Bring in updates to roraty encoder driver switching it away from legacy platform data and over to generic device properties and adding support for encoders using more than 2 GPIOs.
Unified · Split
| @@ -22,8 +22,7 @@ Required properties: · 21 unmodified lines | ||
| 22 | 22 | Optional properties: |
| 23 | 23 | - ti,hwmods: Name of the hwmods associated to the eDMA CC |
| 24 | 24 | - ti,edma-memcpy-channels: List of channels allocated to be used for memcpy, iow |
| 25 | − these channels will be SW triggered channels. The list must | |
| 26 | − contain 16 bits numbers, see example. | |
| 25 | + these channels will be SW triggered channels. See example. | |
| 27 | 26 | - ti,edma-reserved-slot-ranges: PaRAM slot ranges which should not be used by |
| 28 | 27 | the driver, they are allocated to be used by for example the |
| 29 | 28 | DSP. See example. |
| @@ -56,10 +55,9 @@ edma: edma@49000000 { · 26 unmodified lines | ||
| 56 | 55 | ti,tptcs = <&edma_tptc0 7>, <&edma_tptc1 7>, <&edma_tptc2 0>; |
| 57 | 56 | |
| 58 | 57 | /* Channel 20 and 21 is allocated for memcpy */ |
| 59 | − ti,edma-memcpy-channels = /bits/ 16 <20 21>; | |
| 60 | − /* The following PaRAM slots are reserved: 35-45 and 100-110 */ | |
| 61 | − ti,edma-reserved-slot-ranges = /bits/ 16 <35 10>, | |
| 62 | − /bits/ 16 <100 10>; | |
| 58 | + ti,edma-memcpy-channels = <20 21>; | |
| 59 | + /* The following PaRAM slots are reserved: 35-44 and 100-109 */ | |
| 60 | + ti,edma-reserved-slot-ranges = <35 10>, <100 10>; | |
| 63 | 61 | }; |
| 64 | 62 | |
| 65 | 63 | edma_tptc0: tptc@49800000 { |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | Rotary encoder DT bindings |
| 2 | 2 | |
| 3 | 3 | Required properties: |
| 4 | −- gpios: a spec for two GPIOs to be used | |
| 4 | +- gpios: a spec for at least two GPIOs to be used, most significant first | |
| 5 | 5 | |
| 6 | 6 | Optional properties: |
| 7 | 7 | - linux,axis: the input subsystem axis to map to this rotary encoder. |
| @@ -12,7 +12,7 @@ Each key is represented as a sub-node of "allwinner,sun4i-a10-lradc-keys": · 11 unmodified lines | ||
| 12 | 12 | Required subnode-properties: |
| 13 | 13 | - label: Descriptive name of the key. |
| 14 | 14 | - linux,code: Keycode to emit. |
| 15 | − - channel: Channel this key is attached to, mut be 0 or 1. | |
| 15 | + - channel: Channel this key is attached to, must be 0 or 1. | |
| 16 | 16 | - voltage: Voltage in µV at lradc input when this key is pressed. |
| 17 | 17 | |
| 18 | 18 | Example: |
| @@ -6,7 +6,9 @@ used for what purposes, but which don't use an on-flash partition table such · 5 unmodified lines | ||
| 6 | 6 | as RedBoot. |
| 7 | 7 | |
| 8 | 8 | The partition table should be a subnode of the mtd node and should be named |
| 9 | −'partitions'. Partitions are defined in subnodes of the partitions node. | |
| 9 | +'partitions'. This node should have the following property: | |
| 10 | +- compatible : (required) must be "fixed-partitions" | |
| 11 | +Partitions are then defined in subnodes of the partitions node. | |
| 10 | 12 | |
| 11 | 13 | For backwards compatibility partitions as direct subnodes of the mtd device are |
| 12 | 14 | supported. This use is discouraged. |
| @@ -36,6 +38,7 @@ Examples: · 23 unmodified lines | ||
| 36 | 38 | |
| 37 | 39 | flash@0 { |
| 38 | 40 | partitions { |
| 41 | + compatible = "fixed-partitions"; | |
| 39 | 42 | #address-cells = <1>; |
| 40 | 43 | #size-cells = <1>; |
| 41 | 44 | |
| @@ -53,6 +56,7 @@ flash@0 { · 11 unmodified lines | ||
| 53 | 56 | |
| 54 | 57 | flash@1 { |
| 55 | 58 | partitions { |
| 59 | + compatible = "fixed-partitions"; | |
| 56 | 60 | #address-cells = <1>; |
| 57 | 61 | #size-cells = <2>; |
| 58 | 62 | |
| @@ -66,6 +70,7 @@ flash@1 { · 7 unmodified lines | ||
| 66 | 70 | |
| 67 | 71 | flash@2 { |
| 68 | 72 | partitions { |
| 73 | + compatible = "fixed-partitions"; | |
| 69 | 74 | #address-cells = <2>; |
| 70 | 75 | #size-cells = <2>; |
| 71 | 76 | |
| @@ -40,18 +40,18 @@ Optional properties: · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | Slave Properties: |
| 42 | 42 | Required properties: |
| 43 | −- phy_id : Specifies slave phy id | |
| 44 | 43 | - phy-mode : See ethernet.txt file in the same directory |
| 45 | 44 | |
| 46 | 45 | Optional properties: |
| 47 | 46 | - dual_emac_res_vlan : Specifies VID to be used to segregate the ports |
| 48 | 47 | - mac-address : See ethernet.txt file in the same directory |
| 48 | +- phy_id : Specifies slave phy id | |
| 49 | 49 | - phy-handle : See ethernet.txt file in the same directory |
| 50 | 50 | |
| 51 | 51 | Slave sub-nodes: |
| 52 | 52 | - fixed-link : See fixed-link.txt file in the same directory |
| 53 | − Either the properties phy_id and phy-mode, | |
| 54 | − or the sub-node fixed-link can be specified | |
| 53 | + Either the property phy_id, or the sub-node | |
| 54 | + fixed-link can be specified | |
| 55 | 55 | |
| 56 | 56 | Note: "ti,hwmods" field is used to fetch the base address and irq |
| 57 | 57 | resources from TI, omap hwmod data base during device registration. |
| @@ -181,17 +181,3 @@ For general information, go to the Intel support website at: · 180 unmodified lines | ||
| 181 | 181 | If an issue is identified with the released source code on the supported |
| 182 | 182 | kernel with a supported adapter, email the specific information related to the |
| 183 | 183 | issue to e1000-devel@lists.sourceforge.net. |
| 184 | − | |
| 185 | − | |
| 186 | −License | |
| 187 | −======= | |
| 188 | − | |
| 189 | −This software program is released under the terms of a license agreement | |
| 190 | −between you ('Licensee') and Intel. Do not use or load this software or any | |
| 191 | −associated materials (collectively, the 'Software') until you have carefully | |
| 192 | −read the full terms and conditions of the file COPYING located in this software | |
| 193 | −package. By loading or using the Software, you agree to the terms of this | |
| 194 | −Agreement. If you do not agree with the terms of this Agreement, do not install | |
| 195 | −or use the Software. | |
| 196 | − | |
| 197 | −* Other names and brands may be claimed as the property of others. | |
| @@ -5578,7 +5578,7 @@ R: Jesse Brandeburg <jesse.brandeburg@intel.com> · 5577 unmodified lines | ||
| 5578 | 5578 | R: Shannon Nelson <shannon.nelson@intel.com> |
| 5579 | 5579 | R: Carolyn Wyborny <carolyn.wyborny@intel.com> |
| 5580 | 5580 | R: Don Skidmore <donald.c.skidmore@intel.com> |
| 5581 | −R: Matthew Vick <matthew.vick@intel.com> | |
| 5581 | +R: Bruce Allan <bruce.w.allan@intel.com> | |
| 5582 | 5582 | R: John Ronciak <john.ronciak@intel.com> |
| 5583 | 5583 | R: Mitch Williams <mitch.a.williams@intel.com> |
| 5584 | 5584 | L: intel-wired-lan@lists.osuosl.org |
| @@ -8380,6 +8380,14 @@ L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) · 2795 unmodified lines | ||
| 8380 | 8380 | S: Maintained |
| 8381 | 8381 | F: drivers/pinctrl/samsung/ |
| 8382 | 8382 | |
| 8383 | +PIN CONTROLLER - SINGLE | |
| 8384 | +M: Tony Lindgren <tony@atomide.com> | |
| 8385 | +M: Haojian Zhuang <haojian.zhuang@linaro.org> | |
| 8386 | +L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | |
| 8387 | +L: linux-omap@vger.kernel.org | |
| 8388 | +S: Maintained | |
| 8389 | +F: drivers/pinctrl/pinctrl-single.c | |
| 8390 | + | |
| 8383 | 8391 | PIN CONTROLLER - ST SPEAR |
| 8384 | 8392 | M: Viresh Kumar <vireshk@kernel.org> |
| 8385 | 8393 | L: spear-devel@list.st.com |
| @@ -8946,6 +8954,13 @@ F: drivers/rpmsg/ · 560 unmodified lines | ||
| 8946 | 8954 | F: Documentation/rpmsg.txt |
| 8947 | 8955 | F: include/linux/rpmsg.h |
| 8948 | 8956 | |
| 8957 | +RENESAS ETHERNET DRIVERS | |
| 8958 | +R: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> | |
| 8959 | +L: netdev@vger.kernel.org | |
| 8960 | +L: linux-sh@vger.kernel.org | |
| 8961 | +F: drivers/net/ethernet/renesas/ | |
| 8962 | +F: include/linux/sh_eth.h | |
| 8963 | + | |
| 8949 | 8964 | RESET CONTROLLER FRAMEWORK |
| 8950 | 8965 | M: Philipp Zabel <p.zabel@pengutronix.de> |
| 8951 | 8966 | S: Maintained |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | VERSION = 4 |
| 2 | 2 | PATCHLEVEL = 4 |
| 3 | 3 | SUBLEVEL = 0 |
| 4 | −EXTRAVERSION = -rc5 | |
| 4 | +EXTRAVERSION = | |
| 5 | 5 | NAME = Blurry Fish Butt |
| 6 | 6 | |
| 7 | 7 | # *DOCUMENTATION* |
| @@ -445,6 +445,7 @@ config LINUX_LINK_BASE · 444 unmodified lines | ||
| 445 | 445 | However some customers have peripherals mapped at this addr, so |
| 446 | 446 | Linux needs to be scooted a bit. |
| 447 | 447 | If you don't know what the above means, leave this setting alone. |
| 448 | + This needs to match memory start address specified in Device Tree | |
| 448 | 449 | |
| 449 | 450 | config HIGHMEM |
| 450 | 451 | bool "High Memory Support" |
| @@ -81,7 +81,7 @@ endif · 80 unmodified lines | ||
| 81 | 81 | LIBGCC := $(shell $(CC) $(cflags-y) --print-libgcc-file-name) |
| 82 | 82 | |
| 83 | 83 | # Modules with short calls might break for calls into builtin-kernel |
| 84 | −KBUILD_CFLAGS_MODULE += -mlong-calls | |
| 84 | +KBUILD_CFLAGS_MODULE += -mlong-calls -mno-millicode | |
| 85 | 85 | |
| 86 | 86 | # Finally dump eveything into kernel build system |
| 87 | 87 | KBUILD_CFLAGS += $(cflags-y) |
| @@ -46,6 +46,7 @@ · 45 unmodified lines | ||
| 46 | 46 | snps,pbl = < 32 >; |
| 47 | 47 | clocks = <&apbclk>; |
| 48 | 48 | clock-names = "stmmaceth"; |
| 49 | + max-speed = <100>; | |
| 49 | 50 | }; |
| 50 | 51 | |
| 51 | 52 | ehci@0x40000 { |
| @@ -17,7 +17,8 @@ · 16 unmodified lines | ||
| 17 | 17 | |
| 18 | 18 | memory { |
| 19 | 19 | device_type = "memory"; |
| 20 | − reg = <0x0 0x80000000 0x0 0x40000000 /* 1 GB low mem */ | |
| 20 | + /* CONFIG_LINUX_LINK_BASE needs to match low mem start */ | |
| 21 | + reg = <0x0 0x80000000 0x0 0x20000000 /* 512 MB low mem */ | |
| 21 | 22 | 0x1 0x00000000 0x0 0x40000000>; /* 1 GB highmem */ |
| 22 | 23 | }; |
| 23 | 24 | |
| @@ -62,9 +62,7 @@ extern int ioc_exists; · 61 unmodified lines | ||
| 62 | 62 | #define ARC_REG_IC_IVIC 0x10 |
| 63 | 63 | #define ARC_REG_IC_CTRL 0x11 |
| 64 | 64 | #define ARC_REG_IC_IVIL 0x19 |
| 65 | −#if defined(CONFIG_ARC_MMU_V3) || defined(CONFIG_ARC_MMU_V4) | |
| 66 | 65 | #define ARC_REG_IC_PTAG 0x1E |
| 67 | −#endif | |
| 68 | 66 | #define ARC_REG_IC_PTAG_HI 0x1F |
| 69 | 67 | |
| 70 | 68 | /* Bit val in IC_CTRL */ |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | * @dt_compat: Array of device tree 'compatible' strings |
| 24 | 24 | * (XXX: although only 1st entry is looked at) |
| 25 | 25 | * @init_early: Very early callback [called from setup_arch()] |
| 26 | − * @init_cpu_smp: for each CPU as it is coming up (SMP as well as UP) | |
| 26 | + * @init_per_cpu: for each CPU as it is coming up (SMP as well as UP) | |
| 27 | 27 | * [(M):init_IRQ(), (o):start_kernel_secondary()] |
| 28 | 28 | * @init_machine: arch initcall level callback (e.g. populate static |
| 29 | 29 | * platform devices or parse Devicetree) |
| @@ -35,7 +35,7 @@ struct machine_desc { · 5 unmodified lines | ||
| 35 | 35 | const char **dt_compat; |
| 36 | 36 | void (*init_early)(void); |
| 37 | 37 | #ifdef CONFIG_SMP |
| 38 | − void (*init_cpu_smp)(unsigned int); | |
| 38 | + void (*init_per_cpu)(unsigned int); | |
| 39 | 39 | #endif |
| 40 | 40 | void (*init_machine)(void); |
| 41 | 41 | void (*init_late)(void); |
| @@ -48,7 +48,7 @@ extern int smp_ipi_irq_setup(int cpu, int irq); · 47 unmodified lines | ||
| 48 | 48 | * @init_early_smp: A SMP specific h/w block can init itself |
| 49 | 49 | * Could be common across platforms so not covered by |
| 50 | 50 | * mach_desc->init_early() |
| 51 | − * @init_irq_cpu: Called for each core so SMP h/w block driver can do | |
| 51 | + * @init_per_cpu: Called for each core so SMP h/w block driver can do | |
| 52 | 52 | * any needed setup per cpu (e.g. IPI request) |
| 53 | 53 | * @cpu_kick: For Master to kickstart a cpu (optionally at a PC) |
| 54 | 54 | * @ipi_send: To send IPI to a @cpu |
| @@ -57,7 +57,7 @@ extern int smp_ipi_irq_setup(int cpu, int irq); · 2 unmodified lines | ||
| 57 | 57 | struct plat_smp_ops { |
| 58 | 58 | const char *info; |
| 59 | 59 | void (*init_early_smp)(void); |
| 60 | − void (*init_irq_cpu)(int cpu); | |
| 60 | + void (*init_per_cpu)(int cpu); | |
| 61 | 61 | void (*cpu_kick)(int cpu, unsigned long pc); |
| 62 | 62 | void (*ipi_send)(int cpu); |
| 63 | 63 | void (*ipi_clear)(int irq); |
| @@ -112,7 +112,6 @@ struct unwind_frame_info { · 111 unmodified lines | ||
| 112 | 112 | |
| 113 | 113 | extern int arc_unwind(struct unwind_frame_info *frame); |
| 114 | 114 | extern void arc_unwind_init(void); |
| 115 | −extern void arc_unwind_setup(void); | |
| 116 | 115 | extern void *unwind_add_table(struct module *module, const void *table_start, |
| 117 | 116 | unsigned long table_size); |
| 118 | 117 | extern void unwind_remove_table(void *handle, int init_only); |
| @@ -152,9 +151,6 @@ static inline void arc_unwind_init(void) · 33 unmodified lines | ||
| 152 | 151 | { |
| 153 | 152 | } |
| 154 | 153 | |
| 155 | −static inline void arc_unwind_setup(void) | |
| 156 | −{ | |
| 157 | −} | |
| 158 | 154 | #define unwind_add_table(a, b, c) |
| 159 | 155 | #define unwind_remove_table(a, b) |
| 160 | 156 | |
| @@ -106,10 +106,21 @@ static struct irq_chip arcv2_irq_chip = { · 105 unmodified lines | ||
| 106 | 106 | static int arcv2_irq_map(struct irq_domain *d, unsigned int irq, |
| 107 | 107 | irq_hw_number_t hw) |
| 108 | 108 | { |
| 109 | − if (irq == TIMER0_IRQ || irq == IPI_IRQ) | |
| 109 | + /* | |
| 110 | + * core intc IRQs [16, 23]: | |
| 111 | + * Statically assigned always private-per-core (Timers, WDT, IPI, PCT) | |
| 112 | + */ | |
| 113 | + if (hw < 24) { | |
| 114 | + /* | |
| 115 | + * A subsequent request_percpu_irq() fails if percpu_devid is | |
| 116 | + * not set. That in turns sets NOAUTOEN, meaning each core needs | |
| 117 | + * to call enable_percpu_irq() | |
| 118 | + */ | |
| 119 | + irq_set_percpu_devid(irq); | |
| 110 | 120 | irq_set_chip_and_handler(irq, &arcv2_irq_chip, handle_percpu_irq); |
| 111 | − else | |
| 121 | + } else { | |
| 112 | 122 | irq_set_chip_and_handler(irq, &arcv2_irq_chip, handle_level_irq); |
| 123 | + } | |
| 113 | 124 | |
| 114 | 125 | return 0; |
| 115 | 126 | } |
| @@ -29,11 +29,11 @@ void __init init_IRQ(void) · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | #ifdef CONFIG_SMP |
| 31 | 31 | /* a SMP H/w block could do IPI IRQ request here */ |
| 32 | − if (plat_smp_ops.init_irq_cpu) | |
| 33 | − plat_smp_ops.init_irq_cpu(smp_processor_id()); | |
| 32 | + if (plat_smp_ops.init_per_cpu) | |
| 33 | + plat_smp_ops.init_per_cpu(smp_processor_id()); | |
| 34 | 34 | |
| 35 | − if (machine_desc->init_cpu_smp) | |
| 36 | − machine_desc->init_cpu_smp(smp_processor_id()); | |
| 35 | + if (machine_desc->init_per_cpu) | |
| 36 | + machine_desc->init_per_cpu(smp_processor_id()); | |
| 37 | 37 | #endif |
| 38 | 38 | } |
| 39 | 39 | |
| @@ -51,6 +51,18 @@ void arch_do_IRQ(unsigned int irq, struct pt_regs *regs) · 11 unmodified lines | ||
| 51 | 51 | set_irq_regs(old_regs); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | +/* | |
| 55 | + * API called for requesting percpu interrupts - called by each CPU | |
| 56 | + * - For boot CPU, actually request the IRQ with genirq core + enables | |
| 57 | + * - For subsequent callers only enable called locally | |
| 58 | + * | |
| 59 | + * Relies on being called by boot cpu first (i.e. request called ahead) of | |
| 60 | + * any enable as expected by genirq. Hence Suitable only for TIMER, IPI | |
| 61 | + * which are guaranteed to be setup on boot core first. | |
| 62 | + * Late probed peripherals such as perf can't use this as there no guarantee | |
| 63 | + * of being called on boot CPU first. | |
| 64 | + */ | |
| 65 | + | |
| 54 | 66 | void arc_request_percpu_irq(int irq, int cpu, |
| 55 | 67 | irqreturn_t (*isr)(int irq, void *dev), |
| 56 | 68 | const char *irq_nm, |
| @@ -60,14 +72,17 @@ void arc_request_percpu_irq(int irq, int cpu, · 3 unmodified lines | ||
| 60 | 72 | if (!cpu) { |
| 61 | 73 | int rc; |
| 62 | 74 | |
| 75 | +#ifdef CONFIG_ISA_ARCOMPACT | |
| 63 | 76 | /* |
| 64 | − * These 2 calls are essential to making percpu IRQ APIs work | |
| 65 | − * Ideally these details could be hidden in irq chip map function | |
| 66 | − * but the issue is IPIs IRQs being static (non-DT) and platform | |
| 67 | − * specific, so we can't identify them there. | |
| 77 | + * A subsequent request_percpu_irq() fails if percpu_devid is | |
| 78 | + * not set. That in turns sets NOAUTOEN, meaning each core needs | |
| 79 | + * to call enable_percpu_irq() | |
| 80 | + * | |
| 81 | + * For ARCv2, this is done in irq map function since we know | |
| 82 | + * which irqs are strictly per cpu | |
| 68 | 83 | */ |
| 69 | 84 | irq_set_percpu_devid(irq); |
| 70 | − irq_modify_status(irq, IRQ_NOAUTOEN, 0); /* @irq, @clr, @set */ | |
| 85 | +#endif | |
| 71 | 86 | |
| 72 | 87 | rc = request_percpu_irq(irq, isr, irq_nm, percpu_dev); |
| 73 | 88 | if (rc) |
| @@ -132,7 +132,7 @@ static void mcip_probe_n_setup(void) · 131 unmodified lines | ||
| 132 | 132 | struct plat_smp_ops plat_smp_ops = { |
| 133 | 133 | .info = smp_cpuinfo_buf, |
| 134 | 134 | .init_early_smp = mcip_probe_n_setup, |
| 135 | − .init_irq_cpu = mcip_setup_per_cpu, | |
| 135 | + .init_per_cpu = mcip_setup_per_cpu, | |
| 136 | 136 | .ipi_send = mcip_ipi_send, |
| 137 | 137 | .ipi_clear = mcip_ipi_clear, |
| 138 | 138 | }; |
| @@ -428,12 +428,11 @@ static irqreturn_t arc_pmu_intr(int irq, void *dev) · 427 unmodified lines | ||
| 428 | 428 | |
| 429 | 429 | #endif /* CONFIG_ISA_ARCV2 */ |
| 430 | 430 | |
| 431 | −void arc_cpu_pmu_irq_init(void) | |
| 431 | +static void arc_cpu_pmu_irq_init(void *data) | |
| 432 | 432 | { |
| 433 | − struct arc_pmu_cpu *pmu_cpu = this_cpu_ptr(&arc_pmu_cpu); | |
| 433 | + int irq = *(int *)data; | |
| 434 | 434 | |
| 435 | − arc_request_percpu_irq(arc_pmu->irq, smp_processor_id(), arc_pmu_intr, | |
| 436 | − "ARC perf counters", pmu_cpu); | |
| 435 | + enable_percpu_irq(irq, IRQ_TYPE_NONE); | |
| 437 | 436 | |
| 438 | 437 | /* Clear all pending interrupt flags */ |
| 439 | 438 | write_aux_reg(ARC_REG_PCT_INT_ACT, 0xffffffff); |
| @@ -515,7 +514,6 @@ static int arc_pmu_device_probe(struct platform_device *pdev) · 75 unmodified lines | ||
| 515 | 514 | |
| 516 | 515 | if (has_interrupts) { |
| 517 | 516 | int irq = platform_get_irq(pdev, 0); |
| 518 | − unsigned long flags; | |
| 519 | 517 | |
| 520 | 518 | if (irq < 0) { |
| 521 | 519 | pr_err("Cannot get IRQ number for the platform\n"); |
| @@ -524,24 +522,12 @@ static int arc_pmu_device_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 524 | 522 | |
| 525 | 523 | arc_pmu->irq = irq; |
| 526 | 524 | |
| 527 | − /* | |
| 528 | − * arc_cpu_pmu_irq_init() needs to be called on all cores for | |
| 529 | − * their respective local PMU. | |
| 530 | − * However we use opencoded on_each_cpu() to ensure it is called | |
| 531 | − * on core0 first, so that arc_request_percpu_irq() sets up | |
| 532 | − * AUTOEN etc. Otherwise enable_percpu_irq() fails to enable | |
| 533 | − * perf IRQ on non master cores. | |
| 534 | − * see arc_request_percpu_irq() | |
| 535 | − */ | |
| 536 | − preempt_disable(); | |
| 537 | − local_irq_save(flags); | |
| 538 | − arc_cpu_pmu_irq_init(); | |
| 539 | − local_irq_restore(flags); | |
| 540 | − smp_call_function((smp_call_func_t)arc_cpu_pmu_irq_init, 0, 1); | |
| 541 | − preempt_enable(); | |
| 542 | − | |
| 543 | − /* Clean all pending interrupt flags */ | |
| 544 | − write_aux_reg(ARC_REG_PCT_INT_ACT, 0xffffffff); | |
| 525 | + /* intc map function ensures irq_set_percpu_devid() called */ | |
| 526 | + request_percpu_irq(irq, arc_pmu_intr, "ARC perf counters", | |
| 527 | + this_cpu_ptr(&arc_pmu_cpu)); | |
| 528 | + | |
| 529 | + on_each_cpu(arc_cpu_pmu_irq_init, &irq, 1); | |
| 530 | + | |
| 545 | 531 | } else |
| 546 | 532 | arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; |
| 547 | 533 | |
| @@ -429,7 +429,6 @@ void __init setup_arch(char **cmdline_p) · 428 unmodified lines | ||
| 429 | 429 | #endif |
| 430 | 430 | |
| 431 | 431 | arc_unwind_init(); |
| 432 | − arc_unwind_setup(); | |
| 433 | 432 | } |
| 434 | 433 | |
| 435 | 434 | static int __init customize_machine(void) |
| @@ -132,11 +132,11 @@ void start_kernel_secondary(void) · 131 unmodified lines | ||
| 132 | 132 | pr_info("## CPU%u LIVE ##: Executing Code...\n", cpu); |
| 133 | 133 | |
| 134 | 134 | /* Some SMP H/w setup - for each cpu */ |
| 135 | − if (plat_smp_ops.init_irq_cpu) | |
| 136 | − plat_smp_ops.init_irq_cpu(cpu); | |
| 135 | + if (plat_smp_ops.init_per_cpu) | |
| 136 | + plat_smp_ops.init_per_cpu(cpu); | |
| 137 | 137 | |
| 138 | − if (machine_desc->init_cpu_smp) | |
| 139 | − machine_desc->init_cpu_smp(cpu); | |
| 138 | + if (machine_desc->init_per_cpu) | |
| 139 | + machine_desc->init_per_cpu(cpu); | |
| 140 | 140 | |
| 141 | 141 | arc_local_timer_setup(); |
| 142 | 142 | |
| @@ -170,6 +170,23 @@ static struct unwind_table *find_table(unsigned long pc) · 169 unmodified lines | ||
| 170 | 170 | |
| 171 | 171 | static unsigned long read_pointer(const u8 **pLoc, |
| 172 | 172 | const void *end, signed ptrType); |
| 173 | +static void init_unwind_hdr(struct unwind_table *table, | |
| 174 | + void *(*alloc) (unsigned long)); | |
| 175 | + | |
| 176 | +/* | |
| 177 | + * wrappers for header alloc (vs. calling one vs. other at call site) | |
| 178 | + * to elide section mismatches warnings | |
| 179 | + */ | |
| 180 | +static void *__init unw_hdr_alloc_early(unsigned long sz) | |
| 181 | +{ | |
| 182 | + return __alloc_bootmem_nopanic(sz, sizeof(unsigned int), | |
| 183 | + MAX_DMA_ADDRESS); | |
| 184 | +} | |
| 185 | + | |
| 186 | +static void *unw_hdr_alloc(unsigned long sz) | |
| 187 | +{ | |
| 188 | + return kmalloc(sz, GFP_KERNEL); | |
| 189 | +} | |
| 173 | 190 | |
| 174 | 191 | static void init_unwind_table(struct unwind_table *table, const char *name, |
| 175 | 192 | const void *core_start, unsigned long core_size, |
| @@ -209,6 +226,8 @@ void __init arc_unwind_init(void) · 33 unmodified lines | ||
| 209 | 226 | __start_unwind, __end_unwind - __start_unwind, |
| 210 | 227 | NULL, 0); |
| 211 | 228 | /*__start_unwind_hdr, __end_unwind_hdr - __start_unwind_hdr);*/ |
| 229 | + | |
| 230 | + init_unwind_hdr(&root_table, unw_hdr_alloc_early); | |
| 212 | 231 | } |
| 213 | 232 | |
| 214 | 233 | static const u32 bad_cie, not_fde; |
| @@ -241,8 +260,8 @@ static void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size) · 26 unmodified lines | ||
| 241 | 260 | e2->fde = v; |
| 242 | 261 | } |
| 243 | 262 | |
| 244 | −static void __init setup_unwind_table(struct unwind_table *table, | |
| 245 | − void *(*alloc) (unsigned long)) | |
| 263 | +static void init_unwind_hdr(struct unwind_table *table, | |
| 264 | + void *(*alloc) (unsigned long)) | |
| 246 | 265 | { |
| 247 | 266 | const u8 *ptr; |
| 248 | 267 | unsigned long tableSize = table->size, hdrSize; |
| @@ -277,10 +296,10 @@ static void __init setup_unwind_table(struct unwind_table *table, · 28 unmodified lines | ||
| 277 | 296 | if (cie == ¬_fde) |
| 278 | 297 | continue; |
| 279 | 298 | if (cie == NULL || cie == &bad_cie) |
| 280 | − return; | |
| 299 | + goto ret_err; | |
| 281 | 300 | ptrType = fde_pointer_type(cie); |
| 282 | 301 | if (ptrType < 0) |
| 283 | − return; | |
| 302 | + goto ret_err; | |
| 284 | 303 | |
| 285 | 304 | ptr = (const u8 *)(fde + 2); |
| 286 | 305 | if (!read_pointer(&ptr, (const u8 *)(fde + 1) + *fde, |
| @@ -296,13 +315,15 @@ static void __init setup_unwind_table(struct unwind_table *table, · 9 unmodified lines | ||
| 296 | 315 | } |
| 297 | 316 | |
| 298 | 317 | if (tableSize || !n) |
| 299 | − return; | |
| 318 | + goto ret_err; | |
| 300 | 319 | |
| 301 | 320 | hdrSize = 4 + sizeof(unsigned long) + sizeof(unsigned int) |
| 302 | 321 | + 2 * n * sizeof(unsigned long); |
| 322 | + | |
| 303 | 323 | header = alloc(hdrSize); |
| 304 | 324 | if (!header) |
| 305 | − return; | |
| 325 | + goto ret_err; | |
| 326 | + | |
| 306 | 327 | header->version = 1; |
| 307 | 328 | header->eh_frame_ptr_enc = DW_EH_PE_abs | DW_EH_PE_native; |
| 308 | 329 | header->fde_count_enc = DW_EH_PE_abs | DW_EH_PE_data4; |
| @@ -340,18 +361,10 @@ static void __init setup_unwind_table(struct unwind_table *table, · 31 unmodified lines | ||
| 340 | 361 | table->hdrsz = hdrSize; |
| 341 | 362 | smp_wmb(); |
| 342 | 363 | table->header = (const void *)header; |
| 343 | −} | |
| 344 | − | |
| 345 | −static void *__init balloc(unsigned long sz) | |
| 346 | −{ | |
| 347 | − return __alloc_bootmem_nopanic(sz, | |
| 348 | − sizeof(unsigned int), | |
| 349 | − __pa(MAX_DMA_ADDRESS)); | |
| 350 | −} | |
| 364 | + return; | |
| 351 | 365 | |
| 352 | −void __init arc_unwind_setup(void) | |
| 353 | −{ | |
| 354 | − setup_unwind_table(&root_table, balloc); | |
| 366 | +ret_err: | |
| 367 | + panic("Attention !!! Dwarf FDE parsing errors\n");; | |
| 355 | 368 | } |
| 356 | 369 | |
| 357 | 370 | #ifdef CONFIG_MODULES |
| @@ -377,6 +390,8 @@ void *unwind_add_table(struct module *module, const void *table_start, · 19 unmodified lines | ||
| 377 | 390 | table_start, table_size, |
| 378 | 391 | NULL, 0); |
| 379 | 392 | |
| 393 | + init_unwind_hdr(table, unw_hdr_alloc); | |
| 394 | + | |
| 380 | 395 | #ifdef UNWIND_DEBUG |
| 381 | 396 | unw_debug("Table added for [%s] %lx %lx\n", |
| 382 | 397 | module->name, table->core.pc, table->core.range); |
| @@ -439,6 +454,7 @@ void unwind_remove_table(void *handle, int init_only) · 56 unmodified lines | ||
| 439 | 454 | info.init_only = init_only; |
| 440 | 455 | |
| 441 | 456 | unlink_table(&info); /* XXX: SMP */ |
| 457 | + kfree(table->header); | |
| 442 | 458 | kfree(table); |
| 443 | 459 | } |
| 444 | 460 | |
| @@ -588,9 +604,6 @@ static signed fde_pointer_type(const u32 *cie) · 143 unmodified lines | ||
| 588 | 604 | const u8 *ptr = (const u8 *)(cie + 2); |
| 589 | 605 | unsigned version = *ptr; |
| 590 | 606 | |
| 591 | − if (version != 1) | |
| 592 | − return -1; /* unsupported */ | |
| 593 | − | |
| 594 | 607 | if (*++ptr) { |
| 595 | 608 | const char *aug; |
| 596 | 609 | const u8 *end = (const u8 *)(cie + 1) + *cie; |
| @@ -1002,9 +1015,7 @@ int arc_unwind(struct unwind_frame_info *frame) · 405 unmodified lines | ||
| 1002 | 1015 | ptr = (const u8 *)(cie + 2); |
| 1003 | 1016 | end = (const u8 *)(cie + 1) + *cie; |
| 1004 | 1017 | frame->call_frame = 1; |
| 1005 | − if ((state.version = *ptr) != 1) | |
| 1006 | − cie = NULL; /* unsupported version */ | |
| 1007 | − else if (*++ptr) { | |
| 1018 | + if (*++ptr) { | |
| 1008 | 1019 | /* check if augmentation size is first (thus present) */ |
| 1009 | 1020 | if (*ptr == 'z') { |
| 1010 | 1021 | while (++ptr < end && *ptr) { |
| @@ -111,7 +111,7 @@ void __kunmap_atomic(void *kv) · 110 unmodified lines | ||
| 111 | 111 | } |
| 112 | 112 | EXPORT_SYMBOL(__kunmap_atomic); |
| 113 | 113 | |
| 114 | −noinline pte_t *alloc_kmap_pgtable(unsigned long kvaddr) | |
| 114 | +static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr) | |
| 115 | 115 | { |
| 116 | 116 | pgd_t *pgd_k; |
| 117 | 117 | pud_t *pud_k; |
| @@ -127,7 +127,7 @@ noinline pte_t *alloc_kmap_pgtable(unsigned long kvaddr) · 9 unmodified lines | ||
| 127 | 127 | return pte_k; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | −void kmap_init(void) | |
| 130 | +void __init kmap_init(void) | |
| 131 | 131 | { |
| 132 | 132 | /* Due to recursive include hell, we can't do this in processor.h */ |
| 133 | 133 | BUILD_BUG_ON(PAGE_OFFSET < (VMALLOC_END + FIXMAP_SIZE + PKMAP_SIZE)); |
| @@ -51,7 +51,9 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) · 50 unmodified lines | ||
| 51 | 51 | int in_use = 0; |
| 52 | 52 | |
| 53 | 53 | if (!low_mem_sz) { |
| 54 | − BUG_ON(base != low_mem_start); | |
| 54 | + if (base != low_mem_start) | |
| 55 | + panic("CONFIG_LINUX_LINK_BASE != DT memory { }"); | |
| 56 | + | |
| 55 | 57 | low_mem_sz = size; |
| 56 | 58 | in_use = 1; |
| 57 | 59 | } else { |
| @@ -154,7 +154,7 @@ · 153 unmodified lines | ||
| 154 | 154 | &fec { |
| 155 | 155 | pinctrl-names = "default"; |
| 156 | 156 | pinctrl-0 = <&pinctrl_enet>; |
| 157 | − phy-mode = "rgmii"; | |
| 157 | + phy-mode = "rgmii-id"; | |
| 158 | 158 | phy-reset-gpios = <&gpio1 30 GPIO_ACTIVE_HIGH>; |
| 159 | 159 | status = "okay"; |
| 160 | 160 | }; |
| @@ -94,7 +94,7 @@ · 93 unmodified lines | ||
| 94 | 94 | &fec { |
| 95 | 95 | pinctrl-names = "default"; |
| 96 | 96 | pinctrl-0 = <&pinctrl_enet>; |
| 97 | − phy-mode = "rgmii"; | |
| 97 | + phy-mode = "rgmii-id"; | |
| 98 | 98 | phy-reset-gpios = <&gpio1 30 GPIO_ACTIVE_LOW>; |
| 99 | 99 | status = "okay"; |
| 100 | 100 | }; |
| @@ -154,7 +154,7 @@ · 153 unmodified lines | ||
| 154 | 154 | &fec { |
| 155 | 155 | pinctrl-names = "default"; |
| 156 | 156 | pinctrl-0 = <&pinctrl_enet>; |
| 157 | − phy-mode = "rgmii"; | |
| 157 | + phy-mode = "rgmii-id"; | |
| 158 | 158 | phy-reset-gpios = <&gpio1 30 GPIO_ACTIVE_LOW>; |
| 159 | 159 | status = "okay"; |
| 160 | 160 | }; |
| @@ -155,7 +155,7 @@ · 154 unmodified lines | ||
| 155 | 155 | &fec { |
| 156 | 156 | pinctrl-names = "default"; |
| 157 | 157 | pinctrl-0 = <&pinctrl_enet>; |
| 158 | − phy-mode = "rgmii"; | |
| 158 | + phy-mode = "rgmii-id"; | |
| 159 | 159 | phy-reset-gpios = <&gpio1 30 GPIO_ACTIVE_LOW>; |
| 160 | 160 | status = "okay"; |
| 161 | 161 | }; |
| @@ -145,7 +145,7 @@ · 144 unmodified lines | ||
| 145 | 145 | &fec { |
| 146 | 146 | pinctrl-names = "default"; |
| 147 | 147 | pinctrl-0 = <&pinctrl_enet>; |
| 148 | − phy-mode = "rgmii"; | |
| 148 | + phy-mode = "rgmii-id"; | |
| 149 | 149 | phy-reset-gpios = <&gpio1 30 GPIO_ACTIVE_LOW>; |
| 150 | 150 | status = "okay"; |
| 151 | 151 | }; |
| @@ -113,14 +113,14 @@ · 112 unmodified lines | ||
| 113 | 113 | &clks { |
| 114 | 114 | assigned-clocks = <&clks IMX6QDL_PLL4_BYPASS_SRC>, |
| 115 | 115 | <&clks IMX6QDL_PLL4_BYPASS>, |
| 116 | − <&clks IMX6QDL_CLK_PLL4_POST_DIV>, | |
| 117 | 116 | <&clks IMX6QDL_CLK_LDB_DI0_SEL>, |
| 118 | − <&clks IMX6QDL_CLK_LDB_DI1_SEL>; | |
| 117 | + <&clks IMX6QDL_CLK_LDB_DI1_SEL>, | |
| 118 | + <&clks IMX6QDL_CLK_PLL4_POST_DIV>; | |
| 119 | 119 | assigned-clock-parents = <&clks IMX6QDL_CLK_LVDS2_IN>, |
| 120 | 120 | <&clks IMX6QDL_PLL4_BYPASS_SRC>, |
| 121 | 121 | <&clks IMX6QDL_CLK_PLL3_USB_OTG>, |
| 122 | 122 | <&clks IMX6QDL_CLK_PLL3_USB_OTG>; |
| 123 | − assigned-clock-rates = <0>, <0>, <24576000>; | |
| 123 | + assigned-clock-rates = <0>, <0>, <0>, <0>, <24576000>; | |
| 124 | 124 | }; |
| 125 | 125 | |
| 126 | 126 | &ecspi1 { |
| @@ -189,3 +189,7 @@ · 188 unmodified lines | ||
| 189 | 189 | }; |
| 190 | 190 | }; |
| 191 | 191 | |
| 192 | +&uart3 { | |
| 193 | + interrupts-extended = <&wakeupgen GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH | |
| 194 | + &omap4_pmx_core OMAP4_UART3_RX>; | |
| 195 | +}; | |
| @@ -25,9 +25,9 @@ · 24 unmodified lines | ||
| 25 | 25 | cache-sets = <512>; |
| 26 | 26 | cache-line-size = <32>; |
| 27 | 27 | /* At full speed latency must be >=2 */ |
| 28 | − arm,tag-latency = <2>; | |
| 29 | − arm,data-latency = <2 2>; | |
| 30 | − arm,dirty-latency = <2>; | |
| 28 | + arm,tag-latency = <8>; | |
| 29 | + arm,data-latency = <8 8>; | |
| 30 | + arm,dirty-latency = <8>; | |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | mtu0: mtu@101e2000 { |
| @@ -83,6 +83,7 @@ · 82 unmodified lines | ||
| 83 | 83 | reg = <0x5d>; |
| 84 | 84 | interrupt-parent = <&pio>; |
| 85 | 85 | interrupts = <0 3 IRQ_TYPE_LEVEL_HIGH>; /* PA3 */ |
| 86 | + touchscreen-swapped-x-y; | |
| 86 | 87 | }; |
| 87 | 88 | }; |
| 88 | 89 | |
| @@ -399,7 +399,7 @@ · 398 unmodified lines | ||
| 399 | 399 | |
| 400 | 400 | /* CPU DFLL clock */ |
| 401 | 401 | clock@0,70110000 { |
| 402 | − status = "okay"; | |
| 402 | + status = "disabled"; | |
| 403 | 403 | vdd-cpu-supply = <&vdd_cpu>; |
| 404 | 404 | nvidia,i2c-fs-rate = <400000>; |
| 405 | 405 | }; |
| @@ -110,7 +110,11 @@ · 109 unmodified lines | ||
| 110 | 110 | interrupt-parent = <&vic>; |
| 111 | 111 | interrupts = <31>; /* Cascaded to vic */ |
| 112 | 112 | clear-mask = <0xffffffff>; |
| 113 | − valid-mask = <0xffc203f8>; | |
| 113 | + /* | |
| 114 | + * Valid interrupt lines mask according to | |
| 115 | + * table 4-36 page 4-50 of ARM DUI 0225D | |
| 116 | + */ | |
| 117 | + valid-mask = <0x0760031b>; | |
| 114 | 118 | }; |
| 115 | 119 | |
| 116 | 120 | dma@10130000 { |
| @@ -266,8 +270,8 @@ · 149 unmodified lines | ||
| 266 | 270 | }; |
| 267 | 271 | mmc@5000 { |
| 268 | 272 | compatible = "arm,pl180", "arm,primecell"; |
| 269 | − reg = < 0x5000 0x1000>; | |
| 270 | − interrupts-extended = <&vic 22 &sic 2>; | |
| 273 | + reg = <0x5000 0x1000>; | |
| 274 | + interrupts-extended = <&vic 22 &sic 1>; | |
| 271 | 275 | clocks = <&xtal24mhz>, <&pclk>; |
| 272 | 276 | clock-names = "mclk", "apb_pclk"; |
| 273 | 277 | }; |
| @@ -5,6 +5,16 @@ · 4 unmodified lines | ||
| 5 | 5 | compatible = "arm,versatile-pb"; |
| 6 | 6 | |
| 7 | 7 | amba { |
| 8 | + /* The Versatile PB is using more SIC IRQ lines than the AB */ | |
| 9 | + sic: intc@10003000 { | |
| 10 | + clear-mask = <0xffffffff>; | |
| 11 | + /* | |
| 12 | + * Valid interrupt lines mask according to | |
| 13 | + * figure 3-30 page 3-74 of ARM DUI 0224B | |
| 14 | + */ | |
| 15 | + valid-mask = <0x7fe003ff>; | |
| 16 | + }; | |
| 17 | + | |
| 8 | 18 | gpio2: gpio@101e6000 { |
| 9 | 19 | compatible = "arm,pl061", "arm,primecell"; |
| 10 | 20 | reg = <0x101e6000 0x1000>; |
| @@ -67,6 +77,13 @@ · 56 unmodified lines | ||
| 67 | 77 | }; |
| 68 | 78 | |
| 69 | 79 | fpga { |
| 80 | + mmc@5000 { | |
| 81 | + /* | |
| 82 | + * Overrides the interrupt assignment from | |
| 83 | + * the Versatile AB board file. | |
| 84 | + */ | |
| 85 | + interrupts-extended = <&sic 22 &sic 23>; | |
| 86 | + }; | |
| 70 | 87 | uart@9000 { |
| 71 | 88 | compatible = "arm,pl011", "arm,primecell"; |
| 72 | 89 | reg = <0x9000 0x1000>; |
| @@ -86,7 +103,8 @@ · 13 unmodified lines | ||
| 86 | 103 | mmc@b000 { |
| 87 | 104 | compatible = "arm,pl180", "arm,primecell"; |
| 88 | 105 | reg = <0xb000 0x1000>; |
| 89 | − interrupts-extended = <&vic 23 &sic 2>; | |
| 106 | + interrupt-parent = <&sic>; | |
| 107 | + interrupts = <1>, <2>; | |
| 90 | 108 | clocks = <&xtal24mhz>, <&pclk>; |
| 91 | 109 | clock-names = "mclk", "apb_pclk"; |
| 92 | 110 | }; |
| @@ -187,6 +187,15 @@ · 186 unmodified lines | ||
| 187 | 187 | interrupts = <43>; |
| 188 | 188 | }; |
| 189 | 189 | |
| 190 | + sdhc@d800a000 { | |
| 191 | + compatible = "wm,wm8505-sdhc"; | |
| 192 | + reg = <0xd800a000 0x400>; | |
| 193 | + interrupts = <20>, <21>; | |
| 194 | + clocks = <&clksdhc>; | |
| 195 | + bus-width = <4>; | |
| 196 | + sdon-inverted; | |
| 197 | + }; | |
| 198 | + | |
| 190 | 199 | fb: fb@d8050800 { |
| 191 | 200 | compatible = "wm,wm8505-fb"; |
| 192 | 201 | reg = <0xd8050800 0x200>; |
| @@ -366,6 +366,7 @@ CONFIG_BATTERY_MAX17042=m · 365 unmodified lines | ||
| 366 | 366 | CONFIG_CHARGER_MAX14577=m |
| 367 | 367 | CONFIG_CHARGER_MAX77693=m |
| 368 | 368 | CONFIG_CHARGER_TPS65090=y |
| 369 | +CONFIG_AXP20X_POWER=m | |
| 369 | 370 | CONFIG_POWER_RESET_AS3722=y |
| 370 | 371 | CONFIG_POWER_RESET_GPIO=y |
| 371 | 372 | CONFIG_POWER_RESET_GPIO_RESTART=y |
| @@ -84,6 +84,7 @@ CONFIG_SPI_SUN4I=y · 83 unmodified lines | ||
| 84 | 84 | CONFIG_SPI_SUN6I=y |
| 85 | 85 | CONFIG_GPIO_SYSFS=y |
| 86 | 86 | CONFIG_POWER_SUPPLY=y |
| 87 | +CONFIG_AXP20X_POWER=y | |
| 87 | 88 | CONFIG_THERMAL=y |
| 88 | 89 | CONFIG_CPU_THERMAL=y |
| 89 | 90 | CONFIG_WATCHDOG=y |
| @@ -510,10 +510,14 @@ __copy_to_user_std(void __user *to, const void *from, unsigned long n); · 509 unmodified lines | ||
| 510 | 510 | static inline unsigned long __must_check |
| 511 | 511 | __copy_to_user(void __user *to, const void *from, unsigned long n) |
| 512 | 512 | { |
| 513 | +#ifndef CONFIG_UACCESS_WITH_MEMCPY | |
| 513 | 514 | unsigned int __ua_flags = uaccess_save_and_enable(); |
| 514 | 515 | n = arm_copy_to_user(to, from, n); |
| 515 | 516 | uaccess_restore(__ua_flags); |
| 516 | 517 | return n; |
| 518 | +#else | |
| 519 | + return arm_copy_to_user(to, from, n); | |
| 520 | +#endif | |
| 517 | 521 | } |
| 518 | 522 | |
| 519 | 523 | extern unsigned long __must_check |
| @@ -95,6 +95,22 @@ void __show_regs(struct pt_regs *regs) · 94 unmodified lines | ||
| 95 | 95 | { |
| 96 | 96 | unsigned long flags; |
| 97 | 97 | char buf[64]; |
| 98 | +#ifndef CONFIG_CPU_V7M | |
| 99 | + unsigned int domain; | |
| 100 | +#ifdef CONFIG_CPU_SW_DOMAIN_PAN | |
| 101 | + /* | |
| 102 | + * Get the domain register for the parent context. In user | |
| 103 | + * mode, we don't save the DACR, so lets use what it should | |
| 104 | + * be. For other modes, we place it after the pt_regs struct. | |
| 105 | + */ | |
| 106 | + if (user_mode(regs)) | |
| 107 | + domain = DACR_UACCESS_ENABLE; | |
| 108 | + else | |
| 109 | + domain = *(unsigned int *)(regs + 1); | |
| 110 | +#else | |
| 111 | + domain = get_domain(); | |
| 112 | +#endif | |
| 113 | +#endif | |
| 98 | 114 | |
| 99 | 115 | show_regs_print_info(KERN_DEFAULT); |
| 100 | 116 | |
| @@ -123,21 +139,8 @@ void __show_regs(struct pt_regs *regs) · 22 unmodified lines | ||
| 123 | 139 | |
| 124 | 140 | #ifndef CONFIG_CPU_V7M |
| 125 | 141 | { |
| 126 | − unsigned int domain = get_domain(); | |
| 127 | 142 | const char *segment; |
| 128 | 143 | |
| 129 | −#ifdef CONFIG_CPU_SW_DOMAIN_PAN | |
| 130 | − /* | |
| 131 | − * Get the domain register for the parent context. In user | |
| 132 | − * mode, we don't save the DACR, so lets use what it should | |
| 133 | − * be. For other modes, we place it after the pt_regs struct. | |
| 134 | − */ | |
| 135 | − if (user_mode(regs)) | |
| 136 | − domain = DACR_UACCESS_ENABLE; | |
| 137 | − else | |
| 138 | − domain = *(unsigned int *)(regs + 1); | |
| 139 | −#endif | |
| 140 | − | |
| 141 | 144 | if ((domain & domain_mask(DOMAIN_USER)) == |
| 142 | 145 | domain_val(DOMAIN_USER, DOMAIN_NOACCESS)) |
| 143 | 146 | segment = "none"; |
| @@ -163,11 +166,11 @@ void __show_regs(struct pt_regs *regs) · 19 unmodified lines | ||
| 163 | 166 | buf[0] = '\0'; |
| 164 | 167 | #ifdef CONFIG_CPU_CP15_MMU |
| 165 | 168 | { |
| 166 | − unsigned int transbase, dac = get_domain(); | |
| 169 | + unsigned int transbase; | |
| 167 | 170 | asm("mrc p15, 0, %0, c2, c0\n\t" |
| 168 | 171 | : "=r" (transbase)); |
| 169 | 172 | snprintf(buf, sizeof(buf), " Table: %08x DAC: %08x", |
| 170 | − transbase, dac); | |
| 173 | + transbase, domain); | |
| 171 | 174 | } |
| 172 | 175 | #endif |
| 173 | 176 | asm("mrc p15, 0, %0, c1, c0\n" : "=r" (ctrl)); |
| @@ -36,10 +36,10 @@ · 35 unmodified lines | ||
| 36 | 36 | */ |
| 37 | 37 | #define __user_swpX_asm(data, addr, res, temp, B) \ |
| 38 | 38 | __asm__ __volatile__( \ |
| 39 | − " mov %2, %1\n" \ | |
| 40 | − "0: ldrex"B" %1, [%3]\n" \ | |
| 41 | − "1: strex"B" %0, %2, [%3]\n" \ | |
| 39 | + "0: ldrex"B" %2, [%3]\n" \ | |
| 40 | + "1: strex"B" %0, %1, [%3]\n" \ | |
| 42 | 41 | " cmp %0, #0\n" \ |
| 42 | + " moveq %1, %2\n" \ | |
| 43 | 43 | " movne %0, %4\n" \ |
| 44 | 44 | "2:\n" \ |
| 45 | 45 | " .section .text.fixup,\"ax\"\n" \ |
| @@ -193,15 +193,44 @@ struct oabi_flock64 { · 192 unmodified lines | ||
| 193 | 193 | pid_t l_pid; |
| 194 | 194 | } __attribute__ ((packed,aligned(4))); |
| 195 | 195 | |
| 196 | −asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, | |
| 196 | +static long do_locks(unsigned int fd, unsigned int cmd, | |
| 197 | 197 | unsigned long arg) |
| 198 | 198 | { |
| 199 | − struct oabi_flock64 user; | |
| 200 | 199 | struct flock64 kernel; |
| 201 | − mm_segment_t fs = USER_DS; /* initialized to kill a warning */ | |
| 202 | − unsigned long local_arg = arg; | |
| 203 | − int ret; | |
| 200 | + struct oabi_flock64 user; | |
| 201 | + mm_segment_t fs; | |
| 202 | + long ret; | |
| 203 | + | |
| 204 | + if (copy_from_user(&user, (struct oabi_flock64 __user *)arg, | |
| 205 | + sizeof(user))) | |
| 206 | + return -EFAULT; | |
| 207 | + kernel.l_type = user.l_type; | |
| 208 | + kernel.l_whence = user.l_whence; | |
| 209 | + kernel.l_start = user.l_start; | |
| 210 | + kernel.l_len = user.l_len; | |
| 211 | + kernel.l_pid = user.l_pid; | |
| 212 | + | |
| 213 | + fs = get_fs(); | |
| 214 | + set_fs(KERNEL_DS); | |
| 215 | + ret = sys_fcntl64(fd, cmd, (unsigned long)&kernel); | |
| 216 | + set_fs(fs); | |
| 217 | + | |
| 218 | + if (!ret && (cmd == F_GETLK64 || cmd == F_OFD_GETLK)) { | |
| 219 | + user.l_type = kernel.l_type; | |
| 220 | + user.l_whence = kernel.l_whence; | |
| 221 | + user.l_start = kernel.l_start; | |
| 222 | + user.l_len = kernel.l_len; | |
| 223 | + user.l_pid = kernel.l_pid; | |
| 224 | + if (copy_to_user((struct oabi_flock64 __user *)arg, | |
| 225 | + &user, sizeof(user))) | |
| 226 | + ret = -EFAULT; | |
| 227 | + } | |
| 228 | + return ret; | |
| 229 | +} | |
| 204 | 230 | |
| 231 | +asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, | |
| 232 | + unsigned long arg) | |
| 233 | +{ | |
| 205 | 234 | switch (cmd) { |
| 206 | 235 | case F_OFD_GETLK: |
| 207 | 236 | case F_OFD_SETLK: |
| @@ -209,39 +238,11 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, · 1 unmodified line | ||
| 209 | 238 | case F_GETLK64: |
| 210 | 239 | case F_SETLK64: |
| 211 | 240 | case F_SETLKW64: |
| 212 | − if (copy_from_user(&user, (struct oabi_flock64 __user *)arg, | |
| 213 | − sizeof(user))) | |
| 214 | − return -EFAULT; | |
| 215 | − kernel.l_type = user.l_type; | |
| 216 | − kernel.l_whence = user.l_whence; | |
| 217 | − kernel.l_start = user.l_start; | |
| 218 | − kernel.l_len = user.l_len; | |
| 219 | − kernel.l_pid = user.l_pid; | |
| 220 | − local_arg = (unsigned long)&kernel; | |
| 221 | − fs = get_fs(); | |
| 222 | − set_fs(KERNEL_DS); | |
| 223 | − } | |
| 224 | − | |
| 225 | − ret = sys_fcntl64(fd, cmd, local_arg); | |
| 241 | + return do_locks(fd, cmd, arg); | |
| 226 | 242 | |
| 227 | − switch (cmd) { | |
| 228 | − case F_GETLK64: | |
| 229 | − if (!ret) { | |
| 230 | − user.l_type = kernel.l_type; | |
| 231 | − user.l_whence = kernel.l_whence; | |
| 232 | − user.l_start = kernel.l_start; | |
| 233 | − user.l_len = kernel.l_len; | |
| 234 | − user.l_pid = kernel.l_pid; | |
| 235 | − if (copy_to_user((struct oabi_flock64 __user *)arg, | |
| 236 | − &user, sizeof(user))) | |
| 237 | − ret = -EFAULT; | |
| 238 | − } | |
| 239 | − case F_SETLK64: | |
| 240 | − case F_SETLKW64: | |
| 241 | − set_fs(fs); | |
| 243 | + default: | |
| 244 | + return sys_fcntl64(fd, cmd, arg); | |
| 242 | 245 | } |
| 243 | − | |
| 244 | − return ret; | |
| 245 | 246 | } |
| 246 | 247 | |
| 247 | 248 | struct oabi_epoll_event { |
| @@ -88,6 +88,7 @@ pin_page_for_write(const void __user *_addr, pte_t **ptep, spinlock_t **ptlp) · 87 unmodified lines | ||
| 88 | 88 | static unsigned long noinline |
| 89 | 89 | __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n) |
| 90 | 90 | { |
| 91 | + unsigned long ua_flags; | |
| 91 | 92 | int atomic; |
| 92 | 93 | |
| 93 | 94 | if (unlikely(segment_eq(get_fs(), KERNEL_DS))) { |
| @@ -118,7 +119,9 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n) · 24 unmodified lines | ||
| 118 | 119 | if (tocopy > n) |
| 119 | 120 | tocopy = n; |
| 120 | 121 | |
| 122 | + ua_flags = uaccess_save_and_enable(); | |
| 121 | 123 | memcpy((void *)to, from, tocopy); |
| 124 | + uaccess_restore(ua_flags); | |
| 122 | 125 | to += tocopy; |
| 123 | 126 | from += tocopy; |
| 124 | 127 | n -= tocopy; |
| @@ -145,14 +148,21 @@ arm_copy_to_user(void __user *to, const void *from, unsigned long n) · 20 unmodified lines | ||
| 145 | 148 | * With frame pointer disabled, tail call optimization kicks in |
| 146 | 149 | * as well making this test almost invisible. |
| 147 | 150 | */ |
| 148 | − if (n < 64) | |
| 149 | − return __copy_to_user_std(to, from, n); | |
| 150 | − return __copy_to_user_memcpy(to, from, n); | |
| 151 | + if (n < 64) { | |
| 152 | + unsigned long ua_flags = uaccess_save_and_enable(); | |
| 153 | + n = __copy_to_user_std(to, from, n); | |
| 154 | + uaccess_restore(ua_flags); | |
| 155 | + } else { | |
| 156 | + n = __copy_to_user_memcpy(to, from, n); | |
| 157 | + } | |
| 158 | + return n; | |
| 151 | 159 | } |
| 152 | 160 | |
| 153 | 161 | static unsigned long noinline |
| 154 | 162 | __clear_user_memset(void __user *addr, unsigned long n) |
| 155 | 163 | { |
| 164 | + unsigned long ua_flags; | |
| 165 | + | |
| 156 | 166 | if (unlikely(segment_eq(get_fs(), KERNEL_DS))) { |
| 157 | 167 | memset((void *)addr, 0, n); |
| 158 | 168 | return 0; |
| @@ -175,7 +185,9 @@ __clear_user_memset(void __user *addr, unsigned long n) · 16 unmodified lines | ||
| 175 | 185 | if (tocopy > n) |
| 176 | 186 | tocopy = n; |
| 177 | 187 | |
| 188 | + ua_flags = uaccess_save_and_enable(); | |
| 178 | 189 | memset((void *)addr, 0, tocopy); |
| 190 | + uaccess_restore(ua_flags); | |
| 179 | 191 | addr += tocopy; |
| 180 | 192 | n -= tocopy; |
| 181 | 193 | |
| @@ -193,9 +205,14 @@ out: · 11 unmodified lines | ||
| 193 | 205 | unsigned long arm_clear_user(void __user *addr, unsigned long n) |
| 194 | 206 | { |
| 195 | 207 | /* See rational for this in __copy_to_user() above. */ |
| 196 | − if (n < 64) | |
| 197 | − return __clear_user_std(addr, n); | |
| 198 | − return __clear_user_memset(addr, n); | |
| 208 | + if (n < 64) { | |
| 209 | + unsigned long ua_flags = uaccess_save_and_enable(); | |
| 210 | + n = __clear_user_std(addr, n); | |
| 211 | + uaccess_restore(ua_flags); | |
| 212 | + } else { | |
| 213 | + n = __clear_user_memset(addr, n); | |
| 214 | + } | |
| 215 | + return n; | |
| 199 | 216 | } |
| 200 | 217 | |
| 201 | 218 | #if 0 |
| @@ -65,6 +65,8 @@ config SOC_AM43XX · 64 unmodified lines | ||
| 65 | 65 | select MACH_OMAP_GENERIC |
| 66 | 66 | select MIGHT_HAVE_CACHE_L2X0 |
| 67 | 67 | select HAVE_ARM_SCU |
| 68 | + select GENERIC_CLOCKEVENTS_BROADCAST | |
| 69 | + select HAVE_ARM_TWD | |
| 68 | 70 | |
| 69 | 71 | config SOC_DRA7XX |
| 70 | 72 | bool "TI DRA7XX" |
| @@ -149,8 +149,8 @@ static int omap2_onenand_get_freq(struct omap_onenand_platform_data *cfg, · 148 unmodified lines | ||
| 149 | 149 | freq = 104; |
| 150 | 150 | break; |
| 151 | 151 | default: |
| 152 | − freq = 54; | |
| 153 | − break; | |
| 152 | + pr_err("onenand rate not detected, bad GPMC async timings?\n"); | |
| 153 | + freq = 0; | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | return freq; |
| @@ -271,6 +271,11 @@ static int omap2_onenand_setup_async(void __iomem *onenand_base) · 114 unmodified lines | ||
| 271 | 271 | struct gpmc_timings t; |
| 272 | 272 | int ret; |
| 273 | 273 | |
| 274 | + /* | |
| 275 | + * Note that we need to keep sync_write set for the call to | |
| 276 | + * omap2_onenand_set_async_mode() to work to detect the onenand | |
| 277 | + * supported clock rate for the sync timings. | |
| 278 | + */ | |
| 274 | 279 | if (gpmc_onenand_data->of_node) { |
| 275 | 280 | gpmc_read_settings_dt(gpmc_onenand_data->of_node, |
| 276 | 281 | &onenand_async); |
| @@ -281,12 +286,9 @@ static int omap2_onenand_setup_async(void __iomem *onenand_base) · 4 unmodified lines | ||
| 281 | 286 | else |
| 282 | 287 | gpmc_onenand_data->flags |= ONENAND_SYNC_READ; |
| 283 | 288 | onenand_async.sync_read = false; |
| 284 | − onenand_async.sync_write = false; | |
| 285 | 289 | } |
| 286 | 290 | } |
| 287 | 291 | |
| 288 | − omap2_onenand_set_async_mode(onenand_base); | |
| 289 | − | |
| 290 | 292 | omap2_onenand_calc_async_timings(&t); |
| 291 | 293 | |
| 292 | 294 | ret = gpmc_cs_program_settings(gpmc_onenand_data->cs, &onenand_async); |
| @@ -310,6 +312,8 @@ static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr) · 17 unmodified lines | ||
| 310 | 312 | if (!freq) { |
| 311 | 313 | /* Very first call freq is not known */ |
| 312 | 314 | freq = omap2_onenand_get_freq(gpmc_onenand_data, onenand_base); |
| 315 | + if (!freq) | |
| 316 | + return -ENODEV; | |
| 313 | 317 | set_onenand_cfg(onenand_base); |
| 314 | 318 | } |
| 315 | 319 | |
| @@ -320,6 +320,12 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, · 319 unmodified lines | ||
| 320 | 320 | return r; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | +#if !defined(CONFIG_SMP) && defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) | |
| 324 | +void tick_broadcast(const struct cpumask *mask) | |
| 325 | +{ | |
| 326 | +} | |
| 327 | +#endif | |
| 328 | + | |
| 323 | 329 | static void __init omap2_gp_clockevent_init(int gptimer_id, |
| 324 | 330 | const char *fck_source, |
| 325 | 331 | const char *property) |
| @@ -18,12 +18,13 @@ · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | #include <linux/init.h> |
| 20 | 20 | #include <linux/kernel.h> |
| 21 | +#include <linux/property.h> | |
| 21 | 22 | #include <linux/platform_device.h> |
| 22 | 23 | #include <linux/interrupt.h> |
| 23 | 24 | #include <linux/gpio.h> |
| 25 | +#include <linux/gpio/machine.h> | |
| 24 | 26 | #include <linux/smsc911x.h> |
| 25 | 27 | #include <linux/input.h> |
| 26 | −#include <linux/rotary_encoder.h> | |
| 27 | 28 | #include <linux/gpio_keys.h> |
| 28 | 29 | #include <linux/input/eeti_ts.h> |
| 29 | 30 | #include <linux/leds.h> |
| @@ -366,22 +367,38 @@ static struct pxaohci_platform_data raumfeld_ohci_info = { · 336 unmodified lines | ||
| 366 | 367 | * Rotary encoder input device |
| 367 | 368 | */ |
| 368 | 369 | |
| 369 | −static struct rotary_encoder_platform_data raumfeld_rotary_encoder_info = { | |
| 370 | − .steps = 24, | |
| 371 | − .axis = REL_X, | |
| 372 | − .relative_axis = 1, | |
| 373 | − .gpio_a = GPIO_VOLENC_A, | |
| 374 | − .gpio_b = GPIO_VOLENC_B, | |
| 375 | − .inverted_a = 1, | |
| 376 | − .inverted_b = 0, | |
| 370 | +static struct gpiod_lookup_table raumfeld_rotary_gpios_table = { | |
| 371 | + .dev_id = "rotary-encoder.0", | |
| 372 | + .table = { | |
| 373 | + GPIO_LOOKUP_IDX("gpio-0", | |
| 374 | + GPIO_VOLENC_A, NULL, 0, GPIO_ACTIVE_LOW), | |
| 375 | + GPIO_LOOKUP_IDX("gpio-0", | |
| 376 | + GPIO_VOLENC_B, NULL, 1, GPIO_ACTIVE_HIGH), | |
| 377 | + { }, | |
| 378 | + }, | |
| 379 | +}; | |
| 380 | + | |
| 381 | +static u32 raumfeld_rotary_encoder_steps = 24; | |
| 382 | +static u32 raumfeld_rotary_encoder_axis = REL_X; | |
| 383 | +static u32 raumfeld_rotary_encoder_relative_axis = 1; | |
| 384 | + | |
| 385 | +static struct property_entry raumfeld_rotary_properties[] = { | |
| 386 | + { "rotary-encoder,steps-per-period", | |
| 387 | + DEV_PROP_U32, 1, &raumfeld_rotary_encoder_steps, }, | |
| 388 | + { "linux,axis", | |
| 389 | + DEV_PROP_U32, 1, &raumfeld_rotary_encoder_axis, }, | |
| 390 | + { "rotary-encoder,relative_axis", | |
| 391 | + DEV_PROP_U32, 1, &raumfeld_rotary_encoder_relative_axis, }, | |
| 392 | + { NULL } | |
| 393 | +}; | |
| 394 | + | |
| 395 | +static struct property_set raumfeld_rotary_property_set = { | |
| 396 | + .properties = raumfeld_rotary_properties, | |
| 377 | 397 | }; |
| 378 | 398 | |
| 379 | 399 | static struct platform_device rotary_encoder_device = { |
| 380 | 400 | .name = "rotary-encoder", |
| 381 | 401 | .id = 0, |
| 382 | − .dev = { | |
| 383 | − .platform_data = &raumfeld_rotary_encoder_info, | |
| 384 | − } | |
| 385 | 402 | }; |
| 386 | 403 | |
| 387 | 404 | /** |
| @@ -1051,7 +1068,12 @@ static void __init raumfeld_controller_init(void) · 663 unmodified lines | ||
| 1051 | 1068 | int ret; |
| 1052 | 1069 | |
| 1053 | 1070 | pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_controller_pin_config)); |
| 1071 | + | |
| 1072 | + gpiod_add_lookup_table(&raumfeld_rotary_gpios_table); | |
| 1073 | + device_add_property_set(&rotary_encoder_device.dev, | |
| 1074 | + &raumfeld_rotary_property_set); | |
| 1054 | 1075 | platform_device_register(&rotary_encoder_device); |
| 1076 | + | |
| 1055 | 1077 | spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices)); |
| 1056 | 1078 | i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1); |
| 1057 | 1079 | |
| @@ -1086,6 +1108,10 @@ static void __init raumfeld_speaker_init(void) · 28 unmodified lines | ||
| 1086 | 1108 | i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1); |
| 1087 | 1109 | |
| 1088 | 1110 | platform_device_register(&smc91x_device); |
| 1111 | + | |
| 1112 | + gpiod_add_lookup_table(&raumfeld_rotary_gpios_table); | |
| 1113 | + device_add_property_set(&rotary_encoder_device.dev, | |
| 1114 | + &raumfeld_rotary_property_set); | |
| 1089 | 1115 | platform_device_register(&rotary_encoder_device); |
| 1090 | 1116 | |
| 1091 | 1117 | raumfeld_audio_init(); |
| @@ -165,13 +165,28 @@ static void flush_context(unsigned int cpu) · 164 unmodified lines | ||
| 165 | 165 | __flush_icache_all(); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | −static int is_reserved_asid(u64 asid) | |
| 168 | +static bool check_update_reserved_asid(u64 asid, u64 newasid) | |
| 169 | 169 | { |
| 170 | 170 | int cpu; |
| 171 | − for_each_possible_cpu(cpu) | |
| 172 | − if (per_cpu(reserved_asids, cpu) == asid) | |
| 173 | − return 1; | |
| 174 | − return 0; | |
| 171 | + bool hit = false; | |
| 172 | + | |
| 173 | + /* | |
| 174 | + * Iterate over the set of reserved ASIDs looking for a match. | |
| 175 | + * If we find one, then we can update our mm to use newasid | |
| 176 | + * (i.e. the same ASID in the current generation) but we can't | |
| 177 | + * exit the loop early, since we need to ensure that all copies | |
| 178 | + * of the old ASID are updated to reflect the mm. Failure to do | |
| 179 | + * so could result in us missing the reserved ASID in a future | |
| 180 | + * generation. | |
| 181 | + */ | |
| 182 | + for_each_possible_cpu(cpu) { | |
| 183 | + if (per_cpu(reserved_asids, cpu) == asid) { | |
| 184 | + hit = true; | |
| 185 | + per_cpu(reserved_asids, cpu) = newasid; | |
| 186 | + } | |
| 187 | + } | |
| 188 | + | |
| 189 | + return hit; | |
| 175 | 190 | } |
| 176 | 191 | |
| 177 | 192 | static u64 new_context(struct mm_struct *mm, unsigned int cpu) |
| @@ -181,12 +196,14 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu) · 3 unmodified lines | ||
| 181 | 196 | u64 generation = atomic64_read(&asid_generation); |
| 182 | 197 | |
| 183 | 198 | if (asid != 0) { |
| 199 | + u64 newasid = generation | (asid & ~ASID_MASK); | |
| 200 | + | |
| 184 | 201 | /* |
| 185 | 202 | * If our current ASID was active during a rollover, we |
| 186 | 203 | * can continue to use it and this was just a false alarm. |
| 187 | 204 | */ |
| 188 | − if (is_reserved_asid(asid)) | |
| 189 | − return generation | (asid & ~ASID_MASK); | |
| 205 | + if (check_update_reserved_asid(asid, newasid)) | |
| 206 | + return newasid; | |
| 190 | 207 | |
| 191 | 208 | /* |
| 192 | 209 | * We had a valid ASID in a previous life, so try to re-use |
| @@ -194,7 +211,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu) · 1 unmodified line | ||
| 194 | 211 | */ |
| 195 | 212 | asid &= ~ASID_MASK; |
| 196 | 213 | if (!__test_and_set_bit(asid, asid_map)) |
| 197 | − goto bump_gen; | |
| 214 | + return newasid; | |
| 198 | 215 | } |
| 199 | 216 | |
| 200 | 217 | /* |
| @@ -216,11 +233,8 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu) · 15 unmodified lines | ||
| 216 | 233 | |
| 217 | 234 | __set_bit(asid, asid_map); |
| 218 | 235 | cur_idx = asid; |
| 219 | − | |
| 220 | −bump_gen: | |
| 221 | − asid |= generation; | |
| 222 | 236 | cpumask_clear(mm_cpumask(mm)); |
| 223 | − return asid; | |
| 237 | + return asid | generation; | |
| 224 | 238 | } |
| 225 | 239 | |
| 226 | 240 | void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk) |
| @@ -1521,7 +1521,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, · 1520 unmodified lines | ||
| 1521 | 1521 | return -ENOMEM; |
| 1522 | 1522 | |
| 1523 | 1523 | for (count = 0, s = sg; count < (size >> PAGE_SHIFT); s = sg_next(s)) { |
| 1524 | − phys_addr_t phys = sg_phys(s) & PAGE_MASK; | |
| 1524 | + phys_addr_t phys = page_to_phys(sg_page(s)); | |
| 1525 | 1525 | unsigned int len = PAGE_ALIGN(s->offset + s->length); |
| 1526 | 1526 | |
| 1527 | 1527 | if (!is_coherent && |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <linux/memblock.h> |
| 23 | 23 | #include <linux/dma-contiguous.h> |
| 24 | 24 | #include <linux/sizes.h> |
| 25 | +#include <linux/stop_machine.h> | |
| 25 | 26 | |
| 26 | 27 | #include <asm/cp15.h> |
| 27 | 28 | #include <asm/mach-types.h> |
| @@ -627,12 +628,10 @@ static struct section_perm ro_perms[] = { · 599 unmodified lines | ||
| 627 | 628 | * safe to be called with preemption disabled, as under stop_machine(). |
| 628 | 629 | */ |
| 629 | 630 | static inline void section_update(unsigned long addr, pmdval_t mask, |
| 630 | − pmdval_t prot) | |
| 631 | + pmdval_t prot, struct mm_struct *mm) | |
| 631 | 632 | { |
| 632 | − struct mm_struct *mm; | |
| 633 | 633 | pmd_t *pmd; |
| 634 | 634 | |
| 635 | − mm = current->active_mm; | |
| 636 | 635 | pmd = pmd_offset(pud_offset(pgd_offset(mm, addr), addr), addr); |
| 637 | 636 | |
| 638 | 637 | #ifdef CONFIG_ARM_LPAE |
| @@ -656,49 +655,82 @@ static inline bool arch_has_strict_perms(void) · 17 unmodified lines | ||
| 656 | 655 | return !!(get_cr() & CR_XP); |
| 657 | 656 | } |
| 658 | 657 | |
| 659 | −#define set_section_perms(perms, field) { \ | |
| 660 | − size_t i; \ | |
| 661 | − unsigned long addr; \ | |
| 662 | − \ | |
| 663 | − if (!arch_has_strict_perms()) \ | |
| 664 | − return; \ | |
| 665 | − \ | |
| 666 | − for (i = 0; i < ARRAY_SIZE(perms); i++) { \ | |
| 667 | − if (!IS_ALIGNED(perms[i].start, SECTION_SIZE) || \ | |
| 668 | − !IS_ALIGNED(perms[i].end, SECTION_SIZE)) { \ | |
| 669 | − pr_err("BUG: section %lx-%lx not aligned to %lx\n", \ | |
| 670 | − perms[i].start, perms[i].end, \ | |
| 671 | − SECTION_SIZE); \ | |
| 672 | − continue; \ | |
| 673 | − } \ | |
| 674 | − \ | |
| 675 | − for (addr = perms[i].start; \ | |
| 676 | − addr < perms[i].end; \ | |
| 677 | − addr += SECTION_SIZE) \ | |
| 678 | − section_update(addr, perms[i].mask, \ | |
| 679 | − perms[i].field); \ | |
| 680 | − } \ | |
| 658 | +void set_section_perms(struct section_perm *perms, int n, bool set, | |
| 659 | + struct mm_struct *mm) | |
| 660 | +{ | |
| 661 | + size_t i; | |
| 662 | + unsigned long addr; | |
| 663 | + | |
| 664 | + if (!arch_has_strict_perms()) | |
| 665 | + return; | |
| 666 | + | |
| 667 | + for (i = 0; i < n; i++) { | |
| 668 | + if (!IS_ALIGNED(perms[i].start, SECTION_SIZE) || | |
| 669 | + !IS_ALIGNED(perms[i].end, SECTION_SIZE)) { | |
| 670 | + pr_err("BUG: section %lx-%lx not aligned to %lx\n", | |
| 671 | + perms[i].start, perms[i].end, | |
| 672 | + SECTION_SIZE); | |
| 673 | + continue; | |
| 674 | + } | |
| 675 | + | |
| 676 | + for (addr = perms[i].start; | |
| 677 | + addr < perms[i].end; | |
| 678 | + addr += SECTION_SIZE) | |
| 679 | + section_update(addr, perms[i].mask, | |
| 680 | + set ? perms[i].prot : perms[i].clear, mm); | |
| 681 | + } | |
| 682 | + | |
| 681 | 683 | } |
| 682 | 684 | |
| 683 | −static inline void fix_kernmem_perms(void) | |
| 685 | +static void update_sections_early(struct section_perm perms[], int n) | |
| 684 | 686 | { |
| 685 | − set_section_perms(nx_perms, prot); | |
| 687 | + struct task_struct *t, *s; | |
| 688 | + | |
| 689 | + read_lock(&tasklist_lock); | |
| 690 | + for_each_process(t) { | |
| 691 | + if (t->flags & PF_KTHREAD) | |
| 692 | + continue; | |
| 693 | + for_each_thread(t, s) | |
| 694 | + set_section_perms(perms, n, true, s->mm); | |
| 695 | + } | |
| 696 | + read_unlock(&tasklist_lock); | |
| 697 | + set_section_perms(perms, n, true, current->active_mm); | |
| 698 | + set_section_perms(perms, n, true, &init_mm); | |
| 699 | +} | |
| 700 | + | |
| 701 | +int __fix_kernmem_perms(void *unused) | |
| 702 | +{ | |
| 703 | + update_sections_early(nx_perms, ARRAY_SIZE(nx_perms)); | |
| 704 | + return 0; | |
| 705 | +} | |
| 706 | + | |
| 707 | +void fix_kernmem_perms(void) | |
| 708 | +{ | |
| 709 | + stop_machine(__fix_kernmem_perms, NULL, NULL); | |
| 686 | 710 | } |
| 687 | 711 | |
| 688 | 712 | #ifdef CONFIG_DEBUG_RODATA |
| 713 | +int __mark_rodata_ro(void *unused) | |
| 714 | +{ | |
| 715 | + update_sections_early(ro_perms, ARRAY_SIZE(ro_perms)); | |
| 716 | + return 0; | |
| 717 | +} | |
| 718 | + | |
| 689 | 719 | void mark_rodata_ro(void) |
| 690 | 720 | { |
| 691 | − set_section_perms(ro_perms, prot); | |
| 721 | + stop_machine(__mark_rodata_ro, NULL, NULL); | |
| 692 | 722 | } |
| 693 | 723 | |
| 694 | 724 | void set_kernel_text_rw(void) |
| 695 | 725 | { |
| 696 | − set_section_perms(ro_perms, clear); | |
| 726 | + set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), false, | |
| 727 | + current->active_mm); | |
| 697 | 728 | } |
| 698 | 729 | |
| 699 | 730 | void set_kernel_text_ro(void) |
| 700 | 731 | { |
| 701 | − set_section_perms(ro_perms, prot); | |
| 732 | + set_section_perms(ro_perms, ARRAY_SIZE(ro_perms), true, | |
| 733 | + current->active_mm); | |
| 702 | 734 | } |
| 703 | 735 | #endif /* CONFIG_DEBUG_RODATA */ |
| 704 | 736 | |
| @@ -95,7 +95,7 @@ ENDPROC(cpu_v7_dcache_clean_area) · 94 unmodified lines | ||
| 95 | 95 | .equ cpu_v7_suspend_size, 4 * 9 |
| 96 | 96 | #ifdef CONFIG_ARM_CPU_SUSPEND |
| 97 | 97 | ENTRY(cpu_v7_do_suspend) |
| 98 | − stmfd sp!, {r4 - r10, lr} | |
| 98 | + stmfd sp!, {r4 - r11, lr} | |
| 99 | 99 | mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID |
| 100 | 100 | mrc p15, 0, r5, c13, c0, 3 @ User r/o thread ID |
| 101 | 101 | stmia r0!, {r4 - r5} |
| @@ -112,7 +112,7 @@ ENTRY(cpu_v7_do_suspend) · 10 unmodified lines | ||
| 112 | 112 | mrc p15, 0, r9, c1, c0, 1 @ Auxiliary control register |
| 113 | 113 | mrc p15, 0, r10, c1, c0, 2 @ Co-processor access control |
| 114 | 114 | stmia r0, {r5 - r11} |
| 115 | − ldmfd sp!, {r4 - r10, pc} | |
| 115 | + ldmfd sp!, {r4 - r11, pc} | |
| 116 | 116 | ENDPROC(cpu_v7_do_suspend) |
| 117 | 117 | |
| 118 | 118 | ENTRY(cpu_v7_do_resume) |
| @@ -187,19 +187,6 @@ static inline int mem_words_used(struct jit_ctx *ctx) · 186 unmodified lines | ||
| 187 | 187 | return fls(ctx->seen & SEEN_MEM); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | −static inline bool is_load_to_a(u16 inst) | |
| 191 | −{ | |
| 192 | − switch (inst) { | |
| 193 | − case BPF_LD | BPF_W | BPF_LEN: | |
| 194 | − case BPF_LD | BPF_W | BPF_ABS: | |
| 195 | − case BPF_LD | BPF_H | BPF_ABS: | |
| 196 | − case BPF_LD | BPF_B | BPF_ABS: | |
| 197 | − return true; | |
| 198 | − default: | |
| 199 | − return false; | |
| 200 | − } | |
| 201 | −} | |
| 202 | − | |
| 203 | 190 | static void jit_fill_hole(void *area, unsigned int size) |
| 204 | 191 | { |
| 205 | 192 | u32 *ptr; |
| @@ -211,7 +198,6 @@ static void jit_fill_hole(void *area, unsigned int size) · 5 unmodified lines | ||
| 211 | 198 | static void build_prologue(struct jit_ctx *ctx) |
| 212 | 199 | { |
| 213 | 200 | u16 reg_set = saved_regs(ctx); |
| 214 | − u16 first_inst = ctx->skf->insns[0].code; | |
| 215 | 201 | u16 off; |
| 216 | 202 | |
| 217 | 203 | #ifdef CONFIG_FRAME_POINTER |
| @@ -241,7 +227,7 @@ static void build_prologue(struct jit_ctx *ctx) · 23 unmodified lines | ||
| 241 | 227 | emit(ARM_MOV_I(r_X, 0), ctx); |
| 242 | 228 | |
| 243 | 229 | /* do not leak kernel data to userspace */ |
| 244 | − if ((first_inst != (BPF_RET | BPF_K)) && !(is_load_to_a(first_inst))) | |
| 230 | + if (bpf_needs_clear_a(&ctx->skf->insns[0])) | |
| 245 | 231 | emit(ARM_MOV_I(r_A, 0), ctx); |
| 246 | 232 | |
| 247 | 233 | /* stack space for the BPF_MEM words */ |
| @@ -770,7 +756,8 @@ load_ind: · 522 unmodified lines | ||
| 770 | 756 | case BPF_ALU | BPF_RSH | BPF_K: |
| 771 | 757 | if (unlikely(k > 31)) |
| 772 | 758 | return -1; |
| 773 | − emit(ARM_LSR_I(r_A, r_A, k), ctx); | |
| 759 | + if (k) | |
| 760 | + emit(ARM_LSR_I(r_A, r_A, k), ctx); | |
| 774 | 761 | break; |
| 775 | 762 | case BPF_ALU | BPF_RSH | BPF_X: |
| 776 | 763 | update_on_xread(ctx); |
| @@ -11,7 +11,7 @@ · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | |
| 14 | −#define NR_syscalls 322 /* length of syscall table */ | |
| 14 | +#define NR_syscalls 323 /* length of syscall table */ | |
| 15 | 15 | |
| 16 | 16 | /* |
| 17 | 17 | * The following defines stop scripts/checksyscalls.sh from complaining about |
| @@ -335,5 +335,6 @@ · 334 unmodified lines | ||
| 335 | 335 | #define __NR_userfaultfd 1343 |
| 336 | 336 | #define __NR_membarrier 1344 |
| 337 | 337 | #define __NR_kcmp 1345 |
| 338 | +#define __NR_mlock2 1346 | |
| 338 | 339 | |
| 339 | 340 | #endif /* _UAPI_ASM_IA64_UNISTD_H */ |
| @@ -1771,5 +1771,6 @@ sys_call_table: · 1770 unmodified lines | ||
| 1771 | 1771 | data8 sys_userfaultfd |
| 1772 | 1772 | data8 sys_membarrier |
| 1773 | 1773 | data8 sys_kcmp // 1345 |
| 1774 | + data8 sys_mlock2 | |
| 1774 | 1775 | |
| 1775 | 1776 | .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls |
| @@ -3,6 +3,7 @@ generic-y += clkdev.h · 2 unmodified lines | ||
| 3 | 3 | generic-y += cputime.h |
| 4 | 4 | generic-y += exec.h |
| 5 | 5 | generic-y += irq_work.h |
| 6 | +generic-y += kvm_para.h | |
| 6 | 7 | generic-y += mcs_spinlock.h |
| 7 | 8 | generic-y += mm-arch-hooks.h |
| 8 | 9 | generic-y += module.h |
| @@ -168,13 +168,21 @@ static inline void _writel(unsigned long l, unsigned long addr) · 167 unmodified lines | ||
| 168 | 168 | #define writew_relaxed writew |
| 169 | 169 | #define writel_relaxed writel |
| 170 | 170 | |
| 171 | −#define ioread8 read | |
| 171 | +#define ioread8 readb | |
| 172 | 172 | #define ioread16 readw |
| 173 | 173 | #define ioread32 readl |
| 174 | 174 | #define iowrite8 writeb |
| 175 | 175 | #define iowrite16 writew |
| 176 | 176 | #define iowrite32 writel |
| 177 | 177 | |
| 178 | +#define ioread8_rep(p, dst, count) insb((unsigned long)(p), (dst), (count)) | |
| 179 | +#define ioread16_rep(p, dst, count) insw((unsigned long)(p), (dst), (count)) | |
| 180 | +#define ioread32_rep(p, dst, count) insl((unsigned long)(p), (dst), (count)) | |
| 181 | + | |
| 182 | +#define iowrite8_rep(p, src, count) outsb((unsigned long)(p), (src), (count)) | |
| 183 | +#define iowrite16_rep(p, src, count) outsw((unsigned long)(p), (src), (count)) | |
| 184 | +#define iowrite32_rep(p, src, count) outsl((unsigned long)(p), (src), (count)) | |
| 185 | + | |
| 178 | 186 | #define ioread16be(addr) be16_to_cpu(readw(addr)) |
| 179 | 187 | #define ioread32be(addr) be32_to_cpu(readl(addr)) |
| 180 | 188 | #define iowrite16be(v, addr) writew(cpu_to_be16(v), (addr)) |
| @@ -61,7 +61,8 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, · 60 unmodified lines | ||
| 61 | 61 | /* FIXME this part of code is untested */ |
| 62 | 62 | for_each_sg(sgl, sg, nents, i) { |
| 63 | 63 | sg->dma_address = sg_phys(sg); |
| 64 | − __dma_sync(sg_phys(sg), sg->length, direction); | |
| 64 | + __dma_sync(page_to_phys(sg_page(sg)) + sg->offset, | |
| 65 | + sg->length, direction); | |
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | return nents; |
| @@ -599,7 +599,7 @@ extern void __put_user_unknown(void); · 598 unmodified lines | ||
| 599 | 599 | * On error, the variable @x is set to zero. |
| 600 | 600 | */ |
| 601 | 601 | #define __get_user_unaligned(x,ptr) \ |
| 602 | − __get_user__unalignednocheck((x),(ptr),sizeof(*(ptr))) | |
| 602 | + __get_user_unaligned_nocheck((x),(ptr),sizeof(*(ptr))) | |
| 603 | 603 | |
| 604 | 604 | /* |
| 605 | 605 | * Yuck. We need two variants, one for 64bit operation and one |
| @@ -620,8 +620,8 @@ extern void __get_user_unaligned_unknown(void); · 14 unmodified lines | ||
| 620 | 620 | do { \ |
| 621 | 621 | switch (size) { \ |
| 622 | 622 | case 1: __get_data_asm(val, "lb", ptr); break; \ |
| 623 | − case 2: __get_user_unaligned_asm(val, "ulh", ptr); break; \ | |
| 624 | − case 4: __get_user_unaligned_asm(val, "ulw", ptr); break; \ | |
| 623 | + case 2: __get_data_unaligned_asm(val, "ulh", ptr); break; \ | |
| 624 | + case 4: __get_data_unaligned_asm(val, "ulw", ptr); break; \ | |
| 625 | 625 | case 8: __GET_USER_UNALIGNED_DW(val, ptr); break; \ |
| 626 | 626 | default: __get_user_unaligned_unknown(); break; \ |
| 627 | 627 | } \ |
| @@ -1122,9 +1122,15 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n); · 494 unmodified lines | ||
| 1122 | 1122 | __cu_to = (to); \ |
| 1123 | 1123 | __cu_from = (from); \ |
| 1124 | 1124 | __cu_len = (n); \ |
| 1125 | − might_fault(); \ | |
| 1126 | − __cu_len = __invoke_copy_from_user(__cu_to, __cu_from, \ | |
| 1127 | − __cu_len); \ | |
| 1125 | + if (eva_kernel_access()) { \ | |
| 1126 | + __cu_len = __invoke_copy_from_kernel(__cu_to, \ | |
| 1127 | + __cu_from, \ | |
| 1128 | + __cu_len); \ | |
| 1129 | + } else { \ | |
| 1130 | + might_fault(); \ | |
| 1131 | + __cu_len = __invoke_copy_from_user(__cu_to, __cu_from, \ | |
| 1132 | + __cu_len); \ | |
| 1133 | + } \ | |
| 1128 | 1134 | __cu_len; \ |
| 1129 | 1135 | }) |
| 1130 | 1136 | |
| @@ -1229,16 +1235,28 @@ __clear_user(void __user *addr, __kernel_size_t size) · 98 unmodified lines | ||
| 1229 | 1235 | { |
| 1230 | 1236 | __kernel_size_t res; |
| 1231 | 1237 | |
| 1232 | − might_fault(); | |
| 1233 | − __asm__ __volatile__( | |
| 1234 | − "move\t$4, %1\n\t" | |
| 1235 | − "move\t$5, $0\n\t" | |
| 1236 | − "move\t$6, %2\n\t" | |
| 1237 | − __MODULE_JAL(__bzero) | |
| 1238 | − "move\t%0, $6" | |
| 1239 | − : "=r" (res) | |
| 1240 | − : "r" (addr), "r" (size) | |
| 1241 | − : "$4", "$5", "$6", __UA_t0, __UA_t1, "$31"); | |
| 1238 | + if (eva_kernel_access()) { | |
| 1239 | + __asm__ __volatile__( | |
| 1240 | + "move\t$4, %1\n\t" | |
| 1241 | + "move\t$5, $0\n\t" | |
| 1242 | + "move\t$6, %2\n\t" | |
| 1243 | + __MODULE_JAL(__bzero_kernel) | |
| 1244 | + "move\t%0, $6" | |
| 1245 | + : "=r" (res) | |
| 1246 | + : "r" (addr), "r" (size) | |
| 1247 | + : "$4", "$5", "$6", __UA_t0, __UA_t1, "$31"); | |
| 1248 | + } else { | |
| 1249 | + might_fault(); | |
| 1250 | + __asm__ __volatile__( | |
| 1251 | + "move\t$4, %1\n\t" | |
| 1252 | + "move\t$5, $0\n\t" | |
| 1253 | + "move\t$6, %2\n\t" | |
| 1254 | + __MODULE_JAL(__bzero) | |
| 1255 | + "move\t%0, $6" | |
| 1256 | + : "=r" (res) | |
| 1257 | + : "r" (addr), "r" (size) | |
| 1258 | + : "$4", "$5", "$6", __UA_t0, __UA_t1, "$31"); | |
| 1259 | + } | |
| 1242 | 1260 | |
| 1243 | 1261 | return res; |
| 1244 | 1262 | } |
| @@ -1384,7 +1402,7 @@ static inline long strlen_user(const char __user *s) · 139 unmodified lines | ||
| 1384 | 1402 | might_fault(); |
| 1385 | 1403 | __asm__ __volatile__( |
| 1386 | 1404 | "move\t$4, %1\n\t" |
| 1387 | − __MODULE_JAL(__strlen_kernel_asm) | |
| 1405 | + __MODULE_JAL(__strlen_user_asm) | |
| 1388 | 1406 | "move\t%0, $2" |
| 1389 | 1407 | : "=r" (res) |
| 1390 | 1408 | : "r" (s) |
| @@ -257,7 +257,6 @@ LEAF(mips_cps_core_init) · 256 unmodified lines | ||
| 257 | 257 | has_mt t0, 3f |
| 258 | 258 | |
| 259 | 259 | .set push |
| 260 | − .set mips64r2 | |
| 261 | 260 | .set mt |
| 262 | 261 | |
| 263 | 262 | /* Only allow 1 TC per VPE to execute... */ |
| @@ -376,7 +375,6 @@ LEAF(mips_cps_boot_vpes) · 112 unmodified lines | ||
| 376 | 375 | nop |
| 377 | 376 | |
| 378 | 377 | .set push |
| 379 | − .set mips64r2 | |
| 380 | 378 | .set mt |
| 381 | 379 | |
| 382 | 380 | 1: /* Enter VPE configuration state */ |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <asm/fpu.h> |
| 18 | 18 | #include <asm/msa.h> |
| 19 | 19 | |
| 20 | +extern void *__bzero_kernel(void *__s, size_t __count); | |
| 20 | 21 | extern void *__bzero(void *__s, size_t __count); |
| 21 | 22 | extern long __strncpy_from_kernel_nocheck_asm(char *__to, |
| 22 | 23 | const char *__from, long __len); |
| @@ -64,6 +65,7 @@ EXPORT_SYMBOL(__copy_from_user_eva); · 41 unmodified lines | ||
| 64 | 65 | EXPORT_SYMBOL(__copy_in_user_eva); |
| 65 | 66 | EXPORT_SYMBOL(__copy_to_user_eva); |
| 66 | 67 | EXPORT_SYMBOL(__copy_user_inatomic_eva); |
| 68 | +EXPORT_SYMBOL(__bzero_kernel); | |
| 67 | 69 | #endif |
| 68 | 70 | EXPORT_SYMBOL(__bzero); |
| 69 | 71 | EXPORT_SYMBOL(__strncpy_from_kernel_nocheck_asm); |
| @@ -283,6 +283,8 @@ LEAF(memset) · 282 unmodified lines | ||
| 283 | 283 | 1: |
| 284 | 284 | #ifndef CONFIG_EVA |
| 285 | 285 | FEXPORT(__bzero) |
| 286 | +#else | |
| 287 | +FEXPORT(__bzero_kernel) | |
| 286 | 288 | #endif |
| 287 | 289 | __BUILD_BZERO LEGACY_MODE |
| 288 | 290 | |
| @@ -521,19 +521,6 @@ static inline u16 align_sp(unsigned int num) · 520 unmodified lines | ||
| 521 | 521 | return num; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | −static bool is_load_to_a(u16 inst) | |
| 525 | −{ | |
| 526 | − switch (inst) { | |
| 527 | − case BPF_LD | BPF_W | BPF_LEN: | |
| 528 | − case BPF_LD | BPF_W | BPF_ABS: | |
| 529 | − case BPF_LD | BPF_H | BPF_ABS: | |
| 530 | − case BPF_LD | BPF_B | BPF_ABS: | |
| 531 | − return true; | |
| 532 | − default: | |
| 533 | − return false; | |
| 534 | − } | |
| 535 | −} | |
| 536 | − | |
| 537 | 524 | static void save_bpf_jit_regs(struct jit_ctx *ctx, unsigned offset) |
| 538 | 525 | { |
| 539 | 526 | int i = 0, real_off = 0; |
| @@ -614,7 +601,6 @@ static unsigned int get_stack_depth(struct jit_ctx *ctx) · 74 unmodified lines | ||
| 614 | 601 | |
| 615 | 602 | static void build_prologue(struct jit_ctx *ctx) |
| 616 | 603 | { |
| 617 | − u16 first_inst = ctx->skf->insns[0].code; | |
| 618 | 604 | int sp_off; |
| 619 | 605 | |
| 620 | 606 | /* Calculate the total offset for the stack pointer */ |
| @@ -641,7 +627,7 @@ static void build_prologue(struct jit_ctx *ctx) · 20 unmodified lines | ||
| 641 | 627 | emit_jit_reg_move(r_X, r_zero, ctx); |
| 642 | 628 | |
| 643 | 629 | /* Do not leak kernel data to userspace */ |
| 644 | − if ((first_inst != (BPF_RET | BPF_K)) && !(is_load_to_a(first_inst))) | |
| 630 | + if (bpf_needs_clear_a(&ctx->skf->insns[0])) | |
| 645 | 631 | emit_jit_reg_move(r_A, r_zero, ctx); |
| 646 | 632 | } |
| 647 | 633 | |
| @@ -221,7 +221,6 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) · 220 unmodified lines | ||
| 221 | 221 | static int rt288x_pci_probe(struct platform_device *pdev) |
| 222 | 222 | { |
| 223 | 223 | void __iomem *io_map_base; |
| 224 | − int i; | |
| 225 | 224 | |
| 226 | 225 | rt2880_pci_base = ioremap_nocache(RT2880_PCI_BASE, PAGE_SIZE); |
| 227 | 226 | |
| @@ -39,7 +39,6 @@ extern void msp_serial_setup(void); · 38 unmodified lines | ||
| 39 | 39 | void msp7120_reset(void) |
| 40 | 40 | { |
| 41 | 41 | void *start, *end, *iptr; |
| 42 | − register int i; | |
| 43 | 42 | |
| 44 | 43 | /* Diasble all interrupts */ |
| 45 | 44 | local_irq_disable(); |
| @@ -26,7 +26,7 @@ static inline void kb_wait(void) · 25 unmodified lines | ||
| 26 | 26 | /* XXX This ends up at the ARC firmware prompt ... */ |
| 27 | 27 | void sni_machine_restart(char *command) |
| 28 | 28 | { |
| 29 | − int i, j; | |
| 29 | + int i; | |
| 30 | 30 | |
| 31 | 31 | /* This does a normal via the keyboard controller like a PC. |
| 32 | 32 | We can do that easier ... */ |
| @@ -26,8 +26,8 @@ aflags-vdso := $(ccflags-vdso) \ · 25 unmodified lines | ||
| 26 | 26 | # the comments on that file. |
| 27 | 27 | # |
| 28 | 28 | ifndef CONFIG_CPU_MIPSR6 |
| 29 | − ifeq ($(call ld-ifversion, -gt, 22400000, y),) | |
| 30 | − $(warning MIPS VDSO requires binutils > 2.24) | |
| 29 | + ifeq ($(call ld-ifversion, -lt, 22500000, y),y) | |
| 30 | + $(warning MIPS VDSO requires binutils >= 2.25) | |
| 31 | 31 | obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y)) |
| 32 | 32 | ccflags-vdso += -DDISABLE_MIPS_VDSO |
| 33 | 33 | endif |
| @@ -435,6 +435,55 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs, int in_syscall) · 434 unmodified lines | ||
| 435 | 435 | regs->gr[28]); |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | +/* | |
| 439 | + * Check how the syscall number gets loaded into %r20 within | |
| 440 | + * the delay branch in userspace and adjust as needed. | |
| 441 | + */ | |
| 442 | + | |
| 443 | +static void check_syscallno_in_delay_branch(struct pt_regs *regs) | |
| 444 | +{ | |
| 445 | + u32 opcode, source_reg; | |
| 446 | + u32 __user *uaddr; | |
| 447 | + int err; | |
| 448 | + | |
| 449 | + /* Usually we don't have to restore %r20 (the system call number) | |
| 450 | + * because it gets loaded in the delay slot of the branch external | |
| 451 | + * instruction via the ldi instruction. | |
| 452 | + * In some cases a register-to-register copy instruction might have | |
| 453 | + * been used instead, in which case we need to copy the syscall | |
| 454 | + * number into the source register before returning to userspace. | |
| 455 | + */ | |
| 456 | + | |
| 457 | + /* A syscall is just a branch, so all we have to do is fiddle the | |
| 458 | + * return pointer so that the ble instruction gets executed again. | |
| 459 | + */ | |
| 460 | + regs->gr[31] -= 8; /* delayed branching */ | |
| 461 | + | |
| 462 | + /* Get assembler opcode of code in delay branch */ | |
| 463 | + uaddr = (unsigned int *) ((regs->gr[31] & ~3) + 4); | |
| 464 | + err = get_user(opcode, uaddr); | |
| 465 | + if (err) | |
| 466 | + return; | |
| 467 | + | |
| 468 | + /* Check if delay branch uses "ldi int,%r20" */ | |
| 469 | + if ((opcode & 0xffff0000) == 0x34140000) | |
| 470 | + return; /* everything ok, just return */ | |
| 471 | + | |
| 472 | + /* Check if delay branch uses "nop" */ | |
| 473 | + if (opcode == INSN_NOP) | |
| 474 | + return; | |
| 475 | + | |
| 476 | + /* Check if delay branch uses "copy %rX,%r20" */ | |
| 477 | + if ((opcode & 0xffe0ffff) == 0x08000254) { | |
| 478 | + source_reg = (opcode >> 16) & 31; | |
| 479 | + regs->gr[source_reg] = regs->gr[20]; | |
| 480 | + return; | |
| 481 | + } | |
| 482 | + | |
| 483 | + pr_warn("syscall restart: %s (pid %d): unexpected opcode 0x%08x\n", | |
| 484 | + current->comm, task_pid_nr(current), opcode); | |
| 485 | +} | |
| 486 | + | |
| 438 | 487 | static inline void |
| 439 | 488 | syscall_restart(struct pt_regs *regs, struct k_sigaction *ka) |
| 440 | 489 | { |
| @@ -457,10 +506,7 @@ syscall_restart(struct pt_regs *regs, struct k_sigaction *ka) · 16 unmodified lines | ||
| 457 | 506 | } |
| 458 | 507 | /* fallthrough */ |
| 459 | 508 | case -ERESTARTNOINTR: |
| 460 | − /* A syscall is just a branch, so all | |
| 461 | − * we have to do is fiddle the return pointer. | |
| 462 | − */ | |
| 463 | − regs->gr[31] -= 8; /* delayed branching */ | |
| 509 | + check_syscallno_in_delay_branch(regs); | |
| 464 | 510 | break; |
| 465 | 511 | } |
| 466 | 512 | } |
| @@ -510,15 +556,9 @@ insert_restart_trampoline(struct pt_regs *regs) · 43 unmodified lines | ||
| 510 | 556 | } |
| 511 | 557 | case -ERESTARTNOHAND: |
| 512 | 558 | case -ERESTARTSYS: |
| 513 | − case -ERESTARTNOINTR: { | |
| 514 | − /* Hooray for delayed branching. We don't | |
| 515 | − * have to restore %r20 (the system call | |
| 516 | − * number) because it gets loaded in the delay | |
| 517 | − * slot of the branch external instruction. | |
| 518 | − */ | |
| 519 | − regs->gr[31] -= 8; | |
| 559 | + case -ERESTARTNOINTR: | |
| 560 | + check_syscallno_in_delay_branch(regs); | |
| 520 | 561 | return; |
| 521 | − } | |
| 522 | 562 | default: |
| 523 | 563 | break; |
| 524 | 564 | } |
| @@ -370,16 +370,16 @@ COMPAT_SYS(execveat) · 369 unmodified lines | ||
| 370 | 370 | PPC64ONLY(switch_endian) |
| 371 | 371 | SYSCALL_SPU(userfaultfd) |
| 372 | 372 | SYSCALL_SPU(membarrier) |
| 373 | −SYSCALL(semop) | |
| 374 | −SYSCALL(semget) | |
| 375 | −COMPAT_SYS(semctl) | |
| 376 | −COMPAT_SYS(semtimedop) | |
| 377 | −COMPAT_SYS(msgsnd) | |
| 378 | −COMPAT_SYS(msgrcv) | |
| 379 | −SYSCALL(msgget) | |
| 380 | −COMPAT_SYS(msgctl) | |
| 381 | −COMPAT_SYS(shmat) | |
| 382 | −SYSCALL(shmdt) | |
| 383 | −SYSCALL(shmget) | |
| 384 | −COMPAT_SYS(shmctl) | |
| 373 | +SYSCALL(ni_syscall) | |
| 374 | +SYSCALL(ni_syscall) | |
| 375 | +SYSCALL(ni_syscall) | |
| 376 | +SYSCALL(ni_syscall) | |
| 377 | +SYSCALL(ni_syscall) | |
| 378 | +SYSCALL(ni_syscall) | |
| 379 | +SYSCALL(ni_syscall) | |
| 380 | +SYSCALL(ni_syscall) | |
| 381 | +SYSCALL(ni_syscall) | |
| 382 | +SYSCALL(ni_syscall) | |
| 383 | +SYSCALL(ni_syscall) | |
| 384 | +SYSCALL(ni_syscall) | |
| 385 | 385 | SYSCALL(mlock2) |
| @@ -388,18 +388,6 @@ · 387 unmodified lines | ||
| 388 | 388 | #define __NR_switch_endian 363 |
| 389 | 389 | #define __NR_userfaultfd 364 |
| 390 | 390 | #define __NR_membarrier 365 |
| 391 | −#define __NR_semop 366 | |
| 392 | −#define __NR_semget 367 | |
| 393 | −#define __NR_semctl 368 | |
| 394 | −#define __NR_semtimedop 369 | |
| 395 | −#define __NR_msgsnd 370 | |
| 396 | −#define __NR_msgrcv 371 | |
| 397 | −#define __NR_msgget 372 | |
| 398 | −#define __NR_msgctl 373 | |
| 399 | −#define __NR_shmat 374 | |
| 400 | −#define __NR_shmdt 375 | |
| 401 | −#define __NR_shmget 376 | |
| 402 | −#define __NR_shmctl 377 | |
| 403 | 391 | #define __NR_mlock2 378 |
| 404 | 392 | |
| 405 | 393 | #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ |
| @@ -224,6 +224,12 @@ static void kvmppc_core_vcpu_put_hv(struct kvm_vcpu *vcpu) · 223 unmodified lines | ||
| 224 | 224 | |
| 225 | 225 | static void kvmppc_set_msr_hv(struct kvm_vcpu *vcpu, u64 msr) |
| 226 | 226 | { |
| 227 | + /* | |
| 228 | + * Check for illegal transactional state bit combination | |
| 229 | + * and if we find it, force the TS field to a safe state. | |
| 230 | + */ | |
| 231 | + if ((msr & MSR_TS_MASK) == MSR_TS_MASK) | |
| 232 | + msr &= ~MSR_TS_MASK; | |
| 227 | 233 | vcpu->arch.shregs.msr = msr; |
| 228 | 234 | kvmppc_end_cede(vcpu); |
| 229 | 235 | } |
| @@ -78,18 +78,9 @@ static void bpf_jit_build_prologue(struct bpf_prog *fp, u32 *image, · 77 unmodified lines | ||
| 78 | 78 | PPC_LI(r_X, 0); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | − switch (filter[0].code) { | |
| 82 | − case BPF_RET | BPF_K: | |
| 83 | − case BPF_LD | BPF_W | BPF_LEN: | |
| 84 | − case BPF_LD | BPF_W | BPF_ABS: | |
| 85 | − case BPF_LD | BPF_H | BPF_ABS: | |
| 86 | − case BPF_LD | BPF_B | BPF_ABS: | |
| 87 | − /* first instruction sets A register (or is RET 'constant') */ | |
| 88 | − break; | |
| 89 | − default: | |
| 90 | − /* make sure we dont leak kernel information to user */ | |
| 81 | + /* make sure we dont leak kernel information to user */ | |
| 82 | + if (bpf_needs_clear_a(&filter[0])) | |
| 91 | 83 | PPC_LI(r_A, 0); |
| 92 | − } | |
| 93 | 84 | } |
| 94 | 85 | |
| 95 | 86 | static void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx) |
| @@ -83,7 +83,19 @@ static void opal_event_unmask(struct irq_data *d) · 82 unmodified lines | ||
| 83 | 83 | set_bit(d->hwirq, &opal_event_irqchip.mask); |
| 84 | 84 | |
| 85 | 85 | opal_poll_events(&events); |
| 86 | − opal_handle_events(be64_to_cpu(events)); | |
| 86 | + last_outstanding_events = be64_to_cpu(events); | |
| 87 | + | |
| 88 | + /* | |
| 89 | + * We can't just handle the events now with opal_handle_events(). | |
| 90 | + * If we did we would deadlock when opal_event_unmask() is called from | |
| 91 | + * handle_level_irq() with the irq descriptor lock held, because | |
| 92 | + * calling opal_handle_events() would call generic_handle_irq() and | |
| 93 | + * then handle_level_irq() which would try to take the descriptor lock | |
| 94 | + * again. Instead queue the events for later. | |
| 95 | + */ | |
| 96 | + if (last_outstanding_events & opal_event_irqchip.mask) | |
| 97 | + /* Need to retrigger the interrupt */ | |
| 98 | + irq_work_queue(&opal_event_irq_work); | |
| 87 | 99 | } |
| 88 | 100 | |
| 89 | 101 | static int opal_event_set_type(struct irq_data *d, unsigned int flow_type) |
| @@ -278,7 +278,7 @@ static void opal_handle_message(void) · 277 unmodified lines | ||
| 278 | 278 | |
| 279 | 279 | /* Sanity check */ |
| 280 | 280 | if (type >= OPAL_MSG_TYPE_MAX) { |
| 281 | − pr_warning("%s: Unknown message type: %u\n", __func__, type); | |
| 281 | + pr_warn_once("%s: Unknown message type: %u\n", __func__, type); | |
| 282 | 282 | return; |
| 283 | 283 | } |
| 284 | 284 | opal_message_do_notify(type, (void *)&msg); |
| @@ -1920,16 +1920,23 @@ static int print_insn(char *buffer, unsigned char *code, unsigned long addr) · 1919 unmodified lines | ||
| 1920 | 1920 | } |
| 1921 | 1921 | if (separator) |
| 1922 | 1922 | ptr += sprintf(ptr, "%c", separator); |
| 1923 | + /* | |
| 1924 | + * Use four '%' characters below because of the | |
| 1925 | + * following two conversions: | |
| 1926 | + * | |
| 1927 | + * 1) sprintf: %%%%r -> %%r | |
| 1928 | + * 2) printk : %%r -> %r | |
| 1929 | + */ | |
| 1923 | 1930 | if (operand->flags & OPERAND_GPR) |
| 1924 | − ptr += sprintf(ptr, "%%r%i", value); | |
| 1931 | + ptr += sprintf(ptr, "%%%%r%i", value); | |
| 1925 | 1932 | else if (operand->flags & OPERAND_FPR) |
| 1926 | − ptr += sprintf(ptr, "%%f%i", value); | |
| 1933 | + ptr += sprintf(ptr, "%%%%f%i", value); | |
| 1927 | 1934 | else if (operand->flags & OPERAND_AR) |
| 1928 | − ptr += sprintf(ptr, "%%a%i", value); | |
| 1935 | + ptr += sprintf(ptr, "%%%%a%i", value); | |
| 1929 | 1936 | else if (operand->flags & OPERAND_CR) |
| 1930 | − ptr += sprintf(ptr, "%%c%i", value); | |
| 1937 | + ptr += sprintf(ptr, "%%%%c%i", value); | |
| 1931 | 1938 | else if (operand->flags & OPERAND_VR) |
| 1932 | − ptr += sprintf(ptr, "%%v%i", value); | |
| 1939 | + ptr += sprintf(ptr, "%%%%v%i", value); | |
| 1933 | 1940 | else if (operand->flags & OPERAND_PCREL) |
| 1934 | 1941 | ptr += sprintf(ptr, "%lx", (signed int) value |
| 1935 | 1942 | + addr); |
| @@ -95,6 +95,7 @@ · 94 unmodified lines | ||
| 95 | 95 | * really available. So we simply advertise only "crypto" support. |
| 96 | 96 | */ |
| 97 | 97 | #define HWCAP_SPARC_CRYPTO 0x04000000 /* CRYPTO insns available */ |
| 98 | +#define HWCAP_SPARC_ADI 0x08000000 /* ADI available */ | |
| 98 | 99 | |
| 99 | 100 | #define CORE_DUMP_USE_REGSET |
| 100 | 101 | |
| @@ -417,8 +417,13 @@ · 416 unmodified lines | ||
| 417 | 417 | #define __NR_bpf 349 |
| 418 | 418 | #define __NR_execveat 350 |
| 419 | 419 | #define __NR_membarrier 351 |
| 420 | +#define __NR_userfaultfd 352 | |
| 421 | +#define __NR_bind 353 | |
| 422 | +#define __NR_listen 354 | |
| 423 | +#define __NR_setsockopt 355 | |
| 424 | +#define __NR_mlock2 356 | |
| 420 | 425 | |
| 421 | −#define NR_syscalls 352 | |
| 426 | +#define NR_syscalls 357 | |
| 422 | 427 | |
| 423 | 428 | /* Bitmask values returned from kern_features system call. */ |
| 424 | 429 | #define KERN_FEATURE_MIXED_MODE_STACK 0x00000001 |
| @@ -946,6 +946,12 @@ ENTRY(__retl_one) · 945 unmodified lines | ||
| 946 | 946 | mov 1, %o0 |
| 947 | 947 | ENDPROC(__retl_one) |
| 948 | 948 | |
| 949 | +ENTRY(__retl_one_fp) | |
| 950 | + VISExitHalf | |
| 951 | + retl | |
| 952 | + mov 1, %o0 | |
| 953 | +ENDPROC(__retl_one_fp) | |
| 954 | + | |
| 949 | 955 | ENTRY(__ret_one_asi) |
| 950 | 956 | wr %g0, ASI_AIUS, %asi |
| 951 | 957 | ret |
| @@ -958,6 +964,13 @@ ENTRY(__retl_one_asi) · 6 unmodified lines | ||
| 958 | 964 | mov 1, %o0 |
| 959 | 965 | ENDPROC(__retl_one_asi) |
| 960 | 966 | |
| 967 | +ENTRY(__retl_one_asi_fp) | |
| 968 | + wr %g0, ASI_AIUS, %asi | |
| 969 | + VISExitHalf | |
| 970 | + retl | |
| 971 | + mov 1, %o0 | |
| 972 | +ENDPROC(__retl_one_asi_fp) | |
| 973 | + | |
| 961 | 974 | ENTRY(__retl_o1) |
| 962 | 975 | retl |
| 963 | 976 | mov %o1, %o0 |
| @@ -1828,11 +1828,18 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry, · 1827 unmodified lines | ||
| 1828 | 1828 | void |
| 1829 | 1829 | perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs) |
| 1830 | 1830 | { |
| 1831 | + u64 saved_fault_address = current_thread_info()->fault_address; | |
| 1832 | + u8 saved_fault_code = get_thread_fault_code(); | |
| 1833 | + mm_segment_t old_fs; | |
| 1834 | + | |
| 1831 | 1835 | perf_callchain_store(entry, regs->tpc); |
| 1832 | 1836 | |
| 1833 | 1837 | if (!current->mm) |
| 1834 | 1838 | return; |
| 1835 | 1839 | |
| 1840 | + old_fs = get_fs(); | |
| 1841 | + set_fs(USER_DS); | |
| 1842 | + | |
| 1836 | 1843 | flushw_user(); |
| 1837 | 1844 | |
| 1838 | 1845 | pagefault_disable(); |
| @@ -1843,4 +1850,8 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs) · 4 unmodified lines | ||
| 1843 | 1850 | perf_callchain_user_64(entry, regs); |
| 1844 | 1851 | |
| 1845 | 1852 | pagefault_enable(); |
| 1853 | + | |
| 1854 | + set_fs(old_fs); | |
| 1855 | + set_thread_fault_code(saved_fault_code); | |
| 1856 | + current_thread_info()->fault_address = saved_fault_address; | |
| 1846 | 1857 | } |
| @@ -73,7 +73,13 @@ rtrap_nmi: ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 · 72 unmodified lines | ||
| 73 | 73 | andn %l1, %l4, %l1 |
| 74 | 74 | srl %l4, 20, %l4 |
| 75 | 75 | ba,pt %xcc, rtrap_no_irq_enable |
| 76 | − wrpr %l4, %pil | |
| 76 | + nop | |
| 77 | + /* Do not actually set the %pil here. We will do that | |
| 78 | + * below after we clear PSTATE_IE in the %pstate register. | |
| 79 | + * If we re-enable interrupts here, we can recurse down | |
| 80 | + * the hardirq stack potentially endlessly, causing a | |
| 81 | + * stack overflow. | |
| 82 | + */ | |
| 77 | 83 | |
| 78 | 84 | .align 64 |
| 79 | 85 | .globl rtrap_irq, rtrap, irqsz_patchme, rtrap_xcall |
| @@ -380,7 +380,8 @@ static const char *hwcaps[] = { · 379 unmodified lines | ||
| 380 | 380 | */ |
| 381 | 381 | "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2", |
| 382 | 382 | "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau", |
| 383 | − "ima", "cspare", "pause", "cbcond", | |
| 383 | + "ima", "cspare", "pause", "cbcond", NULL /*reserved for crypto */, | |
| 384 | + "adp", | |
| 384 | 385 | }; |
| 385 | 386 | |
| 386 | 387 | static const char *crypto_hwcaps[] = { |
| @@ -396,7 +397,7 @@ void cpucap_info(struct seq_file *m) · 9 unmodified lines | ||
| 396 | 397 | seq_puts(m, "cpucaps\t\t: "); |
| 397 | 398 | for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { |
| 398 | 399 | unsigned long bit = 1UL << i; |
| 399 | − if (caps & bit) { | |
| 400 | + if (hwcaps[i] && (caps & bit)) { | |
| 400 | 401 | seq_printf(m, "%s%s", |
| 401 | 402 | printed ? "," : "", hwcaps[i]); |
| 402 | 403 | printed++; |
| @@ -450,7 +451,7 @@ static void __init report_hwcaps(unsigned long caps) · 47 unmodified lines | ||
| 450 | 451 | |
| 451 | 452 | for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { |
| 452 | 453 | unsigned long bit = 1UL << i; |
| 453 | − if (caps & bit) | |
| 454 | + if (hwcaps[i] && (caps & bit)) | |
| 454 | 455 | report_one_hwcap(&printed, hwcaps[i]); |
| 455 | 456 | } |
| 456 | 457 | if (caps & HWCAP_SPARC_CRYPTO) |
| @@ -485,7 +486,7 @@ static unsigned long __init mdesc_cpu_hwcap_list(void) · 28 unmodified lines | ||
| 485 | 486 | for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { |
| 486 | 487 | unsigned long bit = 1UL << i; |
| 487 | 488 | |
| 488 | − if (!strcmp(prop, hwcaps[i])) { | |
| 489 | + if (hwcaps[i] && !strcmp(prop, hwcaps[i])) { | |
| 489 | 490 | caps |= bit; |
| 490 | 491 | break; |
| 491 | 492 | } |
| @@ -35,18 +35,18 @@ sys_call_table: · 34 unmodified lines | ||
| 35 | 35 | /*80*/ .long sys_setgroups16, sys_getpgrp, sys_setgroups, sys_setitimer, sys_ftruncate64 |
| 36 | 36 | /*85*/ .long sys_swapon, sys_getitimer, sys_setuid, sys_sethostname, sys_setgid |
| 37 | 37 | /*90*/ .long sys_dup2, sys_setfsuid, sys_fcntl, sys_select, sys_setfsgid |
| 38 | −/*95*/ .long sys_fsync, sys_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall | |
| 38 | +/*95*/ .long sys_fsync, sys_setpriority, sys_socket, sys_connect, sys_accept | |
| 39 | 39 | /*100*/ .long sys_getpriority, sys_rt_sigreturn, sys_rt_sigaction, sys_rt_sigprocmask, sys_rt_sigpending |
| 40 | 40 | /*105*/ .long sys_rt_sigtimedwait, sys_rt_sigqueueinfo, sys_rt_sigsuspend, sys_setresuid, sys_getresuid |
| 41 | −/*110*/ .long sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall | |
| 42 | −/*115*/ .long sys_getgroups, sys_gettimeofday, sys_getrusage, sys_nis_syscall, sys_getcwd | |
| 41 | +/*110*/ .long sys_setresgid, sys_getresgid, sys_setregid, sys_recvmsg, sys_sendmsg | |
| 42 | +/*115*/ .long sys_getgroups, sys_gettimeofday, sys_getrusage, sys_getsockopt, sys_getcwd | |
| 43 | 43 | /*120*/ .long sys_readv, sys_writev, sys_settimeofday, sys_fchown16, sys_fchmod |
| 44 | −/*125*/ .long sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate | |
| 45 | −/*130*/ .long sys_ftruncate, sys_flock, sys_lstat64, sys_nis_syscall, sys_nis_syscall | |
| 46 | −/*135*/ .long sys_nis_syscall, sys_mkdir, sys_rmdir, sys_utimes, sys_stat64 | |
| 47 | −/*140*/ .long sys_sendfile64, sys_nis_syscall, sys_futex, sys_gettid, sys_getrlimit | |
| 44 | +/*125*/ .long sys_recvfrom, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate | |
| 45 | +/*130*/ .long sys_ftruncate, sys_flock, sys_lstat64, sys_sendto, sys_shutdown | |
| 46 | +/*135*/ .long sys_socketpair, sys_mkdir, sys_rmdir, sys_utimes, sys_stat64 | |
| 47 | +/*140*/ .long sys_sendfile64, sys_getpeername, sys_futex, sys_gettid, sys_getrlimit | |
| 48 | 48 | /*145*/ .long sys_setrlimit, sys_pivot_root, sys_prctl, sys_pciconfig_read, sys_pciconfig_write |
| 49 | −/*150*/ .long sys_nis_syscall, sys_inotify_init, sys_inotify_add_watch, sys_poll, sys_getdents64 | |
| 49 | +/*150*/ .long sys_getsockname, sys_inotify_init, sys_inotify_add_watch, sys_poll, sys_getdents64 | |
| 50 | 50 | /*155*/ .long sys_fcntl64, sys_inotify_rm_watch, sys_statfs, sys_fstatfs, sys_oldumount |
| 51 | 51 | /*160*/ .long sys_sched_setaffinity, sys_sched_getaffinity, sys_getdomainname, sys_setdomainname, sys_nis_syscall |
| 52 | 52 | /*165*/ .long sys_quotactl, sys_set_tid_address, sys_mount, sys_ustat, sys_setxattr |
| @@ -87,4 +87,5 @@ sys_call_table: · 34 unmodified lines | ||
| 87 | 87 | /*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev |
| 88 | 88 | /*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr |
| 89 | 89 | /*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf |
| 90 | −/*350*/ .long sys_execveat, sys_membarrier | |
| 90 | +/*350*/ .long sys_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen | |
| 91 | +/*355*/ .long sys_setsockopt, sys_mlock2 | |
| @@ -37,15 +37,15 @@ sys_call_table32: · 36 unmodified lines | ||
| 37 | 37 | /*80*/ .word sys_setgroups16, sys_getpgrp, sys_setgroups, compat_sys_setitimer, sys32_ftruncate64 |
| 38 | 38 | .word sys_swapon, compat_sys_getitimer, sys_setuid, sys_sethostname, sys_setgid |
| 39 | 39 | /*90*/ .word sys_dup2, sys_setfsuid, compat_sys_fcntl, sys32_select, sys_setfsgid |
| 40 | − .word sys_fsync, sys_setpriority, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall | |
| 40 | + .word sys_fsync, sys_setpriority, sys_socket, sys_connect, sys_accept | |
| 41 | 41 | /*100*/ .word sys_getpriority, sys32_rt_sigreturn, compat_sys_rt_sigaction, compat_sys_rt_sigprocmask, compat_sys_rt_sigpending |
| 42 | 42 | .word compat_sys_rt_sigtimedwait, compat_sys_rt_sigqueueinfo, compat_sys_rt_sigsuspend, sys_setresuid, sys_getresuid |
| 43 | −/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall | |
| 44 | − .word sys_getgroups, compat_sys_gettimeofday, compat_sys_getrusage, sys_nis_syscall, sys_getcwd | |
| 43 | +/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, compat_sys_recvmsg, compat_sys_sendmsg | |
| 44 | + .word sys_getgroups, compat_sys_gettimeofday, compat_sys_getrusage, compat_sys_getsockopt, sys_getcwd | |
| 45 | 45 | /*120*/ .word compat_sys_readv, compat_sys_writev, compat_sys_settimeofday, sys_fchown16, sys_fchmod |
| 46 | − .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, compat_sys_truncate | |
| 47 | −/*130*/ .word compat_sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall | |
| 48 | − .word sys_nis_syscall, sys_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64 | |
| 46 | + .word sys_recvfrom, sys_setreuid16, sys_setregid16, sys_rename, compat_sys_truncate | |
| 47 | +/*130*/ .word compat_sys_ftruncate, sys_flock, compat_sys_lstat64, sys_sendto, sys_shutdown | |
| 48 | + .word sys_socketpair, sys_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64 | |
| 49 | 49 | /*140*/ .word sys_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit |
| 50 | 50 | .word compat_sys_setrlimit, sys_pivot_root, sys_prctl, sys_pciconfig_read, sys_pciconfig_write |
| 51 | 51 | /*150*/ .word sys_nis_syscall, sys_inotify_init, sys_inotify_add_watch, sys_poll, sys_getdents64 |
| @@ -88,7 +88,8 @@ sys_call_table32: · 36 unmodified lines | ||
| 88 | 88 | .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev |
| 89 | 89 | /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr |
| 90 | 90 | .word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf |
| 91 | −/*350*/ .word sys32_execveat, sys_membarrier | |
| 91 | +/*350*/ .word sys32_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen | |
| 92 | + .word compat_sys_setsockopt, sys_mlock2 | |
| 92 | 93 | |
| 93 | 94 | #endif /* CONFIG_COMPAT */ |
| 94 | 95 | |
| @@ -168,4 +169,5 @@ sys_call_table: · 73 unmodified lines | ||
| 168 | 169 | .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev |
| 169 | 170 | /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr |
| 170 | 171 | .word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf |
| 171 | −/*350*/ .word sys64_execveat, sys_membarrier | |
| 172 | +/*350*/ .word sys64_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen | |
| 173 | + .word sys_setsockopt, sys_mlock2 | |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_LD_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_asi_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #ifndef ASI_AIUS |
| 15 | 23 | #define ASI_AIUS 0x11 |
| 16 | 24 | #endif |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_ST_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_asi_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #ifndef ASI_AIUS |
| 15 | 23 | #define ASI_AIUS 0x11 |
| 16 | 24 | #endif |
| @@ -34,10 +34,16 @@ · 33 unmodified lines | ||
| 34 | 34 | #ifndef EX_LD |
| 35 | 35 | #define EX_LD(x) x |
| 36 | 36 | #endif |
| 37 | +#ifndef EX_LD_FP | |
| 38 | +#define EX_LD_FP(x) x | |
| 39 | +#endif | |
| 37 | 40 | |
| 38 | 41 | #ifndef EX_ST |
| 39 | 42 | #define EX_ST(x) x |
| 40 | 43 | #endif |
| 44 | +#ifndef EX_ST_FP | |
| 45 | +#define EX_ST_FP(x) x | |
| 46 | +#endif | |
| 41 | 47 | |
| 42 | 48 | #ifndef EX_RETVAL |
| 43 | 49 | #define EX_RETVAL(x) x |
| @@ -134,40 +140,40 @@ · 90 unmodified lines | ||
| 134 | 140 | fsrc2 %x6, %f12; \ |
| 135 | 141 | fsrc2 %x7, %f14; |
| 136 | 142 | #define FREG_LOAD_1(base, x0) \ |
| 137 | − EX_LD(LOAD(ldd, base + 0x00, %x0)) | |
| 143 | + EX_LD_FP(LOAD(ldd, base + 0x00, %x0)) | |
| 138 | 144 | #define FREG_LOAD_2(base, x0, x1) \ |
| 139 | − EX_LD(LOAD(ldd, base + 0x00, %x0)); \ | |
| 140 | − EX_LD(LOAD(ldd, base + 0x08, %x1)); | |
| 145 | + EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ | |
| 146 | + EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); | |
| 141 | 147 | #define FREG_LOAD_3(base, x0, x1, x2) \ |
| 142 | − EX_LD(LOAD(ldd, base + 0x00, %x0)); \ | |
| 143 | − EX_LD(LOAD(ldd, base + 0x08, %x1)); \ | |
| 144 | − EX_LD(LOAD(ldd, base + 0x10, %x2)); | |
| 148 | + EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ | |
| 149 | + EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ | |
| 150 | + EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); | |
| 145 | 151 | #define FREG_LOAD_4(base, x0, x1, x2, x3) \ |
| 146 | − EX_LD(LOAD(ldd, base + 0x00, %x0)); \ | |
| 147 | − EX_LD(LOAD(ldd, base + 0x08, %x1)); \ | |
| 148 | − EX_LD(LOAD(ldd, base + 0x10, %x2)); \ | |
| 149 | − EX_LD(LOAD(ldd, base + 0x18, %x3)); | |
| 152 | + EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ | |
| 153 | + EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ | |
| 154 | + EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ | |
| 155 | + EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); | |
| 150 | 156 | #define FREG_LOAD_5(base, x0, x1, x2, x3, x4) \ |
| 151 | − EX_LD(LOAD(ldd, base + 0x00, %x0)); \ | |
| 152 | − EX_LD(LOAD(ldd, base + 0x08, %x1)); \ | |
| 153 | − EX_LD(LOAD(ldd, base + 0x10, %x2)); \ | |
| 154 | − EX_LD(LOAD(ldd, base + 0x18, %x3)); \ | |
| 155 | − EX_LD(LOAD(ldd, base + 0x20, %x4)); | |
| 157 | + EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ | |
| 158 | + EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ | |
| 159 | + EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ | |
| 160 | + EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \ | |
| 161 | + EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); | |
| 156 | 162 | #define FREG_LOAD_6(base, x0, x1, x2, x3, x4, x5) \ |
| 157 | − EX_LD(LOAD(ldd, base + 0x00, %x0)); \ | |
| 158 | − EX_LD(LOAD(ldd, base + 0x08, %x1)); \ | |
| 159 | − EX_LD(LOAD(ldd, base + 0x10, %x2)); \ | |
| 160 | − EX_LD(LOAD(ldd, base + 0x18, %x3)); \ | |
| 161 | − EX_LD(LOAD(ldd, base + 0x20, %x4)); \ | |
| 162 | − EX_LD(LOAD(ldd, base + 0x28, %x5)); | |
| 163 | + EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ | |
| 164 | + EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ | |
| 165 | + EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ | |
| 166 | + EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \ | |
| 167 | + EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); \ | |
| 168 | + EX_LD_FP(LOAD(ldd, base + 0x28, %x5)); | |
| 163 | 169 | #define FREG_LOAD_7(base, x0, x1, x2, x3, x4, x5, x6) \ |
| 164 | − EX_LD(LOAD(ldd, base + 0x00, %x0)); \ | |
| 165 | − EX_LD(LOAD(ldd, base + 0x08, %x1)); \ | |
| 166 | − EX_LD(LOAD(ldd, base + 0x10, %x2)); \ | |
| 167 | − EX_LD(LOAD(ldd, base + 0x18, %x3)); \ | |
| 168 | − EX_LD(LOAD(ldd, base + 0x20, %x4)); \ | |
| 169 | − EX_LD(LOAD(ldd, base + 0x28, %x5)); \ | |
| 170 | − EX_LD(LOAD(ldd, base + 0x30, %x6)); | |
| 170 | + EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \ | |
| 171 | + EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \ | |
| 172 | + EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \ | |
| 173 | + EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \ | |
| 174 | + EX_LD_FP(LOAD(ldd, base + 0x20, %x4)); \ | |
| 175 | + EX_LD_FP(LOAD(ldd, base + 0x28, %x5)); \ | |
| 176 | + EX_LD_FP(LOAD(ldd, base + 0x30, %x6)); | |
| 171 | 177 | |
| 172 | 178 | .register %g2,#scratch |
| 173 | 179 | .register %g3,#scratch |
| @@ -275,11 +281,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 101 unmodified lines | ||
| 275 | 281 | nop |
| 276 | 282 | /* fall through for 0 < low bits < 8 */ |
| 277 | 283 | 110: sub %o4, 64, %g2 |
| 278 | − EX_LD(LOAD_BLK(%g2, %f0)) | |
| 279 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 280 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 284 | + EX_LD_FP(LOAD_BLK(%g2, %f0)) | |
| 285 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 286 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 281 | 287 | FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f14, f16) |
| 282 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 288 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 283 | 289 | FREG_MOVE_8(f16, f18, f20, f22, f24, f26, f28, f30) |
| 284 | 290 | subcc %g1, 64, %g1 |
| 285 | 291 | add %o4, 64, %o4 |
| @@ -290,10 +296,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 290 | 296 | |
| 291 | 297 | 120: sub %o4, 56, %g2 |
| 292 | 298 | FREG_LOAD_7(%g2, f0, f2, f4, f6, f8, f10, f12) |
| 293 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 294 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 299 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 300 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 295 | 301 | FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f16, f18) |
| 296 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 302 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 297 | 303 | FREG_MOVE_7(f18, f20, f22, f24, f26, f28, f30) |
| 298 | 304 | subcc %g1, 64, %g1 |
| 299 | 305 | add %o4, 64, %o4 |
| @@ -304,10 +310,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 304 | 310 | |
| 305 | 311 | 130: sub %o4, 48, %g2 |
| 306 | 312 | FREG_LOAD_6(%g2, f0, f2, f4, f6, f8, f10) |
| 307 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 308 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 313 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 314 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 309 | 315 | FREG_FROB(f0, f2, f4, f6, f8, f10, f16, f18, f20) |
| 310 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 316 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 311 | 317 | FREG_MOVE_6(f20, f22, f24, f26, f28, f30) |
| 312 | 318 | subcc %g1, 64, %g1 |
| 313 | 319 | add %o4, 64, %o4 |
| @@ -318,10 +324,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 318 | 324 | |
| 319 | 325 | 140: sub %o4, 40, %g2 |
| 320 | 326 | FREG_LOAD_5(%g2, f0, f2, f4, f6, f8) |
| 321 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 322 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 327 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 328 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 323 | 329 | FREG_FROB(f0, f2, f4, f6, f8, f16, f18, f20, f22) |
| 324 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 330 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 325 | 331 | FREG_MOVE_5(f22, f24, f26, f28, f30) |
| 326 | 332 | subcc %g1, 64, %g1 |
| 327 | 333 | add %o4, 64, %o4 |
| @@ -332,10 +338,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 332 | 338 | |
| 333 | 339 | 150: sub %o4, 32, %g2 |
| 334 | 340 | FREG_LOAD_4(%g2, f0, f2, f4, f6) |
| 335 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 336 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 341 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 342 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 337 | 343 | FREG_FROB(f0, f2, f4, f6, f16, f18, f20, f22, f24) |
| 338 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 344 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 339 | 345 | FREG_MOVE_4(f24, f26, f28, f30) |
| 340 | 346 | subcc %g1, 64, %g1 |
| 341 | 347 | add %o4, 64, %o4 |
| @@ -346,10 +352,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 346 | 352 | |
| 347 | 353 | 160: sub %o4, 24, %g2 |
| 348 | 354 | FREG_LOAD_3(%g2, f0, f2, f4) |
| 349 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 350 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 355 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 356 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 351 | 357 | FREG_FROB(f0, f2, f4, f16, f18, f20, f22, f24, f26) |
| 352 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 358 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 353 | 359 | FREG_MOVE_3(f26, f28, f30) |
| 354 | 360 | subcc %g1, 64, %g1 |
| 355 | 361 | add %o4, 64, %o4 |
| @@ -360,10 +366,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 360 | 366 | |
| 361 | 367 | 170: sub %o4, 16, %g2 |
| 362 | 368 | FREG_LOAD_2(%g2, f0, f2) |
| 363 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 364 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 369 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 370 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 365 | 371 | FREG_FROB(f0, f2, f16, f18, f20, f22, f24, f26, f28) |
| 366 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 372 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 367 | 373 | FREG_MOVE_2(f28, f30) |
| 368 | 374 | subcc %g1, 64, %g1 |
| 369 | 375 | add %o4, 64, %o4 |
| @@ -374,10 +380,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 374 | 380 | |
| 375 | 381 | 180: sub %o4, 8, %g2 |
| 376 | 382 | FREG_LOAD_1(%g2, f0) |
| 377 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 378 | − EX_LD(LOAD_BLK(%o4, %f16)) | |
| 383 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 384 | + EX_LD_FP(LOAD_BLK(%o4, %f16)) | |
| 379 | 385 | FREG_FROB(f0, f16, f18, f20, f22, f24, f26, f28, f30) |
| 380 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 386 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 381 | 387 | FREG_MOVE_1(f30) |
| 382 | 388 | subcc %g1, 64, %g1 |
| 383 | 389 | add %o4, 64, %o4 |
| @@ -387,10 +393,10 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 3 unmodified lines | ||
| 387 | 393 | nop |
| 388 | 394 | |
| 389 | 395 | 190: |
| 390 | −1: EX_ST(STORE_INIT(%g0, %o4 + %g3)) | |
| 396 | +1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3)) | |
| 391 | 397 | subcc %g1, 64, %g1 |
| 392 | − EX_LD(LOAD_BLK(%o4, %f0)) | |
| 393 | − EX_ST(STORE_BLK(%f0, %o4 + %g3)) | |
| 398 | + EX_LD_FP(LOAD_BLK(%o4, %f0)) | |
| 399 | + EX_ST_FP(STORE_BLK(%f0, %o4 + %g3)) | |
| 394 | 400 | add %o4, 64, %o4 |
| 395 | 401 | bne,pt %xcc, 1b |
| 396 | 402 | LOAD(prefetch, %o4 + 64, #one_read) |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_LD_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_asi_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #ifndef ASI_AIUS |
| 15 | 23 | #define ASI_AIUS 0x11 |
| 16 | 24 | #endif |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_ST_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_asi_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #ifndef ASI_AIUS |
| 15 | 23 | #define ASI_AIUS 0x11 |
| 16 | 24 | #endif |
| @@ -48,10 +48,16 @@ · 47 unmodified lines | ||
| 48 | 48 | #ifndef EX_LD |
| 49 | 49 | #define EX_LD(x) x |
| 50 | 50 | #endif |
| 51 | +#ifndef EX_LD_FP | |
| 52 | +#define EX_LD_FP(x) x | |
| 53 | +#endif | |
| 51 | 54 | |
| 52 | 55 | #ifndef EX_ST |
| 53 | 56 | #define EX_ST(x) x |
| 54 | 57 | #endif |
| 58 | +#ifndef EX_ST_FP | |
| 59 | +#define EX_ST_FP(x) x | |
| 60 | +#endif | |
| 55 | 61 | |
| 56 | 62 | #ifndef EX_RETVAL |
| 57 | 63 | #define EX_RETVAL(x) x |
| @@ -210,17 +216,17 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 152 unmodified lines | ||
| 210 | 216 | sub %o2, %o4, %o2 |
| 211 | 217 | alignaddr %o1, %g0, %g1 |
| 212 | 218 | add %o1, %o4, %o1 |
| 213 | − EX_LD(LOAD(ldd, %g1 + 0x00, %f0)) | |
| 214 | −1: EX_LD(LOAD(ldd, %g1 + 0x08, %f2)) | |
| 219 | + EX_LD_FP(LOAD(ldd, %g1 + 0x00, %f0)) | |
| 220 | +1: EX_LD_FP(LOAD(ldd, %g1 + 0x08, %f2)) | |
| 215 | 221 | subcc %o4, 0x40, %o4 |
| 216 | − EX_LD(LOAD(ldd, %g1 + 0x10, %f4)) | |
| 217 | − EX_LD(LOAD(ldd, %g1 + 0x18, %f6)) | |
| 218 | − EX_LD(LOAD(ldd, %g1 + 0x20, %f8)) | |
| 219 | − EX_LD(LOAD(ldd, %g1 + 0x28, %f10)) | |
| 220 | − EX_LD(LOAD(ldd, %g1 + 0x30, %f12)) | |
| 221 | − EX_LD(LOAD(ldd, %g1 + 0x38, %f14)) | |
| 222 | + EX_LD_FP(LOAD(ldd, %g1 + 0x10, %f4)) | |
| 223 | + EX_LD_FP(LOAD(ldd, %g1 + 0x18, %f6)) | |
| 224 | + EX_LD_FP(LOAD(ldd, %g1 + 0x20, %f8)) | |
| 225 | + EX_LD_FP(LOAD(ldd, %g1 + 0x28, %f10)) | |
| 226 | + EX_LD_FP(LOAD(ldd, %g1 + 0x30, %f12)) | |
| 227 | + EX_LD_FP(LOAD(ldd, %g1 + 0x38, %f14)) | |
| 222 | 228 | faligndata %f0, %f2, %f16 |
| 223 | − EX_LD(LOAD(ldd, %g1 + 0x40, %f0)) | |
| 229 | + EX_LD_FP(LOAD(ldd, %g1 + 0x40, %f0)) | |
| 224 | 230 | faligndata %f2, %f4, %f18 |
| 225 | 231 | add %g1, 0x40, %g1 |
| 226 | 232 | faligndata %f4, %f6, %f20 |
| @@ -229,14 +235,14 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 2 unmodified lines | ||
| 229 | 235 | faligndata %f10, %f12, %f26 |
| 230 | 236 | faligndata %f12, %f14, %f28 |
| 231 | 237 | faligndata %f14, %f0, %f30 |
| 232 | − EX_ST(STORE(std, %f16, %o0 + 0x00)) | |
| 233 | − EX_ST(STORE(std, %f18, %o0 + 0x08)) | |
| 234 | − EX_ST(STORE(std, %f20, %o0 + 0x10)) | |
| 235 | − EX_ST(STORE(std, %f22, %o0 + 0x18)) | |
| 236 | − EX_ST(STORE(std, %f24, %o0 + 0x20)) | |
| 237 | − EX_ST(STORE(std, %f26, %o0 + 0x28)) | |
| 238 | − EX_ST(STORE(std, %f28, %o0 + 0x30)) | |
| 239 | − EX_ST(STORE(std, %f30, %o0 + 0x38)) | |
| 238 | + EX_ST_FP(STORE(std, %f16, %o0 + 0x00)) | |
| 239 | + EX_ST_FP(STORE(std, %f18, %o0 + 0x08)) | |
| 240 | + EX_ST_FP(STORE(std, %f20, %o0 + 0x10)) | |
| 241 | + EX_ST_FP(STORE(std, %f22, %o0 + 0x18)) | |
| 242 | + EX_ST_FP(STORE(std, %f24, %o0 + 0x20)) | |
| 243 | + EX_ST_FP(STORE(std, %f26, %o0 + 0x28)) | |
| 244 | + EX_ST_FP(STORE(std, %f28, %o0 + 0x30)) | |
| 245 | + EX_ST_FP(STORE(std, %f30, %o0 + 0x38)) | |
| 240 | 246 | add %o0, 0x40, %o0 |
| 241 | 247 | bne,pt %icc, 1b |
| 242 | 248 | LOAD(prefetch, %g1 + 0x200, #n_reads_strong) |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_LD_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #define FUNC_NAME ___copy_from_user |
| 15 | 23 | #define LOAD(type,addr,dest) type##a [addr] %asi, dest |
| 16 | 24 | #define LOAD_BLK(addr,dest) ldda [addr] ASI_BLK_AIUS, dest |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_ST_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #define FUNC_NAME ___copy_to_user |
| 15 | 23 | #define STORE(type,src,addr) type##a src, [addr] ASI_AIUS |
| 16 | 24 | #define STORE_BLK(src,addr) stda src, [addr] ASI_BLK_AIUS |
| @@ -25,10 +25,16 @@ · 24 unmodified lines | ||
| 25 | 25 | #ifndef EX_LD |
| 26 | 26 | #define EX_LD(x) x |
| 27 | 27 | #endif |
| 28 | +#ifndef EX_LD_FP | |
| 29 | +#define EX_LD_FP(x) x | |
| 30 | +#endif | |
| 28 | 31 | |
| 29 | 32 | #ifndef EX_ST |
| 30 | 33 | #define EX_ST(x) x |
| 31 | 34 | #endif |
| 35 | +#ifndef EX_ST_FP | |
| 36 | +#define EX_ST_FP(x) x | |
| 37 | +#endif | |
| 32 | 38 | |
| 33 | 39 | #ifndef EX_RETVAL |
| 34 | 40 | #define EX_RETVAL(x) x |
| @@ -73,8 +79,8 @@ · 38 unmodified lines | ||
| 73 | 79 | faligndata %f8, %f9, %f62; |
| 74 | 80 | |
| 75 | 81 | #define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, len, jmptgt) \ |
| 76 | − EX_LD(LOAD_BLK(%src, %fdest)); \ | |
| 77 | − EX_ST(STORE_BLK(%fsrc, %dest)); \ | |
| 82 | + EX_LD_FP(LOAD_BLK(%src, %fdest)); \ | |
| 83 | + EX_ST_FP(STORE_BLK(%fsrc, %dest)); \ | |
| 78 | 84 | add %src, 0x40, %src; \ |
| 79 | 85 | subcc %len, 0x40, %len; \ |
| 80 | 86 | be,pn %xcc, jmptgt; \ |
| @@ -89,12 +95,12 @@ · 8 unmodified lines | ||
| 89 | 95 | |
| 90 | 96 | #define DO_SYNC membar #Sync; |
| 91 | 97 | #define STORE_SYNC(dest, fsrc) \ |
| 92 | − EX_ST(STORE_BLK(%fsrc, %dest)); \ | |
| 98 | + EX_ST_FP(STORE_BLK(%fsrc, %dest)); \ | |
| 93 | 99 | add %dest, 0x40, %dest; \ |
| 94 | 100 | DO_SYNC |
| 95 | 101 | |
| 96 | 102 | #define STORE_JUMP(dest, fsrc, target) \ |
| 97 | − EX_ST(STORE_BLK(%fsrc, %dest)); \ | |
| 103 | + EX_ST_FP(STORE_BLK(%fsrc, %dest)); \ | |
| 98 | 104 | add %dest, 0x40, %dest; \ |
| 99 | 105 | ba,pt %xcc, target; \ |
| 100 | 106 | nop; |
| @@ -103,7 +109,7 @@ · 2 unmodified lines | ||
| 103 | 109 | subcc %left, 8, %left;\ |
| 104 | 110 | bl,pn %xcc, 95f; \ |
| 105 | 111 | faligndata %f0, %f1, %f48; \ |
| 106 | − EX_ST(STORE(std, %f48, %dest)); \ | |
| 112 | + EX_ST_FP(STORE(std, %f48, %dest)); \ | |
| 107 | 113 | add %dest, 8, %dest; |
| 108 | 114 | |
| 109 | 115 | #define UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \ |
| @@ -160,8 +166,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 50 unmodified lines | ||
| 160 | 166 | and %g2, 0x38, %g2 |
| 161 | 167 | |
| 162 | 168 | 1: subcc %g1, 0x1, %g1 |
| 163 | − EX_LD(LOAD(ldub, %o1 + 0x00, %o3)) | |
| 164 | − EX_ST(STORE(stb, %o3, %o1 + %GLOBAL_SPARE)) | |
| 169 | + EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3)) | |
| 170 | + EX_ST_FP(STORE(stb, %o3, %o1 + %GLOBAL_SPARE)) | |
| 165 | 171 | bgu,pt %XCC, 1b |
| 166 | 172 | add %o1, 0x1, %o1 |
| 167 | 173 | |
| @@ -172,20 +178,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 172 | 178 | be,pt %icc, 3f |
| 173 | 179 | alignaddr %o1, %g0, %o1 |
| 174 | 180 | |
| 175 | − EX_LD(LOAD(ldd, %o1, %f4)) | |
| 176 | −1: EX_LD(LOAD(ldd, %o1 + 0x8, %f6)) | |
| 181 | + EX_LD_FP(LOAD(ldd, %o1, %f4)) | |
| 182 | +1: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6)) | |
| 177 | 183 | add %o1, 0x8, %o1 |
| 178 | 184 | subcc %g2, 0x8, %g2 |
| 179 | 185 | faligndata %f4, %f6, %f0 |
| 180 | − EX_ST(STORE(std, %f0, %o0)) | |
| 186 | + EX_ST_FP(STORE(std, %f0, %o0)) | |
| 181 | 187 | be,pn %icc, 3f |
| 182 | 188 | add %o0, 0x8, %o0 |
| 183 | 189 | |
| 184 | − EX_LD(LOAD(ldd, %o1 + 0x8, %f4)) | |
| 190 | + EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4)) | |
| 185 | 191 | add %o1, 0x8, %o1 |
| 186 | 192 | subcc %g2, 0x8, %g2 |
| 187 | 193 | faligndata %f6, %f4, %f0 |
| 188 | − EX_ST(STORE(std, %f0, %o0)) | |
| 194 | + EX_ST_FP(STORE(std, %f0, %o0)) | |
| 189 | 195 | bne,pt %icc, 1b |
| 190 | 196 | add %o0, 0x8, %o0 |
| 191 | 197 | |
| @@ -208,13 +214,13 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 16 unmodified lines | ||
| 208 | 214 | add %g1, %GLOBAL_SPARE, %g1 |
| 209 | 215 | subcc %o2, %g3, %o2 |
| 210 | 216 | |
| 211 | − EX_LD(LOAD_BLK(%o1, %f0)) | |
| 217 | + EX_LD_FP(LOAD_BLK(%o1, %f0)) | |
| 212 | 218 | add %o1, 0x40, %o1 |
| 213 | 219 | add %g1, %g3, %g1 |
| 214 | − EX_LD(LOAD_BLK(%o1, %f16)) | |
| 220 | + EX_LD_FP(LOAD_BLK(%o1, %f16)) | |
| 215 | 221 | add %o1, 0x40, %o1 |
| 216 | 222 | sub %GLOBAL_SPARE, 0x80, %GLOBAL_SPARE |
| 217 | − EX_LD(LOAD_BLK(%o1, %f32)) | |
| 223 | + EX_LD_FP(LOAD_BLK(%o1, %f32)) | |
| 218 | 224 | add %o1, 0x40, %o1 |
| 219 | 225 | |
| 220 | 226 | /* There are 8 instances of the unrolled loop, |
| @@ -426,28 +432,28 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 205 unmodified lines | ||
| 426 | 432 | 62: FINISH_VISCHUNK(o0, f44, f46, g3) |
| 427 | 433 | 63: UNEVEN_VISCHUNK_LAST(o0, f46, f0, g3) |
| 428 | 434 | |
| 429 | −93: EX_LD(LOAD(ldd, %o1, %f2)) | |
| 435 | +93: EX_LD_FP(LOAD(ldd, %o1, %f2)) | |
| 430 | 436 | add %o1, 8, %o1 |
| 431 | 437 | subcc %g3, 8, %g3 |
| 432 | 438 | faligndata %f0, %f2, %f8 |
| 433 | − EX_ST(STORE(std, %f8, %o0)) | |
| 439 | + EX_ST_FP(STORE(std, %f8, %o0)) | |
| 434 | 440 | bl,pn %xcc, 95f |
| 435 | 441 | add %o0, 8, %o0 |
| 436 | − EX_LD(LOAD(ldd, %o1, %f0)) | |
| 442 | + EX_LD_FP(LOAD(ldd, %o1, %f0)) | |
| 437 | 443 | add %o1, 8, %o1 |
| 438 | 444 | subcc %g3, 8, %g3 |
| 439 | 445 | faligndata %f2, %f0, %f8 |
| 440 | − EX_ST(STORE(std, %f8, %o0)) | |
| 446 | + EX_ST_FP(STORE(std, %f8, %o0)) | |
| 441 | 447 | bge,pt %xcc, 93b |
| 442 | 448 | add %o0, 8, %o0 |
| 443 | 449 | |
| 444 | 450 | 95: brz,pt %o2, 2f |
| 445 | 451 | mov %g1, %o1 |
| 446 | 452 | |
| 447 | −1: EX_LD(LOAD(ldub, %o1, %o3)) | |
| 453 | +1: EX_LD_FP(LOAD(ldub, %o1, %o3)) | |
| 448 | 454 | add %o1, 1, %o1 |
| 449 | 455 | subcc %o2, 1, %o2 |
| 450 | − EX_ST(STORE(stb, %o3, %o0)) | |
| 456 | + EX_ST_FP(STORE(stb, %o3, %o0)) | |
| 451 | 457 | bne,pt %xcc, 1b |
| 452 | 458 | add %o0, 1, %o0 |
| 453 | 459 | |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_LD_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #define FUNC_NAME U3copy_from_user |
| 15 | 23 | #define LOAD(type,addr,dest) type##a [addr] %asi, dest |
| 16 | 24 | #define EX_RETVAL(x) 0 |
| @@ -11,6 +11,14 @@ · 10 unmodified lines | ||
| 11 | 11 | .text; \ |
| 12 | 12 | .align 4; |
| 13 | 13 | |
| 14 | +#define EX_ST_FP(x) \ | |
| 15 | +98: x; \ | |
| 16 | + .section __ex_table,"a";\ | |
| 17 | + .align 4; \ | |
| 18 | + .word 98b, __retl_one_fp;\ | |
| 19 | + .text; \ | |
| 20 | + .align 4; | |
| 21 | + | |
| 14 | 22 | #define FUNC_NAME U3copy_to_user |
| 15 | 23 | #define STORE(type,src,addr) type##a src, [addr] ASI_AIUS |
| 16 | 24 | #define STORE_BLK(src,addr) stda src, [addr] ASI_BLK_AIUS |
| @@ -24,10 +24,16 @@ · 23 unmodified lines | ||
| 24 | 24 | #ifndef EX_LD |
| 25 | 25 | #define EX_LD(x) x |
| 26 | 26 | #endif |
| 27 | +#ifndef EX_LD_FP | |
| 28 | +#define EX_LD_FP(x) x | |
| 29 | +#endif | |
| 27 | 30 | |
| 28 | 31 | #ifndef EX_ST |
| 29 | 32 | #define EX_ST(x) x |
| 30 | 33 | #endif |
| 34 | +#ifndef EX_ST_FP | |
| 35 | +#define EX_ST_FP(x) x | |
| 36 | +#endif | |
| 31 | 37 | |
| 32 | 38 | #ifndef EX_RETVAL |
| 33 | 39 | #define EX_RETVAL(x) x |
| @@ -120,8 +126,8 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 86 unmodified lines | ||
| 120 | 126 | and %g2, 0x38, %g2 |
| 121 | 127 | |
| 122 | 128 | 1: subcc %g1, 0x1, %g1 |
| 123 | − EX_LD(LOAD(ldub, %o1 + 0x00, %o3)) | |
| 124 | − EX_ST(STORE(stb, %o3, %o1 + GLOBAL_SPARE)) | |
| 129 | + EX_LD_FP(LOAD(ldub, %o1 + 0x00, %o3)) | |
| 130 | + EX_ST_FP(STORE(stb, %o3, %o1 + GLOBAL_SPARE)) | |
| 125 | 131 | bgu,pt %XCC, 1b |
| 126 | 132 | add %o1, 0x1, %o1 |
| 127 | 133 | |
| @@ -132,20 +138,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 132 | 138 | be,pt %icc, 3f |
| 133 | 139 | alignaddr %o1, %g0, %o1 |
| 134 | 140 | |
| 135 | − EX_LD(LOAD(ldd, %o1, %f4)) | |
| 136 | −1: EX_LD(LOAD(ldd, %o1 + 0x8, %f6)) | |
| 141 | + EX_LD_FP(LOAD(ldd, %o1, %f4)) | |
| 142 | +1: EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f6)) | |
| 137 | 143 | add %o1, 0x8, %o1 |
| 138 | 144 | subcc %g2, 0x8, %g2 |
| 139 | 145 | faligndata %f4, %f6, %f0 |
| 140 | − EX_ST(STORE(std, %f0, %o0)) | |
| 146 | + EX_ST_FP(STORE(std, %f0, %o0)) | |
| 141 | 147 | be,pn %icc, 3f |
| 142 | 148 | add %o0, 0x8, %o0 |
| 143 | 149 | |
| 144 | − EX_LD(LOAD(ldd, %o1 + 0x8, %f4)) | |
| 150 | + EX_LD_FP(LOAD(ldd, %o1 + 0x8, %f4)) | |
| 145 | 151 | add %o1, 0x8, %o1 |
| 146 | 152 | subcc %g2, 0x8, %g2 |
| 147 | 153 | faligndata %f6, %f4, %f2 |
| 148 | − EX_ST(STORE(std, %f2, %o0)) | |
| 154 | + EX_ST_FP(STORE(std, %f2, %o0)) | |
| 149 | 155 | bne,pt %icc, 1b |
| 150 | 156 | add %o0, 0x8, %o0 |
| 151 | 157 | |
| @@ -155,25 +161,25 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 3 unmodified lines | ||
| 155 | 161 | LOAD(prefetch, %o1 + 0x080, #one_read) |
| 156 | 162 | LOAD(prefetch, %o1 + 0x0c0, #one_read) |
| 157 | 163 | LOAD(prefetch, %o1 + 0x100, #one_read) |
| 158 | − EX_LD(LOAD(ldd, %o1 + 0x000, %f0)) | |
| 164 | + EX_LD_FP(LOAD(ldd, %o1 + 0x000, %f0)) | |
| 159 | 165 | LOAD(prefetch, %o1 + 0x140, #one_read) |
| 160 | − EX_LD(LOAD(ldd, %o1 + 0x008, %f2)) | |
| 166 | + EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2)) | |
| 161 | 167 | LOAD(prefetch, %o1 + 0x180, #one_read) |
| 162 | − EX_LD(LOAD(ldd, %o1 + 0x010, %f4)) | |
| 168 | + EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4)) | |
| 163 | 169 | LOAD(prefetch, %o1 + 0x1c0, #one_read) |
| 164 | 170 | faligndata %f0, %f2, %f16 |
| 165 | − EX_LD(LOAD(ldd, %o1 + 0x018, %f6)) | |
| 171 | + EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6)) | |
| 166 | 172 | faligndata %f2, %f4, %f18 |
| 167 | − EX_LD(LOAD(ldd, %o1 + 0x020, %f8)) | |
| 173 | + EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8)) | |
| 168 | 174 | faligndata %f4, %f6, %f20 |
| 169 | − EX_LD(LOAD(ldd, %o1 + 0x028, %f10)) | |
| 175 | + EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10)) | |
| 170 | 176 | faligndata %f6, %f8, %f22 |
| 171 | 177 | |
| 172 | − EX_LD(LOAD(ldd, %o1 + 0x030, %f12)) | |
| 178 | + EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12)) | |
| 173 | 179 | faligndata %f8, %f10, %f24 |
| 174 | − EX_LD(LOAD(ldd, %o1 + 0x038, %f14)) | |
| 180 | + EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14)) | |
| 175 | 181 | faligndata %f10, %f12, %f26 |
| 176 | − EX_LD(LOAD(ldd, %o1 + 0x040, %f0)) | |
| 182 | + EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0)) | |
| 177 | 183 | |
| 178 | 184 | subcc GLOBAL_SPARE, 0x80, GLOBAL_SPARE |
| 179 | 185 | add %o1, 0x40, %o1 |
| @@ -184,26 +190,26 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 4 unmodified lines | ||
| 184 | 190 | |
| 185 | 191 | .align 64 |
| 186 | 192 | 1: |
| 187 | − EX_LD(LOAD(ldd, %o1 + 0x008, %f2)) | |
| 193 | + EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2)) | |
| 188 | 194 | faligndata %f12, %f14, %f28 |
| 189 | − EX_LD(LOAD(ldd, %o1 + 0x010, %f4)) | |
| 195 | + EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4)) | |
| 190 | 196 | faligndata %f14, %f0, %f30 |
| 191 | − EX_ST(STORE_BLK(%f16, %o0)) | |
| 192 | − EX_LD(LOAD(ldd, %o1 + 0x018, %f6)) | |
| 197 | + EX_ST_FP(STORE_BLK(%f16, %o0)) | |
| 198 | + EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6)) | |
| 193 | 199 | faligndata %f0, %f2, %f16 |
| 194 | 200 | add %o0, 0x40, %o0 |
| 195 | 201 | |
| 196 | − EX_LD(LOAD(ldd, %o1 + 0x020, %f8)) | |
| 202 | + EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8)) | |
| 197 | 203 | faligndata %f2, %f4, %f18 |
| 198 | − EX_LD(LOAD(ldd, %o1 + 0x028, %f10)) | |
| 204 | + EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10)) | |
| 199 | 205 | faligndata %f4, %f6, %f20 |
| 200 | − EX_LD(LOAD(ldd, %o1 + 0x030, %f12)) | |
| 206 | + EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12)) | |
| 201 | 207 | subcc %o3, 0x01, %o3 |
| 202 | 208 | faligndata %f6, %f8, %f22 |
| 203 | − EX_LD(LOAD(ldd, %o1 + 0x038, %f14)) | |
| 209 | + EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14)) | |
| 204 | 210 | |
| 205 | 211 | faligndata %f8, %f10, %f24 |
| 206 | − EX_LD(LOAD(ldd, %o1 + 0x040, %f0)) | |
| 212 | + EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0)) | |
| 207 | 213 | LOAD(prefetch, %o1 + 0x1c0, #one_read) |
| 208 | 214 | faligndata %f10, %f12, %f26 |
| 209 | 215 | bg,pt %XCC, 1b |
| @@ -211,29 +217,29 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 1 unmodified line | ||
| 211 | 217 | |
| 212 | 218 | /* Finally we copy the last full 64-byte block. */ |
| 213 | 219 | 2: |
| 214 | − EX_LD(LOAD(ldd, %o1 + 0x008, %f2)) | |
| 220 | + EX_LD_FP(LOAD(ldd, %o1 + 0x008, %f2)) | |
| 215 | 221 | faligndata %f12, %f14, %f28 |
| 216 | − EX_LD(LOAD(ldd, %o1 + 0x010, %f4)) | |
| 222 | + EX_LD_FP(LOAD(ldd, %o1 + 0x010, %f4)) | |
| 217 | 223 | faligndata %f14, %f0, %f30 |
| 218 | − EX_ST(STORE_BLK(%f16, %o0)) | |
| 219 | − EX_LD(LOAD(ldd, %o1 + 0x018, %f6)) | |
| 224 | + EX_ST_FP(STORE_BLK(%f16, %o0)) | |
| 225 | + EX_LD_FP(LOAD(ldd, %o1 + 0x018, %f6)) | |
| 220 | 226 | faligndata %f0, %f2, %f16 |
| 221 | − EX_LD(LOAD(ldd, %o1 + 0x020, %f8)) | |
| 227 | + EX_LD_FP(LOAD(ldd, %o1 + 0x020, %f8)) | |
| 222 | 228 | faligndata %f2, %f4, %f18 |
| 223 | − EX_LD(LOAD(ldd, %o1 + 0x028, %f10)) | |
| 229 | + EX_LD_FP(LOAD(ldd, %o1 + 0x028, %f10)) | |
| 224 | 230 | faligndata %f4, %f6, %f20 |
| 225 | − EX_LD(LOAD(ldd, %o1 + 0x030, %f12)) | |
| 231 | + EX_LD_FP(LOAD(ldd, %o1 + 0x030, %f12)) | |
| 226 | 232 | faligndata %f6, %f8, %f22 |
| 227 | − EX_LD(LOAD(ldd, %o1 + 0x038, %f14)) | |
| 233 | + EX_LD_FP(LOAD(ldd, %o1 + 0x038, %f14)) | |
| 228 | 234 | faligndata %f8, %f10, %f24 |
| 229 | 235 | cmp %g1, 0 |
| 230 | 236 | be,pt %XCC, 1f |
| 231 | 237 | add %o0, 0x40, %o0 |
| 232 | − EX_LD(LOAD(ldd, %o1 + 0x040, %f0)) | |
| 238 | + EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0)) | |
| 233 | 239 | 1: faligndata %f10, %f12, %f26 |
| 234 | 240 | faligndata %f12, %f14, %f28 |
| 235 | 241 | faligndata %f14, %f0, %f30 |
| 236 | − EX_ST(STORE_BLK(%f16, %o0)) | |
| 242 | + EX_ST_FP(STORE_BLK(%f16, %o0)) | |
| 237 | 243 | add %o0, 0x40, %o0 |
| 238 | 244 | add %o1, 0x40, %o1 |
| 239 | 245 | membar #Sync |
| @@ -253,20 +259,20 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 13 unmodified lines | ||
| 253 | 259 | |
| 254 | 260 | sub %o2, %g2, %o2 |
| 255 | 261 | be,a,pt %XCC, 1f |
| 256 | − EX_LD(LOAD(ldd, %o1 + 0x00, %f0)) | |
| 262 | + EX_LD_FP(LOAD(ldd, %o1 + 0x00, %f0)) | |
| 257 | 263 | |
| 258 | −1: EX_LD(LOAD(ldd, %o1 + 0x08, %f2)) | |
| 264 | +1: EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f2)) | |
| 259 | 265 | add %o1, 0x8, %o1 |
| 260 | 266 | subcc %g2, 0x8, %g2 |
| 261 | 267 | faligndata %f0, %f2, %f8 |
| 262 | − EX_ST(STORE(std, %f8, %o0)) | |
| 268 | + EX_ST_FP(STORE(std, %f8, %o0)) | |
| 263 | 269 | be,pn %XCC, 2f |
| 264 | 270 | add %o0, 0x8, %o0 |
| 265 | − EX_LD(LOAD(ldd, %o1 + 0x08, %f0)) | |
| 271 | + EX_LD_FP(LOAD(ldd, %o1 + 0x08, %f0)) | |
| 266 | 272 | add %o1, 0x8, %o1 |
| 267 | 273 | subcc %g2, 0x8, %g2 |
| 268 | 274 | faligndata %f2, %f0, %f8 |
| 269 | − EX_ST(STORE(std, %f8, %o0)) | |
| 275 | + EX_ST_FP(STORE(std, %f8, %o0)) | |
| 270 | 276 | bne,pn %XCC, 1b |
| 271 | 277 | add %o0, 0x8, %o0 |
| 272 | 278 | |
| @@ -420,22 +420,9 @@ void bpf_jit_compile(struct bpf_prog *fp) · 419 unmodified lines | ||
| 420 | 420 | } |
| 421 | 421 | emit_reg_move(O7, r_saved_O7); |
| 422 | 422 | |
| 423 | − switch (filter[0].code) { | |
| 424 | − case BPF_RET | BPF_K: | |
| 425 | − case BPF_LD | BPF_W | BPF_LEN: | |
| 426 | − case BPF_LD | BPF_W | BPF_ABS: | |
| 427 | − case BPF_LD | BPF_H | BPF_ABS: | |
| 428 | − case BPF_LD | BPF_B | BPF_ABS: | |
| 429 | − /* The first instruction sets the A register (or is | |
| 430 | − * a "RET 'constant'") | |
| 431 | − */ | |
| 432 | − break; | |
| 433 | − default: | |
| 434 | − /* Make sure we dont leak kernel information to the | |
| 435 | − * user. | |
| 436 | − */ | |
| 423 | + /* Make sure we dont leak kernel information to the user. */ | |
| 424 | + if (bpf_needs_clear_a(&filter[0])) | |
| 437 | 425 | emit_clear(r_A); /* A = 0 */ |
| 438 | − } | |
| 439 | 426 | |
| 440 | 427 | for (i = 0; i < flen; i++) { |
| 441 | 428 | unsigned int K = filter[i].k; |
| @@ -176,8 +176,6 @@ config NR_CPUS · 175 unmodified lines | ||
| 176 | 176 | smaller kernel memory footprint results from using a smaller |
| 177 | 177 | value on chips with fewer tiles. |
| 178 | 178 | |
| 179 | −if TILEGX | |
| 180 | − | |
| 181 | 179 | choice |
| 182 | 180 | prompt "Kernel page size" |
| 183 | 181 | default PAGE_SIZE_64KB |
| @@ -188,8 +186,11 @@ choice · 4 unmodified lines | ||
| 188 | 186 | connections, etc., it may be better to select 16KB, which uses |
| 189 | 187 | memory more efficiently at some cost in TLB performance. |
| 190 | 188 | |
| 191 | − Note that this option is TILE-Gx specific; currently | |
| 192 | − TILEPro page size is set by rebuilding the hypervisor. | |
| 189 | + Note that for TILEPro, you must also rebuild the hypervisor | |
| 190 | + with a matching page size. | |
| 191 | + | |
| 192 | +config PAGE_SIZE_4KB | |
| 193 | + bool "4KB" if TILEPRO | |
| 193 | 194 | |
| 194 | 195 | config PAGE_SIZE_16KB |
| 195 | 196 | bool "16KB" |
| @@ -199,8 +200,6 @@ config PAGE_SIZE_64KB · 3 unmodified lines | ||
| 199 | 200 | |
| 200 | 201 | endchoice |
| 201 | 202 | |
| 202 | −endif | |
| 203 | − | |
| 204 | 203 | source "kernel/Kconfig.hz" |
| 205 | 204 | |
| 206 | 205 | config KEXEC |
| @@ -20,15 +20,17 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <arch/chip.h> |
| 21 | 21 | |
| 22 | 22 | /* PAGE_SHIFT and HPAGE_SHIFT determine the page sizes. */ |
| 23 | −#if defined(CONFIG_PAGE_SIZE_16KB) | |
| 23 | +#if defined(CONFIG_PAGE_SIZE_4KB) /* tilepro only */ | |
| 24 | +#define PAGE_SHIFT 12 | |
| 25 | +#define CTX_PAGE_FLAG HV_CTX_PG_SM_4K | |
| 26 | +#elif defined(CONFIG_PAGE_SIZE_16KB) | |
| 24 | 27 | #define PAGE_SHIFT 14 |
| 25 | 28 | #define CTX_PAGE_FLAG HV_CTX_PG_SM_16K |
| 26 | 29 | #elif defined(CONFIG_PAGE_SIZE_64KB) |
| 27 | 30 | #define PAGE_SHIFT 16 |
| 28 | 31 | #define CTX_PAGE_FLAG HV_CTX_PG_SM_64K |
| 29 | 32 | #else |
| 30 | −#define PAGE_SHIFT HV_LOG2_DEFAULT_PAGE_SIZE_SMALL | |
| 31 | −#define CTX_PAGE_FLAG 0 | |
| 33 | +#error Page size not specified in Kconfig | |
| 32 | 34 | #endif |
| 33 | 35 | #define HPAGE_SHIFT HV_LOG2_DEFAULT_PAGE_SIZE_LARGE |
| 34 | 36 | |
| @@ -421,7 +421,7 @@ __visible long do_fast_syscall_32(struct pt_regs *regs) · 420 unmodified lines | ||
| 421 | 421 | regs->ip = landing_pad; |
| 422 | 422 | |
| 423 | 423 | /* |
| 424 | − * Fetch ECX from where the vDSO stashed it. | |
| 424 | + * Fetch EBP from where the vDSO stashed it. | |
| 425 | 425 | * |
| 426 | 426 | * WARNING: We are in CONTEXT_USER and RCU isn't paying attention! |
| 427 | 427 | */ |
| @@ -432,10 +432,10 @@ __visible long do_fast_syscall_32(struct pt_regs *regs) · 4 unmodified lines | ||
| 432 | 432 | * Micro-optimization: the pointer we're following is explicitly |
| 433 | 433 | * 32 bits, so it can't be out of range. |
| 434 | 434 | */ |
| 435 | − __get_user(*(u32 *)®s->cx, | |
| 435 | + __get_user(*(u32 *)®s->bp, | |
| 436 | 436 | (u32 __user __force *)(unsigned long)(u32)regs->sp) |
| 437 | 437 | #else |
| 438 | − get_user(*(u32 *)®s->cx, | |
| 438 | + get_user(*(u32 *)®s->bp, | |
| 439 | 439 | (u32 __user __force *)(unsigned long)(u32)regs->sp) |
| 440 | 440 | #endif |
| 441 | 441 | ) { |
| @@ -292,7 +292,7 @@ ENTRY(entry_SYSENTER_32) · 291 unmodified lines | ||
| 292 | 292 | movl TSS_sysenter_sp0(%esp), %esp |
| 293 | 293 | sysenter_past_esp: |
| 294 | 294 | pushl $__USER_DS /* pt_regs->ss */ |
| 295 | − pushl %ecx /* pt_regs->cx */ | |
| 295 | + pushl %ebp /* pt_regs->sp (stashed in bp) */ | |
| 296 | 296 | pushfl /* pt_regs->flags (except IF = 0) */ |
| 297 | 297 | orl $X86_EFLAGS_IF, (%esp) /* Fix IF */ |
| 298 | 298 | pushl $__USER_CS /* pt_regs->cs */ |
| @@ -308,8 +308,9 @@ sysenter_past_esp: · 9 unmodified lines | ||
| 308 | 308 | |
| 309 | 309 | movl %esp, %eax |
| 310 | 310 | call do_fast_syscall_32 |
| 311 | − testl %eax, %eax | |
| 312 | − jz .Lsyscall_32_done | |
| 311 | + /* XEN PV guests always use IRET path */ | |
| 312 | + ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \ | |
| 313 | + "jmp .Lsyscall_32_done", X86_FEATURE_XENPV | |
| 313 | 314 | |
| 314 | 315 | /* Opportunistic SYSEXIT */ |
| 315 | 316 | TRACE_IRQS_ON /* User mode traces as IRQs on. */ |
| @@ -63,7 +63,7 @@ ENTRY(entry_SYSENTER_compat) · 62 unmodified lines | ||
| 63 | 63 | |
| 64 | 64 | /* Construct struct pt_regs on stack */ |
| 65 | 65 | pushq $__USER32_DS /* pt_regs->ss */ |
| 66 | − pushq %rcx /* pt_regs->sp */ | |
| 66 | + pushq %rbp /* pt_regs->sp (stashed in bp) */ | |
| 67 | 67 | |
| 68 | 68 | /* |
| 69 | 69 | * Push flags. This is nasty. First, interrupts are currently |
| @@ -82,14 +82,14 @@ ENTRY(entry_SYSENTER_compat) · 12 unmodified lines | ||
| 82 | 82 | pushq %rdi /* pt_regs->di */ |
| 83 | 83 | pushq %rsi /* pt_regs->si */ |
| 84 | 84 | pushq %rdx /* pt_regs->dx */ |
| 85 | − pushq %rcx /* pt_regs->cx (will be overwritten) */ | |
| 85 | + pushq %rcx /* pt_regs->cx */ | |
| 86 | 86 | pushq $-ENOSYS /* pt_regs->ax */ |
| 87 | 87 | pushq %r8 /* pt_regs->r8 = 0 */ |
| 88 | 88 | pushq %r8 /* pt_regs->r9 = 0 */ |
| 89 | 89 | pushq %r8 /* pt_regs->r10 = 0 */ |
| 90 | 90 | pushq %r8 /* pt_regs->r11 = 0 */ |
| 91 | 91 | pushq %rbx /* pt_regs->rbx */ |
| 92 | − pushq %rbp /* pt_regs->rbp */ | |
| 92 | + pushq %rbp /* pt_regs->rbp (will be overwritten) */ | |
| 93 | 93 | pushq %r8 /* pt_regs->r12 = 0 */ |
| 94 | 94 | pushq %r8 /* pt_regs->r13 = 0 */ |
| 95 | 95 | pushq %r8 /* pt_regs->r14 = 0 */ |
| @@ -121,8 +121,9 @@ sysenter_flags_fixed: · 25 unmodified lines | ||
| 121 | 121 | |
| 122 | 122 | movq %rsp, %rdi |
| 123 | 123 | call do_fast_syscall_32 |
| 124 | − testl %eax, %eax | |
| 125 | − jz .Lsyscall_32_done | |
| 124 | + /* XEN PV guests always use IRET path */ | |
| 125 | + ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \ | |
| 126 | + "jmp .Lsyscall_32_done", X86_FEATURE_XENPV | |
| 126 | 127 | jmp sysret32_from_system_call |
| 127 | 128 | |
| 128 | 129 | sysenter_fix_flags: |
| @@ -178,7 +179,7 @@ ENTRY(entry_SYSCALL_compat) · 49 unmodified lines | ||
| 178 | 179 | pushq %rdi /* pt_regs->di */ |
| 179 | 180 | pushq %rsi /* pt_regs->si */ |
| 180 | 181 | pushq %rdx /* pt_regs->dx */ |
| 181 | − pushq %rcx /* pt_regs->cx (will be overwritten) */ | |
| 182 | + pushq %rbp /* pt_regs->cx (stashed in bp) */ | |
| 182 | 183 | pushq $-ENOSYS /* pt_regs->ax */ |
| 183 | 184 | xorq %r8,%r8 |
| 184 | 185 | pushq %r8 /* pt_regs->r8 = 0 */ |
| @@ -186,7 +187,7 @@ ENTRY(entry_SYSCALL_compat) · 1 unmodified line | ||
| 186 | 187 | pushq %r8 /* pt_regs->r10 = 0 */ |
| 187 | 188 | pushq %r8 /* pt_regs->r11 = 0 */ |
| 188 | 189 | pushq %rbx /* pt_regs->rbx */ |
| 189 | − pushq %rbp /* pt_regs->rbp */ | |
| 190 | + pushq %rbp /* pt_regs->rbp (will be overwritten) */ | |
| 190 | 191 | pushq %r8 /* pt_regs->r12 = 0 */ |
| 191 | 192 | pushq %r8 /* pt_regs->r13 = 0 */ |
| 192 | 193 | pushq %r8 /* pt_regs->r14 = 0 */ |
| @@ -200,8 +201,9 @@ ENTRY(entry_SYSCALL_compat) · 7 unmodified lines | ||
| 200 | 201 | |
| 201 | 202 | movq %rsp, %rdi |
| 202 | 203 | call do_fast_syscall_32 |
| 203 | − testl %eax, %eax | |
| 204 | − jz .Lsyscall_32_done | |
| 204 | + /* XEN PV guests always use IRET path */ | |
| 205 | + ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \ | |
| 206 | + "jmp .Lsyscall_32_done", X86_FEATURE_XENPV | |
| 205 | 207 | |
| 206 | 208 | /* Opportunistic SYSRET */ |
| 207 | 209 | sysret32_from_system_call: |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | − * Code for the vDSO. This version uses the old int $0x80 method. | |
| 2 | + * AT_SYSINFO entry point | |
| 3 | 3 | */ |
| 4 | 4 | |
| 5 | 5 | #include <asm/dwarf2.h> |
| @@ -21,35 +21,67 @@ __kernel_vsyscall: · 15 unmodified lines | ||
| 21 | 21 | /* |
| 22 | 22 | * Reshuffle regs so that all of any of the entry instructions |
| 23 | 23 | * will preserve enough state. |
| 24 | + * | |
| 25 | + * A really nice entry sequence would be: | |
| 26 | + * pushl %edx | |
| 27 | + * pushl %ecx | |
| 28 | + * movl %esp, %ecx | |
| 29 | + * | |
| 30 | + * Unfortunately, naughty Android versions between July and December | |
| 31 | + * 2015 actually hardcode the traditional Linux SYSENTER entry | |
| 32 | + * sequence. That is severely broken for a number of reasons (ask | |
| 33 | + * anyone with an AMD CPU, for example). Nonetheless, we try to keep | |
| 34 | + * it working approximately as well as it ever worked. | |
| 35 | + * | |
| 36 | + * This link may eludicate some of the history: | |
| 37 | + * https://android-review.googlesource.com/#/q/Iac3295376d61ef83e713ac9b528f3b50aa780cd7 | |
| 38 | + * personally, I find it hard to understand what's going on there. | |
| 39 | + * | |
| 40 | + * Note to future user developers: DO NOT USE SYSENTER IN YOUR CODE. | |
| 41 | + * Execute an indirect call to the address in the AT_SYSINFO auxv | |
| 42 | + * entry. That is the ONLY correct way to make a fast 32-bit system | |
| 43 | + * call on Linux. (Open-coding int $0x80 is also fine, but it's | |
| 44 | + * slow.) | |
| 24 | 45 | */ |
| 46 | + pushl %ecx | |
| 47 | + CFI_ADJUST_CFA_OFFSET 4 | |
| 48 | + CFI_REL_OFFSET ecx, 0 | |
| 25 | 49 | pushl %edx |
| 26 | 50 | CFI_ADJUST_CFA_OFFSET 4 |
| 27 | 51 | CFI_REL_OFFSET edx, 0 |
| 28 | − pushl %ecx | |
| 52 | + pushl %ebp | |
| 29 | 53 | CFI_ADJUST_CFA_OFFSET 4 |
| 30 | − CFI_REL_OFFSET ecx, 0 | |
| 31 | − movl %esp, %ecx | |
| 54 | + CFI_REL_OFFSET ebp, 0 | |
| 55 | + | |
| 56 | + #define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter" | |
| 57 | + #define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall" | |
| 32 | 58 | |
| 33 | 59 | #ifdef CONFIG_X86_64 |
| 34 | 60 | /* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */ |
| 35 | − ALTERNATIVE_2 "", "sysenter", X86_FEATURE_SYSENTER32, \ | |
| 36 | − "syscall", X86_FEATURE_SYSCALL32 | |
| 61 | + ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \ | |
| 62 | + SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32 | |
| 37 | 63 | #else |
| 38 | − ALTERNATIVE "", "sysenter", X86_FEATURE_SEP | |
| 64 | + ALTERNATIVE "", SYSENTER_SEQUENCE, X86_FEATURE_SEP | |
| 39 | 65 | #endif |
| 40 | 66 | |
| 41 | 67 | /* Enter using int $0x80 */ |
| 42 | − movl (%esp), %ecx | |
| 43 | 68 | int $0x80 |
| 44 | 69 | GLOBAL(int80_landing_pad) |
| 45 | 70 | |
| 46 | − /* Restore ECX and EDX in case they were clobbered. */ | |
| 47 | − popl %ecx | |
| 48 | − CFI_RESTORE ecx | |
| 71 | + /* | |
| 72 | + * Restore EDX and ECX in case they were clobbered. EBP is not | |
| 73 | + * clobbered (the kernel restores it), but it's cleaner and | |
| 74 | + * probably faster to pop it than to adjust ESP using addl. | |
| 75 | + */ | |
| 76 | + popl %ebp | |
| 77 | + CFI_RESTORE ebp | |
| 49 | 78 | CFI_ADJUST_CFA_OFFSET -4 |
| 50 | 79 | popl %edx |
| 51 | 80 | CFI_RESTORE edx |
| 52 | 81 | CFI_ADJUST_CFA_OFFSET -4 |
| 82 | + popl %ecx | |
| 83 | + CFI_RESTORE ecx | |
| 84 | + CFI_ADJUST_CFA_OFFSET -4 | |
| 53 | 85 | ret |
| 54 | 86 | CFI_ENDPROC |
| 55 | 87 | |
| @@ -216,6 +216,7 @@ · 215 unmodified lines | ||
| 216 | 216 | #define X86_FEATURE_PAUSEFILTER ( 8*32+13) /* AMD filtered pause intercept */ |
| 217 | 217 | #define X86_FEATURE_PFTHRESHOLD ( 8*32+14) /* AMD pause filter threshold */ |
| 218 | 218 | #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer vmmcall to vmcall */ |
| 219 | +#define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */ | |
| 219 | 220 | |
| 220 | 221 | |
| 221 | 222 | /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */ |
| @@ -19,6 +19,12 @@ static inline int paravirt_enabled(void) · 18 unmodified lines | ||
| 19 | 19 | return pv_info.paravirt_enabled; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | +static inline int paravirt_has_feature(unsigned int feature) | |
| 23 | +{ | |
| 24 | + WARN_ON_ONCE(!pv_info.paravirt_enabled); | |
| 25 | + return (pv_info.features & feature); | |
| 26 | +} | |
| 27 | + | |
| 22 | 28 | static inline void load_sp0(struct tss_struct *tss, |
| 23 | 29 | struct thread_struct *thread) |
| 24 | 30 | { |
| @@ -70,9 +70,14 @@ struct pv_info { · 69 unmodified lines | ||
| 70 | 70 | #endif |
| 71 | 71 | |
| 72 | 72 | int paravirt_enabled; |
| 73 | + unsigned int features; /* valid only if paravirt_enabled is set */ | |
| 73 | 74 | const char *name; |
| 74 | 75 | }; |
| 75 | 76 | |
| 77 | +#define paravirt_has(x) paravirt_has_feature(PV_SUPPORTED_##x) | |
| 78 | +/* Supported features */ | |
| 79 | +#define PV_SUPPORTED_RTC (1<<0) | |
| 80 | + | |
| 76 | 81 | struct pv_init_ops { |
| 77 | 82 | /* |
| 78 | 83 | * Patch may replace one of the defined code sequences with |
| @@ -472,6 +472,7 @@ static inline unsigned long current_top_of_stack(void) · 471 unmodified lines | ||
| 472 | 472 | #else |
| 473 | 473 | #define __cpuid native_cpuid |
| 474 | 474 | #define paravirt_enabled() 0 |
| 475 | +#define paravirt_has(x) 0 | |
| 475 | 476 | |
| 476 | 477 | static inline void load_sp0(struct tss_struct *tss, |
| 477 | 478 | struct thread_struct *thread) |
| @@ -193,20 +193,17 @@ static int __init numachip_system_init(void) · 192 unmodified lines | ||
| 193 | 193 | case 1: |
| 194 | 194 | init_extra_mapping_uc(NUMACHIP_LCSR_BASE, NUMACHIP_LCSR_SIZE); |
| 195 | 195 | numachip_apic_icr_write = numachip1_apic_icr_write; |
| 196 | − x86_init.pci.arch_init = pci_numachip_init; | |
| 197 | 196 | break; |
| 198 | 197 | case 2: |
| 199 | 198 | init_extra_mapping_uc(NUMACHIP2_LCSR_BASE, NUMACHIP2_LCSR_SIZE); |
| 200 | 199 | numachip_apic_icr_write = numachip2_apic_icr_write; |
| 201 | − | |
| 202 | − /* Use MCFG config cycles rather than locked CF8 cycles */ | |
| 203 | − raw_pci_ops = &pci_mmcfg; | |
| 204 | 200 | break; |
| 205 | 201 | default: |
| 206 | 202 | return 0; |
| 207 | 203 | } |
| 208 | 204 | |
| 209 | 205 | x86_cpuinit.fixup_cpu_id = fixup_cpu_id; |
| 206 | + x86_init.pci.arch_init = pci_numachip_init; | |
| 210 | 207 | |
| 211 | 208 | return 0; |
| 212 | 209 | } |
| @@ -999,6 +999,17 @@ void do_machine_check(struct pt_regs *regs, long error_code) · 998 unmodified lines | ||
| 999 | 999 | int flags = MF_ACTION_REQUIRED; |
| 1000 | 1000 | int lmce = 0; |
| 1001 | 1001 | |
| 1002 | + /* If this CPU is offline, just bail out. */ | |
| 1003 | + if (cpu_is_offline(smp_processor_id())) { | |
| 1004 | + u64 mcgstatus; | |
| 1005 | + | |
| 1006 | + mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS); | |
| 1007 | + if (mcgstatus & MCG_STATUS_RIPV) { | |
| 1008 | + mce_wrmsrl(MSR_IA32_MCG_STATUS, 0); | |
| 1009 | + return; | |
| 1010 | + } | |
| 1011 | + } | |
| 1012 | + | |
| 1002 | 1013 | ist_enter(regs); |
| 1003 | 1014 | |
| 1004 | 1015 | this_cpu_inc(mce_exception_count); |
| @@ -200,6 +200,9 @@ static __init int add_rtc_cmos(void) · 199 unmodified lines | ||
| 200 | 200 | } |
| 201 | 201 | #endif |
| 202 | 202 | |
| 203 | + if (paravirt_enabled() && !paravirt_has(RTC)) | |
| 204 | + return -ENODEV; | |
| 205 | + | |
| 203 | 206 | platform_device_register(&rtc_device); |
| 204 | 207 | dev_info(&rtc_device.dev, |
| 205 | 208 | "registered platform RTC device (no PNP device found)\n"); |
| @@ -38,6 +38,14 @@ static inline bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu) · 37 unmodified lines | ||
| 38 | 38 | return best && (best->ecx & bit(X86_FEATURE_XSAVE)); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | +static inline bool guest_cpuid_has_mtrr(struct kvm_vcpu *vcpu) | |
| 42 | +{ | |
| 43 | + struct kvm_cpuid_entry2 *best; | |
| 44 | + | |
| 45 | + best = kvm_find_cpuid_entry(vcpu, 1, 0); | |
| 46 | + return best && (best->edx & bit(X86_FEATURE_MTRR)); | |
| 47 | +} | |
| 48 | + | |
| 41 | 49 | static inline bool guest_cpuid_has_tsc_adjust(struct kvm_vcpu *vcpu) |
| 42 | 50 | { |
| 43 | 51 | struct kvm_cpuid_entry2 *best; |
| @@ -420,6 +420,7 @@ void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val, int hpet_legacy_s · 419 unmodified lines | ||
| 420 | 420 | u8 saved_mode; |
| 421 | 421 | if (hpet_legacy_start) { |
| 422 | 422 | /* save existing mode for later reenablement */ |
| 423 | + WARN_ON(channel != 0); | |
| 423 | 424 | saved_mode = kvm->arch.vpit->pit_state.channels[0].mode; |
| 424 | 425 | kvm->arch.vpit->pit_state.channels[0].mode = 0xff; /* disable timer */ |
| 425 | 426 | pit_load_count(kvm, channel, val); |
| @@ -120,14 +120,22 @@ static u8 mtrr_default_type(struct kvm_mtrr *mtrr_state) · 119 unmodified lines | ||
| 120 | 120 | return mtrr_state->deftype & IA32_MTRR_DEF_TYPE_TYPE_MASK; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | −static u8 mtrr_disabled_type(void) | |
| 123 | +static u8 mtrr_disabled_type(struct kvm_vcpu *vcpu) | |
| 124 | 124 | { |
| 125 | 125 | /* |
| 126 | 126 | * Intel SDM 11.11.2.2: all MTRRs are disabled when |
| 127 | 127 | * IA32_MTRR_DEF_TYPE.E bit is cleared, and the UC |
| 128 | 128 | * memory type is applied to all of physical memory. |
| 129 | + * | |
| 130 | + * However, virtual machines can be run with CPUID such that | |
| 131 | + * there are no MTRRs. In that case, the firmware will never | |
| 132 | + * enable MTRRs and it is obviously undesirable to run the | |
| 133 | + * guest entirely with UC memory and we use WB. | |
| 129 | 134 | */ |
| 130 | − return MTRR_TYPE_UNCACHABLE; | |
| 135 | + if (guest_cpuid_has_mtrr(vcpu)) | |
| 136 | + return MTRR_TYPE_UNCACHABLE; | |
| 137 | + else | |
| 138 | + return MTRR_TYPE_WRBACK; | |
| 131 | 139 | } |
| 132 | 140 | |
| 133 | 141 | /* |
| @@ -267,7 +275,7 @@ static int fixed_mtrr_addr_to_seg(u64 addr) · 133 unmodified lines | ||
| 267 | 275 | |
| 268 | 276 | for (seg = 0; seg < seg_num; seg++) { |
| 269 | 277 | mtrr_seg = &fixed_seg_table[seg]; |
| 270 | − if (mtrr_seg->start >= addr && addr < mtrr_seg->end) | |
| 278 | + if (mtrr_seg->start <= addr && addr < mtrr_seg->end) | |
| 271 | 279 | return seg; |
| 272 | 280 | } |
| 273 | 281 | |
| @@ -300,7 +308,6 @@ static void var_mtrr_range(struct kvm_mtrr_range *range, u64 *start, u64 *end) · 26 unmodified lines | ||
| 300 | 308 | *start = range->base & PAGE_MASK; |
| 301 | 309 | |
| 302 | 310 | mask = range->mask & PAGE_MASK; |
| 303 | − mask |= ~0ULL << boot_cpu_data.x86_phys_bits; | |
| 304 | 311 | |
| 305 | 312 | /* This cannot overflow because writing to the reserved bits of |
| 306 | 313 | * variable MTRRs causes a #GP. |
| @@ -356,10 +363,14 @@ static void set_var_mtrr_msr(struct kvm_vcpu *vcpu, u32 msr, u64 data) · 49 unmodified lines | ||
| 356 | 363 | if (var_mtrr_range_is_valid(cur)) |
| 357 | 364 | list_del(&mtrr_state->var_ranges[index].node); |
| 358 | 365 | |
| 366 | + /* Extend the mask with all 1 bits to the left, since those | |
| 367 | + * bits must implicitly be 0. The bits are then cleared | |
| 368 | + * when reading them. | |
| 369 | + */ | |
| 359 | 370 | if (!is_mtrr_mask) |
| 360 | 371 | cur->base = data; |
| 361 | 372 | else |
| 362 | − cur->mask = data; | |
| 373 | + cur->mask = data | (-1LL << cpuid_maxphyaddr(vcpu)); | |
| 363 | 374 | |
| 364 | 375 | /* add it to the list if it's enabled. */ |
| 365 | 376 | if (var_mtrr_range_is_valid(cur)) { |
| @@ -426,6 +437,8 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata) · 60 unmodified lines | ||
| 426 | 437 | *pdata = vcpu->arch.mtrr_state.var_ranges[index].base; |
| 427 | 438 | else |
| 428 | 439 | *pdata = vcpu->arch.mtrr_state.var_ranges[index].mask; |
| 440 | + | |
| 441 | + *pdata &= (1ULL << cpuid_maxphyaddr(vcpu)) - 1; | |
| 429 | 442 | } |
| 430 | 443 | |
| 431 | 444 | return 0; |
| @@ -670,7 +683,7 @@ u8 kvm_mtrr_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn) · 238 unmodified lines | ||
| 670 | 683 | } |
| 671 | 684 | |
| 672 | 685 | if (iter.mtrr_disabled) |
| 673 | − return mtrr_disabled_type(); | |
| 686 | + return mtrr_disabled_type(vcpu); | |
| 674 | 687 | |
| 675 | 688 | /* not contained in any MTRRs. */ |
| 676 | 689 | if (type == -1) |
| @@ -3422,6 +3422,8 @@ static int handle_exit(struct kvm_vcpu *vcpu) · 3421 unmodified lines | ||
| 3422 | 3422 | struct kvm_run *kvm_run = vcpu->run; |
| 3423 | 3423 | u32 exit_code = svm->vmcb->control.exit_code; |
| 3424 | 3424 | |
| 3425 | + trace_kvm_exit(exit_code, vcpu, KVM_ISA_SVM); | |
| 3426 | + | |
| 3425 | 3427 | if (!is_cr_intercept(svm, INTERCEPT_CR0_WRITE)) |
| 3426 | 3428 | vcpu->arch.cr0 = svm->vmcb->save.cr0; |
| 3427 | 3429 | if (npt_enabled) |
| @@ -3892,8 +3894,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) · 464 unmodified lines | ||
| 3892 | 3894 | vcpu->arch.regs[VCPU_REGS_RSP] = svm->vmcb->save.rsp; |
| 3893 | 3895 | vcpu->arch.regs[VCPU_REGS_RIP] = svm->vmcb->save.rip; |
| 3894 | 3896 | |
| 3895 | − trace_kvm_exit(svm->vmcb->control.exit_code, vcpu, KVM_ISA_SVM); | |
| 3896 | − | |
| 3897 | 3897 | if (unlikely(svm->vmcb->control.exit_code == SVM_EXIT_NMI)) |
| 3898 | 3898 | kvm_before_handle_nmi(&svm->vcpu); |
| 3899 | 3899 | |
| @@ -2803,7 +2803,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) · 2802 unmodified lines | ||
| 2803 | 2803 | msr_info->data = vcpu->arch.ia32_xss; |
| 2804 | 2804 | break; |
| 2805 | 2805 | case MSR_TSC_AUX: |
| 2806 | − if (!guest_cpuid_has_rdtscp(vcpu)) | |
| 2806 | + if (!guest_cpuid_has_rdtscp(vcpu) && !msr_info->host_initiated) | |
| 2807 | 2807 | return 1; |
| 2808 | 2808 | /* Otherwise falls through */ |
| 2809 | 2809 | default: |
| @@ -2909,7 +2909,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) · 99 unmodified lines | ||
| 2909 | 2909 | clear_atomic_switch_msr(vmx, MSR_IA32_XSS); |
| 2910 | 2910 | break; |
| 2911 | 2911 | case MSR_TSC_AUX: |
| 2912 | − if (!guest_cpuid_has_rdtscp(vcpu)) | |
| 2912 | + if (!guest_cpuid_has_rdtscp(vcpu) && !msr_info->host_initiated) | |
| 2913 | 2913 | return 1; |
| 2914 | 2914 | /* Check reserved bit, higher 32 bits should be zero */ |
| 2915 | 2915 | if ((data >> 32) != 0) |
| @@ -8042,6 +8042,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu) · 5126 unmodified lines | ||
| 8042 | 8042 | u32 exit_reason = vmx->exit_reason; |
| 8043 | 8043 | u32 vectoring_info = vmx->idt_vectoring_info; |
| 8044 | 8044 | |
| 8045 | + trace_kvm_exit(exit_reason, vcpu, KVM_ISA_VMX); | |
| 8046 | + | |
| 8045 | 8047 | /* |
| 8046 | 8048 | * Flush logged GPAs PML buffer, this will make dirty_bitmap more |
| 8047 | 8049 | * updated. Another good is, in kvm_vm_ioctl_get_dirty_log, before |
| @@ -8668,7 +8670,6 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) · 620 unmodified lines | ||
| 8668 | 8670 | vmx->loaded_vmcs->launched = 1; |
| 8669 | 8671 | |
| 8670 | 8672 | vmx->exit_reason = vmcs_read32(VM_EXIT_REASON); |
| 8671 | − trace_kvm_exit(vmx->exit_reason, vcpu, KVM_ISA_VMX); | |
| 8672 | 8673 | |
| 8673 | 8674 | /* |
| 8674 | 8675 | * the KVM_REQ_EVENT optimization bit is only on for one entry, and if |
| @@ -3572,9 +3572,11 @@ static int kvm_vm_ioctl_get_pit(struct kvm *kvm, struct kvm_pit_state *ps) · 3571 unmodified lines | ||
| 3572 | 3572 | |
| 3573 | 3573 | static int kvm_vm_ioctl_set_pit(struct kvm *kvm, struct kvm_pit_state *ps) |
| 3574 | 3574 | { |
| 3575 | + int i; | |
| 3575 | 3576 | mutex_lock(&kvm->arch.vpit->pit_state.lock); |
| 3576 | 3577 | memcpy(&kvm->arch.vpit->pit_state, ps, sizeof(struct kvm_pit_state)); |
| 3577 | − kvm_pit_load_count(kvm, 0, ps->channels[0].count, 0); | |
| 3578 | + for (i = 0; i < 3; i++) | |
| 3579 | + kvm_pit_load_count(kvm, i, ps->channels[i].count, 0); | |
| 3578 | 3580 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); |
| 3579 | 3581 | return 0; |
| 3580 | 3582 | } |
| @@ -3593,6 +3595,7 @@ static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) · 12 unmodified lines | ||
| 3593 | 3595 | static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) |
| 3594 | 3596 | { |
| 3595 | 3597 | int start = 0; |
| 3598 | + int i; | |
| 3596 | 3599 | u32 prev_legacy, cur_legacy; |
| 3597 | 3600 | mutex_lock(&kvm->arch.vpit->pit_state.lock); |
| 3598 | 3601 | prev_legacy = kvm->arch.vpit->pit_state.flags & KVM_PIT_FLAGS_HPET_LEGACY; |
| @@ -3602,7 +3605,9 @@ static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) · 3 unmodified lines | ||
| 3602 | 3605 | memcpy(&kvm->arch.vpit->pit_state.channels, &ps->channels, |
| 3603 | 3606 | sizeof(kvm->arch.vpit->pit_state.channels)); |
| 3604 | 3607 | kvm->arch.vpit->pit_state.flags = ps->flags; |
| 3605 | − kvm_pit_load_count(kvm, 0, kvm->arch.vpit->pit_state.channels[0].count, start); | |
| 3608 | + for (i = 0; i < 3; i++) | |
| 3609 | + kvm_pit_load_count(kvm, i, kvm->arch.vpit->pit_state.channels[i].count, | |
| 3610 | + start && i == 0); | |
| 3606 | 3611 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); |
| 3607 | 3612 | return 0; |
| 3608 | 3613 | } |
| @@ -6515,6 +6520,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) · 2906 unmodified lines | ||
| 6515 | 6520 | if (req_immediate_exit) |
| 6516 | 6521 | smp_send_reschedule(vcpu->cpu); |
| 6517 | 6522 | |
| 6523 | + trace_kvm_entry(vcpu->vcpu_id); | |
| 6524 | + wait_lapic_expire(vcpu); | |
| 6518 | 6525 | __kvm_guest_enter(); |
| 6519 | 6526 | |
| 6520 | 6527 | if (unlikely(vcpu->arch.switch_db_regs)) { |
| @@ -6527,8 +6534,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) · 6 unmodified lines | ||
| 6527 | 6534 | vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD; |
| 6528 | 6535 | } |
| 6529 | 6536 | |
| 6530 | − trace_kvm_entry(vcpu->vcpu_id); | |
| 6531 | − wait_lapic_expire(vcpu); | |
| 6532 | 6537 | kvm_x86_ops->run(vcpu); |
| 6533 | 6538 | |
| 6534 | 6539 | /* |
| @@ -1414,6 +1414,7 @@ __init void lguest_init(void) · 1413 unmodified lines | ||
| 1414 | 1414 | pv_info.kernel_rpl = 1; |
| 1415 | 1415 | /* Everyone except Xen runs with this set. */ |
| 1416 | 1416 | pv_info.shared_kernel_pmd = 1; |
| 1417 | + pv_info.features = 0; | |
| 1417 | 1418 | |
| 1418 | 1419 | /* |
| 1419 | 1420 | * We set up all the lguest overrides for sensitive operations. These |
| @@ -89,7 +89,7 @@ static struct addr_marker address_markers[] = { · 88 unmodified lines | ||
| 89 | 89 | { 0/* VMALLOC_START */, "vmalloc() Area" }, |
| 90 | 90 | { 0/*VMALLOC_END*/, "vmalloc() End" }, |
| 91 | 91 | # ifdef CONFIG_HIGHMEM |
| 92 | − { 0/*PKMAP_BASE*/, "Persisent kmap() Area" }, | |
| 92 | + { 0/*PKMAP_BASE*/, "Persistent kmap() Area" }, | |
| 93 | 93 | # endif |
| 94 | 94 | { 0/*FIXADDR_START*/, "Fixmap Area" }, |
| 95 | 95 | #endif |
| @@ -470,7 +470,7 @@ long sys_sigreturn(void) · 469 unmodified lines | ||
| 470 | 470 | struct sigcontext __user *sc = &frame->sc; |
| 471 | 471 | int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long); |
| 472 | 472 | |
| 473 | − if (copy_from_user(&set.sig[0], (void *)sc->oldmask, sizeof(set.sig[0])) || | |
| 473 | + if (copy_from_user(&set.sig[0], &sc->oldmask, sizeof(set.sig[0])) || | |
| 474 | 474 | copy_from_user(&set.sig[1], frame->extramask, sig_size)) |
| 475 | 475 | goto segfault; |
| 476 | 476 | |
| @@ -1192,7 +1192,7 @@ static const struct pv_info xen_info __initconst = { · 1191 unmodified lines | ||
| 1192 | 1192 | #ifdef CONFIG_X86_64 |
| 1193 | 1193 | .extra_user_64bit_cs = FLAT_USER_CS64, |
| 1194 | 1194 | #endif |
| 1195 | − | |
| 1195 | + .features = 0, | |
| 1196 | 1196 | .name = "Xen", |
| 1197 | 1197 | }; |
| 1198 | 1198 | |
| @@ -1535,6 +1535,8 @@ asmlinkage __visible void __init xen_start_kernel(void) · 336 unmodified lines | ||
| 1535 | 1535 | |
| 1536 | 1536 | /* Install Xen paravirt ops */ |
| 1537 | 1537 | pv_info = xen_info; |
| 1538 | + if (xen_initial_domain()) | |
| 1539 | + pv_info.features |= PV_SUPPORTED_RTC; | |
| 1538 | 1540 | pv_init_ops = xen_init_ops; |
| 1539 | 1541 | pv_apic_ops = xen_apic_ops; |
| 1540 | 1542 | if (!xen_pvh_domain()) { |
| @@ -1886,8 +1888,10 @@ EXPORT_SYMBOL_GPL(xen_hvm_need_lapic); · 345 unmodified lines | ||
| 1886 | 1888 | |
| 1887 | 1889 | static void xen_set_cpu_features(struct cpuinfo_x86 *c) |
| 1888 | 1890 | { |
| 1889 | − if (xen_pv_domain()) | |
| 1891 | + if (xen_pv_domain()) { | |
| 1890 | 1892 | clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS); |
| 1893 | + set_cpu_cap(c, X86_FEATURE_XENPV); | |
| 1894 | + } | |
| 1891 | 1895 | } |
| 1892 | 1896 | |
| 1893 | 1897 | const struct hypervisor_x86 x86_hyper_xen = { |
| @@ -2495,14 +2495,9 @@ void __init xen_init_mmu_ops(void) · 2494 unmodified lines | ||
| 2495 | 2495 | { |
| 2496 | 2496 | x86_init.paging.pagetable_init = xen_pagetable_init; |
| 2497 | 2497 | |
| 2498 | − /* Optimization - we can use the HVM one but it has no idea which | |
| 2499 | − * VCPUs are descheduled - which means that it will needlessly IPI | |
| 2500 | − * them. Xen knows so let it do the job. | |
| 2501 | − */ | |
| 2502 | − if (xen_feature(XENFEAT_auto_translated_physmap)) { | |
| 2503 | − pv_mmu_ops.flush_tlb_others = xen_flush_tlb_others; | |
| 2498 | + if (xen_feature(XENFEAT_auto_translated_physmap)) | |
| 2504 | 2499 | return; |
| 2505 | − } | |
| 2500 | + | |
| 2506 | 2501 | pv_mmu_ops = xen_mmu_ops; |
| 2507 | 2502 | |
| 2508 | 2503 | memset(dummy_mapping, 0xff, PAGE_SIZE); |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | #include <linux/types.h> |
| 2 | 2 | #include <linux/tick.h> |
| 3 | 3 | |
| 4 | +#include <xen/xen.h> | |
| 4 | 5 | #include <xen/interface/xen.h> |
| 5 | 6 | #include <xen/grant_table.h> |
| 6 | 7 | #include <xen/events.h> |
| @@ -68,26 +69,16 @@ static void xen_pv_post_suspend(int suspend_cancelled) · 61 unmodified lines | ||
| 68 | 69 | |
| 69 | 70 | void xen_arch_pre_suspend(void) |
| 70 | 71 | { |
| 71 | − int cpu; | |
| 72 | − | |
| 73 | − for_each_online_cpu(cpu) | |
| 74 | − xen_pmu_finish(cpu); | |
| 75 | − | |
| 76 | 72 | if (xen_pv_domain()) |
| 77 | 73 | xen_pv_pre_suspend(); |
| 78 | 74 | } |
| 79 | 75 | |
| 80 | 76 | void xen_arch_post_suspend(int cancelled) |
| 81 | 77 | { |
| 82 | − int cpu; | |
| 83 | − | |
| 84 | 78 | if (xen_pv_domain()) |
| 85 | 79 | xen_pv_post_suspend(cancelled); |
| 86 | 80 | else |
| 87 | 81 | xen_hvm_post_suspend(cancelled); |
| 88 | − | |
| 89 | − for_each_online_cpu(cpu) | |
| 90 | − xen_pmu_init(cpu); | |
| 91 | 82 | } |
| 92 | 83 | |
| 93 | 84 | static void xen_vcpu_notify_restore(void *data) |
| @@ -106,10 +97,20 @@ static void xen_vcpu_notify_suspend(void *data) · 12 unmodified lines | ||
| 106 | 97 | |
| 107 | 98 | void xen_arch_resume(void) |
| 108 | 99 | { |
| 100 | + int cpu; | |
| 101 | + | |
| 109 | 102 | on_each_cpu(xen_vcpu_notify_restore, NULL, 1); |
| 103 | + | |
| 104 | + for_each_online_cpu(cpu) | |
| 105 | + xen_pmu_init(cpu); | |
| 110 | 106 | } |
| 111 | 107 | |
| 112 | 108 | void xen_arch_suspend(void) |
| 113 | 109 | { |
| 110 | + int cpu; | |
| 111 | + | |
| 112 | + for_each_online_cpu(cpu) | |
| 113 | + xen_pmu_finish(cpu); | |
| 114 | + | |
| 114 | 115 | on_each_cpu(xen_vcpu_notify_suspend, NULL, 1); |
| 115 | 116 | } |
| @@ -206,6 +206,22 @@ void blk_delay_queue(struct request_queue *q, unsigned long msecs) · 205 unmodified lines | ||
| 206 | 206 | } |
| 207 | 207 | EXPORT_SYMBOL(blk_delay_queue); |
| 208 | 208 | |
| 209 | +/** | |
| 210 | + * blk_start_queue_async - asynchronously restart a previously stopped queue | |
| 211 | + * @q: The &struct request_queue in question | |
| 212 | + * | |
| 213 | + * Description: | |
| 214 | + * blk_start_queue_async() will clear the stop flag on the queue, and | |
| 215 | + * ensure that the request_fn for the queue is run from an async | |
| 216 | + * context. | |
| 217 | + **/ | |
| 218 | +void blk_start_queue_async(struct request_queue *q) | |
| 219 | +{ | |
| 220 | + queue_flag_clear(QUEUE_FLAG_STOPPED, q); | |
| 221 | + blk_run_queue_async(q); | |
| 222 | +} | |
| 223 | +EXPORT_SYMBOL(blk_start_queue_async); | |
| 224 | + | |
| 209 | 225 | /** |
| 210 | 226 | * blk_start_queue - restart a previously stopped queue |
| 211 | 227 | * @q: The &struct request_queue in question |
| @@ -1689,8 +1705,6 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio) · 1477 unmodified lines | ||
| 1689 | 1705 | struct request *req; |
| 1690 | 1706 | unsigned int request_count = 0; |
| 1691 | 1707 | |
| 1692 | − blk_queue_split(q, &bio, q->bio_split); | |
| 1693 | − | |
| 1694 | 1708 | /* |
| 1695 | 1709 | * low level driver can indicate that it wants pages above a |
| 1696 | 1710 | * certain limit bounced to low memory (ie for highmem, or even |
| @@ -1698,6 +1712,8 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio) · 1 unmodified line | ||
| 1698 | 1712 | */ |
| 1699 | 1713 | blk_queue_bounce(q, &bio); |
| 1700 | 1714 | |
| 1715 | + blk_queue_split(q, &bio, q->bio_split); | |
| 1716 | + | |
| 1701 | 1717 | if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) { |
| 1702 | 1718 | bio->bi_error = -EIO; |
| 1703 | 1719 | bio_endio(bio); |
| @@ -277,12 +277,12 @@ static int ablkcipher_walk_first(struct ablkcipher_request *req, · 276 unmodified lines | ||
| 277 | 277 | if (WARN_ON_ONCE(in_irq())) |
| 278 | 278 | return -EDEADLK; |
| 279 | 279 | |
| 280 | + walk->iv = req->info; | |
| 280 | 281 | walk->nbytes = walk->total; |
| 281 | 282 | if (unlikely(!walk->total)) |
| 282 | 283 | return 0; |
| 283 | 284 | |
| 284 | 285 | walk->iv_buffer = NULL; |
| 285 | − walk->iv = req->info; | |
| 286 | 286 | if (unlikely(((unsigned long)walk->iv & alignmask))) { |
| 287 | 287 | int err = ablkcipher_copy_iv(walk, tfm, alignmask); |
| 288 | 288 | |
| @@ -47,7 +47,7 @@ struct skcipher_ctx { · 46 unmodified lines | ||
| 47 | 47 | bool merge; |
| 48 | 48 | bool enc; |
| 49 | 49 | |
| 50 | − struct ablkcipher_request req; | |
| 50 | + struct skcipher_request req; | |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | 53 | struct skcipher_async_rsgl { |
| @@ -64,13 +64,13 @@ struct skcipher_async_req { · 10 unmodified lines | ||
| 64 | 64 | }; |
| 65 | 65 | |
| 66 | 66 | #define GET_SREQ(areq, ctx) (struct skcipher_async_req *)((char *)areq + \ |
| 67 | − crypto_ablkcipher_reqsize(crypto_ablkcipher_reqtfm(&ctx->req))) | |
| 67 | + crypto_skcipher_reqsize(crypto_skcipher_reqtfm(&ctx->req))) | |
| 68 | 68 | |
| 69 | 69 | #define GET_REQ_SIZE(ctx) \ |
| 70 | − crypto_ablkcipher_reqsize(crypto_ablkcipher_reqtfm(&ctx->req)) | |
| 70 | + crypto_skcipher_reqsize(crypto_skcipher_reqtfm(&ctx->req)) | |
| 71 | 71 | |
| 72 | 72 | #define GET_IV_SIZE(ctx) \ |
| 73 | − crypto_ablkcipher_ivsize(crypto_ablkcipher_reqtfm(&ctx->req)) | |
| 73 | + crypto_skcipher_ivsize(crypto_skcipher_reqtfm(&ctx->req)) | |
| 74 | 74 | |
| 75 | 75 | #define MAX_SGL_ENTS ((4096 - sizeof(struct skcipher_sg_list)) / \ |
| 76 | 76 | sizeof(struct scatterlist) - 1) |
| @@ -302,8 +302,8 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg, · 225 unmodified lines | ||
| 302 | 302 | struct sock *sk = sock->sk; |
| 303 | 303 | struct alg_sock *ask = alg_sk(sk); |
| 304 | 304 | struct skcipher_ctx *ctx = ask->private; |
| 305 | − struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(&ctx->req); | |
| 306 | − unsigned ivsize = crypto_ablkcipher_ivsize(tfm); | |
| 305 | + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(&ctx->req); | |
| 306 | + unsigned ivsize = crypto_skcipher_ivsize(tfm); | |
| 307 | 307 | struct skcipher_sg_list *sgl; |
| 308 | 308 | struct af_alg_control con = {}; |
| 309 | 309 | long copied = 0; |
| @@ -507,7 +507,7 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, · 197 unmodified lines | ||
| 507 | 507 | struct skcipher_sg_list *sgl; |
| 508 | 508 | struct scatterlist *sg; |
| 509 | 509 | struct skcipher_async_req *sreq; |
| 510 | − struct ablkcipher_request *req; | |
| 510 | + struct skcipher_request *req; | |
| 511 | 511 | struct skcipher_async_rsgl *last_rsgl = NULL; |
| 512 | 512 | unsigned int txbufs = 0, len = 0, tx_nents = skcipher_all_sg_nents(ctx); |
| 513 | 513 | unsigned int reqlen = sizeof(struct skcipher_async_req) + |
| @@ -531,9 +531,9 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, · 17 unmodified lines | ||
| 531 | 531 | } |
| 532 | 532 | sg_init_table(sreq->tsg, tx_nents); |
| 533 | 533 | memcpy(sreq->iv, ctx->iv, GET_IV_SIZE(ctx)); |
| 534 | − ablkcipher_request_set_tfm(req, crypto_ablkcipher_reqtfm(&ctx->req)); | |
| 535 | − ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, | |
| 536 | − skcipher_async_cb, sk); | |
| 534 | + skcipher_request_set_tfm(req, crypto_skcipher_reqtfm(&ctx->req)); | |
| 535 | + skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, | |
| 536 | + skcipher_async_cb, sk); | |
| 537 | 537 | |
| 538 | 538 | while (iov_iter_count(&msg->msg_iter)) { |
| 539 | 539 | struct skcipher_async_rsgl *rsgl; |
| @@ -608,10 +608,10 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, · 68 unmodified lines | ||
| 608 | 608 | if (mark) |
| 609 | 609 | sg_mark_end(sreq->tsg + txbufs - 1); |
| 610 | 610 | |
| 611 | − ablkcipher_request_set_crypt(req, sreq->tsg, sreq->first_sgl.sgl.sg, | |
| 612 | − len, sreq->iv); | |
| 613 | − err = ctx->enc ? crypto_ablkcipher_encrypt(req) : | |
| 614 | − crypto_ablkcipher_decrypt(req); | |
| 611 | + skcipher_request_set_crypt(req, sreq->tsg, sreq->first_sgl.sgl.sg, | |
| 612 | + len, sreq->iv); | |
| 613 | + err = ctx->enc ? crypto_skcipher_encrypt(req) : | |
| 614 | + crypto_skcipher_decrypt(req); | |
| 615 | 615 | if (err == -EINPROGRESS) { |
| 616 | 616 | atomic_inc(&ctx->inflight); |
| 617 | 617 | err = -EIOCBQUEUED; |
| @@ -632,7 +632,7 @@ static int skcipher_recvmsg_sync(struct socket *sock, struct msghdr *msg, · 14 unmodified lines | ||
| 632 | 632 | struct sock *sk = sock->sk; |
| 633 | 633 | struct alg_sock *ask = alg_sk(sk); |
| 634 | 634 | struct skcipher_ctx *ctx = ask->private; |
| 635 | − unsigned bs = crypto_ablkcipher_blocksize(crypto_ablkcipher_reqtfm( | |
| 635 | + unsigned bs = crypto_skcipher_blocksize(crypto_skcipher_reqtfm( | |
| 636 | 636 | &ctx->req)); |
| 637 | 637 | struct skcipher_sg_list *sgl; |
| 638 | 638 | struct scatterlist *sg; |
| @@ -669,14 +669,13 @@ static int skcipher_recvmsg_sync(struct socket *sock, struct msghdr *msg, · 30 unmodified lines | ||
| 669 | 669 | if (!used) |
| 670 | 670 | goto free; |
| 671 | 671 | |
| 672 | − ablkcipher_request_set_crypt(&ctx->req, sg, | |
| 673 | − ctx->rsgl.sg, used, | |
| 674 | − ctx->iv); | |
| 672 | + skcipher_request_set_crypt(&ctx->req, sg, ctx->rsgl.sg, used, | |
| 673 | + ctx->iv); | |
| 675 | 674 | |
| 676 | 675 | err = af_alg_wait_for_completion( |
| 677 | 676 | ctx->enc ? |
| 678 | − crypto_ablkcipher_encrypt(&ctx->req) : | |
| 679 | − crypto_ablkcipher_decrypt(&ctx->req), | |
| 677 | + crypto_skcipher_encrypt(&ctx->req) : | |
| 678 | + crypto_skcipher_decrypt(&ctx->req), | |
| 680 | 679 | &ctx->completion); |
| 681 | 680 | |
| 682 | 681 | free: |
| @@ -751,17 +750,17 @@ static struct proto_ops algif_skcipher_ops = { · 68 unmodified lines | ||
| 751 | 750 | |
| 752 | 751 | static void *skcipher_bind(const char *name, u32 type, u32 mask) |
| 753 | 752 | { |
| 754 | − return crypto_alloc_ablkcipher(name, type, mask); | |
| 753 | + return crypto_alloc_skcipher(name, type, mask); | |
| 755 | 754 | } |
| 756 | 755 | |
| 757 | 756 | static void skcipher_release(void *private) |
| 758 | 757 | { |
| 759 | − crypto_free_ablkcipher(private); | |
| 758 | + crypto_free_skcipher(private); | |
| 760 | 759 | } |
| 761 | 760 | |
| 762 | 761 | static int skcipher_setkey(void *private, const u8 *key, unsigned int keylen) |
| 763 | 762 | { |
| 764 | − return crypto_ablkcipher_setkey(private, key, keylen); | |
| 763 | + return crypto_skcipher_setkey(private, key, keylen); | |
| 765 | 764 | } |
| 766 | 765 | |
| 767 | 766 | static void skcipher_wait(struct sock *sk) |
| @@ -778,13 +777,13 @@ static void skcipher_sock_destruct(struct sock *sk) · 10 unmodified lines | ||
| 778 | 777 | { |
| 779 | 778 | struct alg_sock *ask = alg_sk(sk); |
| 780 | 779 | struct skcipher_ctx *ctx = ask->private; |
| 781 | − struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(&ctx->req); | |
| 780 | + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(&ctx->req); | |
| 782 | 781 | |
| 783 | 782 | if (atomic_read(&ctx->inflight)) |
| 784 | 783 | skcipher_wait(sk); |
| 785 | 784 | |
| 786 | 785 | skcipher_free_sgl(sk); |
| 787 | − sock_kzfree_s(sk, ctx->iv, crypto_ablkcipher_ivsize(tfm)); | |
| 786 | + sock_kzfree_s(sk, ctx->iv, crypto_skcipher_ivsize(tfm)); | |
| 788 | 787 | sock_kfree_s(sk, ctx, ctx->len); |
| 789 | 788 | af_alg_release_parent(sk); |
| 790 | 789 | } |
| @@ -793,20 +792,20 @@ static int skcipher_accept_parent(void *private, struct sock *sk) · 2 unmodified lines | ||
| 793 | 792 | { |
| 794 | 793 | struct skcipher_ctx *ctx; |
| 795 | 794 | struct alg_sock *ask = alg_sk(sk); |
| 796 | − unsigned int len = sizeof(*ctx) + crypto_ablkcipher_reqsize(private); | |
| 795 | + unsigned int len = sizeof(*ctx) + crypto_skcipher_reqsize(private); | |
| 797 | 796 | |
| 798 | 797 | ctx = sock_kmalloc(sk, len, GFP_KERNEL); |
| 799 | 798 | if (!ctx) |
| 800 | 799 | return -ENOMEM; |
| 801 | 800 | |
| 802 | − ctx->iv = sock_kmalloc(sk, crypto_ablkcipher_ivsize(private), | |
| 801 | + ctx->iv = sock_kmalloc(sk, crypto_skcipher_ivsize(private), | |
| 803 | 802 | GFP_KERNEL); |
| 804 | 803 | if (!ctx->iv) { |
| 805 | 804 | sock_kfree_s(sk, ctx, len); |
| 806 | 805 | return -ENOMEM; |
| 807 | 806 | } |
| 808 | 807 | |
| 809 | − memset(ctx->iv, 0, crypto_ablkcipher_ivsize(private)); | |
| 808 | + memset(ctx->iv, 0, crypto_skcipher_ivsize(private)); | |
| 810 | 809 | |
| 811 | 810 | INIT_LIST_HEAD(&ctx->tsgl); |
| 812 | 811 | ctx->len = len; |
| @@ -819,9 +818,9 @@ static int skcipher_accept_parent(void *private, struct sock *sk) · 6 unmodified lines | ||
| 819 | 818 | |
| 820 | 819 | ask->private = ctx; |
| 821 | 820 | |
| 822 | − ablkcipher_request_set_tfm(&ctx->req, private); | |
| 823 | − ablkcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, | |
| 824 | − af_alg_complete, &ctx->completion); | |
| 821 | + skcipher_request_set_tfm(&ctx->req, private); | |
| 822 | + skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, | |
| 823 | + af_alg_complete, &ctx->completion); | |
| 825 | 824 | |
| 826 | 825 | sk->sk_destruct = skcipher_sock_destruct; |
| 827 | 826 | |
| @@ -53,7 +53,7 @@ async_memcpy(struct page *dest, struct page *src, unsigned int dest_offset, · 52 unmodified lines | ||
| 53 | 53 | struct dmaengine_unmap_data *unmap = NULL; |
| 54 | 54 | |
| 55 | 55 | if (device) |
| 56 | − unmap = dmaengine_get_unmap_data(device->dev, 2, GFP_NOIO); | |
| 56 | + unmap = dmaengine_get_unmap_data(device->dev, 2, GFP_NOWAIT); | |
| 57 | 57 | |
| 58 | 58 | if (unmap && is_dma_copy_aligned(device, src_offset, dest_offset, len)) { |
| 59 | 59 | unsigned long dma_prep_flags = 0; |
| @@ -188,7 +188,7 @@ async_gen_syndrome(struct page **blocks, unsigned int offset, int disks, · 187 unmodified lines | ||
| 188 | 188 | BUG_ON(disks > 255 || !(P(blocks, disks) || Q(blocks, disks))); |
| 189 | 189 | |
| 190 | 190 | if (device) |
| 191 | − unmap = dmaengine_get_unmap_data(device->dev, disks, GFP_NOIO); | |
| 191 | + unmap = dmaengine_get_unmap_data(device->dev, disks, GFP_NOWAIT); | |
| 192 | 192 | |
| 193 | 193 | /* XORing P/Q is only implemented in software */ |
| 194 | 194 | if (unmap && !(submit->flags & ASYNC_TX_PQ_XOR_DST) && |
| @@ -307,7 +307,7 @@ async_syndrome_val(struct page **blocks, unsigned int offset, int disks, · 112 unmodified lines | ||
| 307 | 307 | BUG_ON(disks < 4); |
| 308 | 308 | |
| 309 | 309 | if (device) |
| 310 | − unmap = dmaengine_get_unmap_data(device->dev, disks, GFP_NOIO); | |
| 310 | + unmap = dmaengine_get_unmap_data(device->dev, disks, GFP_NOWAIT); | |
| 311 | 311 | |
| 312 | 312 | if (unmap && disks <= dma_maxpq(device, 0) && |
| 313 | 313 | is_dma_pq_aligned(device, offset, 0, len)) { |
| @@ -41,7 +41,7 @@ async_sum_product(struct page *dest, struct page **srcs, unsigned char *coef, · 40 unmodified lines | ||
| 41 | 41 | u8 *a, *b, *c; |
| 42 | 42 | |
| 43 | 43 | if (dma) |
| 44 | − unmap = dmaengine_get_unmap_data(dma->dev, 3, GFP_NOIO); | |
| 44 | + unmap = dmaengine_get_unmap_data(dma->dev, 3, GFP_NOWAIT); | |
| 45 | 45 | |
| 46 | 46 | if (unmap) { |
| 47 | 47 | struct device *dev = dma->dev; |
| @@ -105,7 +105,7 @@ async_mult(struct page *dest, struct page *src, u8 coef, size_t len, · 57 unmodified lines | ||
| 105 | 105 | u8 *d, *s; |
| 106 | 106 | |
| 107 | 107 | if (dma) |
| 108 | − unmap = dmaengine_get_unmap_data(dma->dev, 3, GFP_NOIO); | |
| 108 | + unmap = dmaengine_get_unmap_data(dma->dev, 3, GFP_NOWAIT); | |
| 109 | 109 | |
| 110 | 110 | if (unmap) { |
| 111 | 111 | dma_addr_t dma_dest[2]; |
| @@ -182,7 +182,7 @@ async_xor(struct page *dest, struct page **src_list, unsigned int offset, · 181 unmodified lines | ||
| 182 | 182 | BUG_ON(src_cnt <= 1); |
| 183 | 183 | |
| 184 | 184 | if (device) |
| 185 | − unmap = dmaengine_get_unmap_data(device->dev, src_cnt+1, GFP_NOIO); | |
| 185 | + unmap = dmaengine_get_unmap_data(device->dev, src_cnt+1, GFP_NOWAIT); | |
| 186 | 186 | |
| 187 | 187 | if (unmap && is_dma_xor_aligned(device, offset, 0, len)) { |
| 188 | 188 | struct dma_async_tx_descriptor *tx; |
| @@ -278,7 +278,7 @@ async_xor_val(struct page *dest, struct page **src_list, unsigned int offset, · 89 unmodified lines | ||
| 278 | 278 | BUG_ON(src_cnt <= 1); |
| 279 | 279 | |
| 280 | 280 | if (device) |
| 281 | − unmap = dmaengine_get_unmap_data(device->dev, src_cnt, GFP_NOIO); | |
| 281 | + unmap = dmaengine_get_unmap_data(device->dev, src_cnt, GFP_NOWAIT); | |
| 282 | 282 | |
| 283 | 283 | if (unmap && src_cnt <= device->max_xor && |
| 284 | 284 | is_dma_xor_aligned(device, offset, 0, len)) { |
| @@ -326,12 +326,12 @@ static int blkcipher_walk_first(struct blkcipher_desc *desc, · 325 unmodified lines | ||
| 326 | 326 | if (WARN_ON_ONCE(in_irq())) |
| 327 | 327 | return -EDEADLK; |
| 328 | 328 | |
| 329 | + walk->iv = desc->info; | |
| 329 | 330 | walk->nbytes = walk->total; |
| 330 | 331 | if (unlikely(!walk->total)) |
| 331 | 332 | return 0; |
| 332 | 333 | |
| 333 | 334 | walk->buffer = NULL; |
| 334 | − walk->iv = desc->info; | |
| 335 | 335 | if (unlikely(((unsigned long)walk->iv & walk->alignmask))) { |
| 336 | 336 | int err = blkcipher_copy_iv(walk); |
| 337 | 337 | if (err) |
| @@ -104,7 +104,7 @@ static void acpi_expose_nondev_subnodes(struct kobject *kobj, · 103 unmodified lines | ||
| 104 | 104 | |
| 105 | 105 | init_completion(&dn->kobj_done); |
| 106 | 106 | ret = kobject_init_and_add(&dn->kobj, &acpi_data_node_ktype, |
| 107 | − kobj, dn->name); | |
| 107 | + kobj, "%s", dn->name); | |
| 108 | 108 | if (ret) |
| 109 | 109 | acpi_handle_err(dn->handle, "Failed to expose (%d)\n", ret); |
| 110 | 110 | else |
| @@ -1810,7 +1810,7 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event) · 1809 unmodified lines | ||
| 1810 | 1810 | if (!dev->driver) { |
| 1811 | 1811 | /* dev->driver may be null if we're being removed */ |
| 1812 | 1812 | dev_dbg(dev, "%s: no driver found for dev\n", __func__); |
| 1813 | − return; | |
| 1813 | + goto out_unlock; | |
| 1814 | 1814 | } |
| 1815 | 1815 | |
| 1816 | 1816 | if (!acpi_desc) { |
| @@ -200,7 +200,8 @@ static int acpi_pss_perf_init(struct acpi_processor *pr, · 199 unmodified lines | ||
| 200 | 200 | goto err_remove_sysfs_thermal; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | − sysfs_remove_link(&pr->cdev->device.kobj, "device"); | |
| 203 | + return 0; | |
| 204 | + | |
| 204 | 205 | err_remove_sysfs_thermal: |
| 205 | 206 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); |
| 206 | 207 | err_thermal_unregister: |
| @@ -390,6 +390,7 @@ static int pm_genpd_runtime_suspend(struct device *dev) · 389 unmodified lines | ||
| 390 | 390 | struct generic_pm_domain *genpd; |
| 391 | 391 | bool (*stop_ok)(struct device *__dev); |
| 392 | 392 | struct gpd_timing_data *td = &dev_gpd_data(dev)->td; |
| 393 | + bool runtime_pm = pm_runtime_enabled(dev); | |
| 393 | 394 | ktime_t time_start; |
| 394 | 395 | s64 elapsed_ns; |
| 395 | 396 | int ret; |
| @@ -400,12 +401,19 @@ static int pm_genpd_runtime_suspend(struct device *dev) · 4 unmodified lines | ||
| 400 | 401 | if (IS_ERR(genpd)) |
| 401 | 402 | return -EINVAL; |
| 402 | 403 | |
| 404 | + /* | |
| 405 | + * A runtime PM centric subsystem/driver may re-use the runtime PM | |
| 406 | + * callbacks for other purposes than runtime PM. In those scenarios | |
| 407 | + * runtime PM is disabled. Under these circumstances, we shall skip | |
| 408 | + * validating/measuring the PM QoS latency. | |
| 409 | + */ | |
| 403 | 410 | stop_ok = genpd->gov ? genpd->gov->stop_ok : NULL; |
| 404 | − if (stop_ok && !stop_ok(dev)) | |
| 411 | + if (runtime_pm && stop_ok && !stop_ok(dev)) | |
| 405 | 412 | return -EBUSY; |
| 406 | 413 | |
| 407 | 414 | /* Measure suspend latency. */ |
| 408 | − time_start = ktime_get(); | |
| 415 | + if (runtime_pm) | |
| 416 | + time_start = ktime_get(); | |
| 409 | 417 | |
| 410 | 418 | ret = genpd_save_dev(genpd, dev); |
| 411 | 419 | if (ret) |
| @@ -418,13 +426,15 @@ static int pm_genpd_runtime_suspend(struct device *dev) · 6 unmodified lines | ||
| 418 | 426 | } |
| 419 | 427 | |
| 420 | 428 | /* Update suspend latency value if the measured time exceeds it. */ |
| 421 | − elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); | |
| 422 | − if (elapsed_ns > td->suspend_latency_ns) { | |
| 423 | − td->suspend_latency_ns = elapsed_ns; | |
| 424 | − dev_dbg(dev, "suspend latency exceeded, %lld ns\n", | |
| 425 | − elapsed_ns); | |
| 426 | − genpd->max_off_time_changed = true; | |
| 427 | − td->constraint_changed = true; | |
| 429 | + if (runtime_pm) { | |
| 430 | + elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); | |
| 431 | + if (elapsed_ns > td->suspend_latency_ns) { | |
| 432 | + td->suspend_latency_ns = elapsed_ns; | |
| 433 | + dev_dbg(dev, "suspend latency exceeded, %lld ns\n", | |
| 434 | + elapsed_ns); | |
| 435 | + genpd->max_off_time_changed = true; | |
| 436 | + td->constraint_changed = true; | |
| 437 | + } | |
| 428 | 438 | } |
| 429 | 439 | |
| 430 | 440 | /* |
| @@ -453,6 +463,7 @@ static int pm_genpd_runtime_resume(struct device *dev) · 22 unmodified lines | ||
| 453 | 463 | { |
| 454 | 464 | struct generic_pm_domain *genpd; |
| 455 | 465 | struct gpd_timing_data *td = &dev_gpd_data(dev)->td; |
| 466 | + bool runtime_pm = pm_runtime_enabled(dev); | |
| 456 | 467 | ktime_t time_start; |
| 457 | 468 | s64 elapsed_ns; |
| 458 | 469 | int ret; |
| @@ -479,14 +490,14 @@ static int pm_genpd_runtime_resume(struct device *dev) · 20 unmodified lines | ||
| 479 | 490 | |
| 480 | 491 | out: |
| 481 | 492 | /* Measure resume latency. */ |
| 482 | − if (timed) | |
| 493 | + if (timed && runtime_pm) | |
| 483 | 494 | time_start = ktime_get(); |
| 484 | 495 | |
| 485 | 496 | genpd_start_dev(genpd, dev); |
| 486 | 497 | genpd_restore_dev(genpd, dev); |
| 487 | 498 | |
| 488 | 499 | /* Update resume latency value if the measured time exceeds it. */ |
| 489 | − if (timed) { | |
| 500 | + if (timed && runtime_pm) { | |
| 490 | 501 | elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); |
| 491 | 502 | if (elapsed_ns > td->resume_latency_ns) { |
| 492 | 503 | td->resume_latency_ns = elapsed_ns; |
| @@ -219,6 +219,9 @@ static void end_cmd(struct nullb_cmd *cmd) · 218 unmodified lines | ||
| 219 | 219 | { |
| 220 | 220 | struct request_queue *q = NULL; |
| 221 | 221 | |
| 222 | + if (cmd->rq) | |
| 223 | + q = cmd->rq->q; | |
| 224 | + | |
| 222 | 225 | switch (queue_mode) { |
| 223 | 226 | case NULL_Q_MQ: |
| 224 | 227 | blk_mq_end_request(cmd->rq, 0); |
| @@ -229,23 +232,19 @@ static void end_cmd(struct nullb_cmd *cmd) · 4 unmodified lines | ||
| 229 | 232 | break; |
| 230 | 233 | case NULL_Q_BIO: |
| 231 | 234 | bio_endio(cmd->bio); |
| 232 | − goto free_cmd; | |
| 235 | + break; | |
| 233 | 236 | } |
| 234 | 237 | |
| 235 | − if (cmd->rq) | |
| 236 | − q = cmd->rq->q; | |
| 238 | + free_cmd(cmd); | |
| 237 | 239 | |
| 238 | 240 | /* Restart queue if needed, as we are freeing a tag */ |
| 239 | − if (q && !q->mq_ops && blk_queue_stopped(q)) { | |
| 241 | + if (queue_mode == NULL_Q_RQ && blk_queue_stopped(q)) { | |
| 240 | 242 | unsigned long flags; |
| 241 | 243 | |
| 242 | 244 | spin_lock_irqsave(q->queue_lock, flags); |
| 243 | − if (blk_queue_stopped(q)) | |
| 244 | − blk_start_queue(q); | |
| 245 | + blk_start_queue_async(q); | |
| 245 | 246 | spin_unlock_irqrestore(q->queue_lock, flags); |
| 246 | 247 | } |
| 247 | −free_cmd: | |
| 248 | − free_cmd(cmd); | |
| 249 | 248 | } |
| 250 | 249 | |
| 251 | 250 | static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer) |
| @@ -950,6 +950,8 @@ static int xen_blkbk_parse_indirect(struct blkif_request *req, · 949 unmodified lines | ||
| 950 | 950 | goto unmap; |
| 951 | 951 | |
| 952 | 952 | for (n = 0, i = 0; n < nseg; n++) { |
| 953 | + uint8_t first_sect, last_sect; | |
| 954 | + | |
| 953 | 955 | if ((n % SEGS_PER_INDIRECT_FRAME) == 0) { |
| 954 | 956 | /* Map indirect segments */ |
| 955 | 957 | if (segments) |
| @@ -957,15 +959,18 @@ static int xen_blkbk_parse_indirect(struct blkif_request *req, · 1 unmodified line | ||
| 957 | 959 | segments = kmap_atomic(pages[n/SEGS_PER_INDIRECT_FRAME]->page); |
| 958 | 960 | } |
| 959 | 961 | i = n % SEGS_PER_INDIRECT_FRAME; |
| 962 | + | |
| 960 | 963 | pending_req->segments[n]->gref = segments[i].gref; |
| 961 | − seg[n].nsec = segments[i].last_sect - | |
| 962 | − segments[i].first_sect + 1; | |
| 963 | − seg[n].offset = (segments[i].first_sect << 9); | |
| 964 | − if ((segments[i].last_sect >= (XEN_PAGE_SIZE >> 9)) || | |
| 965 | − (segments[i].last_sect < segments[i].first_sect)) { | |
| 964 | + | |
| 965 | + first_sect = READ_ONCE(segments[i].first_sect); | |
| 966 | + last_sect = READ_ONCE(segments[i].last_sect); | |
| 967 | + if (last_sect >= (XEN_PAGE_SIZE >> 9) || last_sect < first_sect) { | |
| 966 | 968 | rc = -EINVAL; |
| 967 | 969 | goto unmap; |
| 968 | 970 | } |
| 971 | + | |
| 972 | + seg[n].nsec = last_sect - first_sect + 1; | |
| 973 | + seg[n].offset = first_sect << 9; | |
| 969 | 974 | preq->nr_sects += seg[n].nsec; |
| 970 | 975 | } |
| 971 | 976 | |
| @@ -408,8 +408,8 @@ static inline void blkif_get_x86_32_req(struct blkif_request *dst, · 407 unmodified lines | ||
| 408 | 408 | struct blkif_x86_32_request *src) |
| 409 | 409 | { |
| 410 | 410 | int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j; |
| 411 | − dst->operation = src->operation; | |
| 412 | − switch (src->operation) { | |
| 411 | + dst->operation = READ_ONCE(src->operation); | |
| 412 | + switch (dst->operation) { | |
| 413 | 413 | case BLKIF_OP_READ: |
| 414 | 414 | case BLKIF_OP_WRITE: |
| 415 | 415 | case BLKIF_OP_WRITE_BARRIER: |
| @@ -456,8 +456,8 @@ static inline void blkif_get_x86_64_req(struct blkif_request *dst, · 40 unmodified lines | ||
| 456 | 456 | struct blkif_x86_64_request *src) |
| 457 | 457 | { |
| 458 | 458 | int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j; |
| 459 | − dst->operation = src->operation; | |
| 460 | − switch (src->operation) { | |
| 459 | + dst->operation = READ_ONCE(src->operation); | |
| 460 | + switch (dst->operation) { | |
| 461 | 461 | case BLKIF_OP_READ: |
| 462 | 462 | case BLKIF_OP_WRITE: |
| 463 | 463 | case BLKIF_OP_WRITE_BARRIER: |
| @@ -342,13 +342,13 @@ static int sunxi_rsb_read(struct sunxi_rsb *rsb, u8 rtaddr, u8 addr, · 341 unmodified lines | ||
| 342 | 342 | |
| 343 | 343 | ret = _sunxi_rsb_run_xfer(rsb); |
| 344 | 344 | if (ret) |
| 345 | − goto out; | |
| 345 | + goto unlock; | |
| 346 | 346 | |
| 347 | 347 | *buf = readl(rsb->regs + RSB_DATA); |
| 348 | 348 | |
| 349 | +unlock: | |
| 349 | 350 | mutex_unlock(&rsb->lock); |
| 350 | 351 | |
| 351 | −out: | |
| 352 | 352 | return ret; |
| 353 | 353 | } |
| 354 | 354 | |
| @@ -527,9 +527,9 @@ static int sunxi_rsb_init_device_mode(struct sunxi_rsb *rsb) · 172 unmodified lines | ||
| 527 | 527 | */ |
| 528 | 528 | |
| 529 | 529 | static const struct sunxi_rsb_addr_map sunxi_rsb_addr_maps[] = { |
| 530 | − { 0x3e3, 0x2d }, /* Primary PMIC: AXP223, AXP809, AXP81X, ... */ | |
| 530 | + { 0x3a3, 0x2d }, /* Primary PMIC: AXP223, AXP809, AXP81X, ... */ | |
| 531 | 531 | { 0x745, 0x3a }, /* Secondary PMIC: AXP806, ... */ |
| 532 | − { 0xe89, 0x45 }, /* Peripheral IC: AC100, ... */ | |
| 532 | + { 0xe89, 0x4e }, /* Peripheral IC: AC100, ... */ | |
| 533 | 533 | }; |
| 534 | 534 | |
| 535 | 535 | static u8 sunxi_rsb_get_rtaddr(u16 hwaddr) |
| @@ -179,26 +179,21 @@ static int cn_call_callback(struct sk_buff *skb) · 178 unmodified lines | ||
| 179 | 179 | * |
| 180 | 180 | * It checks skb, netlink header and msg sizes, and calls callback helper. |
| 181 | 181 | */ |
| 182 | −static void cn_rx_skb(struct sk_buff *__skb) | |
| 182 | +static void cn_rx_skb(struct sk_buff *skb) | |
| 183 | 183 | { |
| 184 | 184 | struct nlmsghdr *nlh; |
| 185 | − struct sk_buff *skb; | |
| 186 | 185 | int len, err; |
| 187 | 186 | |
| 188 | − skb = skb_get(__skb); | |
| 189 | − | |
| 190 | 187 | if (skb->len >= NLMSG_HDRLEN) { |
| 191 | 188 | nlh = nlmsg_hdr(skb); |
| 192 | 189 | len = nlmsg_len(nlh); |
| 193 | 190 | |
| 194 | 191 | if (len < (int)sizeof(struct cn_msg) || |
| 195 | 192 | skb->len < nlh->nlmsg_len || |
| 196 | − len > CONNECTOR_MAX_MSG_SIZE) { | |
| 197 | − kfree_skb(skb); | |
| 193 | + len > CONNECTOR_MAX_MSG_SIZE) | |
| 198 | 194 | return; |
| 199 | − } | |
| 200 | 195 | |
| 201 | − err = cn_call_callback(skb); | |
| 196 | + err = cn_call_callback(skb_get(skb)); | |
| 202 | 197 | if (err < 0) |
| 203 | 198 | kfree_skb(skb); |
| 204 | 199 | } |
| @@ -226,7 +226,7 @@ config ARM_TEGRA20_CPUFREQ · 225 unmodified lines | ||
| 226 | 226 | |
| 227 | 227 | config ARM_TEGRA124_CPUFREQ |
| 228 | 228 | tristate "Tegra124 CPUFreq support" |
| 229 | − depends on ARCH_TEGRA && CPUFREQ_DT | |
| 229 | + depends on ARCH_TEGRA && CPUFREQ_DT && REGULATOR | |
| 230 | 230 | default y |
| 231 | 231 | help |
| 232 | 232 | This adds the CPUFreq driver support for Tegra124 SOCs. |
| @@ -1123,7 +1123,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 1122 unmodified lines | ||
| 1123 | 1123 | limits->max_sysfs_pct); |
| 1124 | 1124 | limits->max_perf_pct = max(limits->min_policy_pct, |
| 1125 | 1125 | limits->max_perf_pct); |
| 1126 | − limits->max_perf = round_up(limits->max_perf, 8); | |
| 1126 | + limits->max_perf = round_up(limits->max_perf, FRAC_BITS); | |
| 1127 | 1127 | |
| 1128 | 1128 | /* Make sure min_perf_pct <= max_perf_pct */ |
| 1129 | 1129 | limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct); |
| @@ -31,7 +31,7 @@ static struct scpi_ops *scpi_ops; · 30 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | static struct scpi_dvfs_info *scpi_get_dvfs_info(struct device *cpu_dev) |
| 33 | 33 | { |
| 34 | − u8 domain = topology_physical_package_id(cpu_dev->id); | |
| 34 | + int domain = topology_physical_package_id(cpu_dev->id); | |
| 35 | 35 | |
| 36 | 36 | if (domain < 0) |
| 37 | 37 | return ERR_PTR(-EINVAL); |
| @@ -156,7 +156,7 @@ · 155 unmodified lines | ||
| 156 | 156 | #define AT_XDMAC_CC_WRIP (0x1 << 23) /* Write in Progress (read only) */ |
| 157 | 157 | #define AT_XDMAC_CC_WRIP_DONE (0x0 << 23) |
| 158 | 158 | #define AT_XDMAC_CC_WRIP_IN_PROGRESS (0x1 << 23) |
| 159 | −#define AT_XDMAC_CC_PERID(i) (0x7f & (h) << 24) /* Channel Peripheral Identifier */ | |
| 159 | +#define AT_XDMAC_CC_PERID(i) (0x7f & (i) << 24) /* Channel Peripheral Identifier */ | |
| 160 | 160 | #define AT_XDMAC_CDS_MSP 0x2C /* Channel Data Stride Memory Set Pattern */ |
| 161 | 161 | #define AT_XDMAC_CSUS 0x30 /* Channel Source Microblock Stride */ |
| 162 | 162 | #define AT_XDMAC_CDUS 0x34 /* Channel Destination Microblock Stride */ |
| @@ -965,7 +965,9 @@ at_xdmac_prep_interleaved(struct dma_chan *chan, · 802 unmodified lines | ||
| 965 | 965 | NULL, |
| 966 | 966 | src_addr, dst_addr, |
| 967 | 967 | xt, xt->sgl); |
| 968 | − for (i = 0; i < xt->numf; i++) | |
| 968 | + | |
| 969 | + /* Length of the block is (BLEN+1) microblocks. */ | |
| 970 | + for (i = 0; i < xt->numf - 1; i++) | |
| 969 | 971 | at_xdmac_increment_block_count(chan, first); |
| 970 | 972 | |
| 971 | 973 | dev_dbg(chan2dev(chan), "%s: add desc 0x%p to descs_list 0x%p\n", |
| @@ -1086,6 +1088,7 @@ at_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, · 114 unmodified lines | ||
| 1086 | 1088 | /* Check remaining length and change data width if needed. */ |
| 1087 | 1089 | dwidth = at_xdmac_align_width(chan, |
| 1088 | 1090 | src_addr | dst_addr | xfer_size); |
| 1091 | + chan_cc &= ~AT_XDMAC_CC_DWIDTH_MASK; | |
| 1089 | 1092 | chan_cc |= AT_XDMAC_CC_DWIDTH(dwidth); |
| 1090 | 1093 | |
| 1091 | 1094 | ublen = xfer_size >> dwidth; |
| @@ -1333,7 +1336,7 @@ at_xdmac_prep_dma_memset_sg(struct dma_chan *chan, struct scatterlist *sgl, · 241 unmodified lines | ||
| 1333 | 1336 | * since we don't care about the stride anymore. |
| 1334 | 1337 | */ |
| 1335 | 1338 | if ((i == (sg_len - 1)) && |
| 1336 | − sg_dma_len(ppsg) == sg_dma_len(psg)) { | |
| 1339 | + sg_dma_len(psg) == sg_dma_len(sg)) { | |
| 1337 | 1340 | dev_dbg(chan2dev(chan), |
| 1338 | 1341 | "%s: desc 0x%p can be merged with desc 0x%p\n", |
| 1339 | 1342 | __func__, desc, pdesc); |
| @@ -31,6 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | */ |
| 32 | 32 | #include <linux/dmaengine.h> |
| 33 | 33 | #include <linux/dma-mapping.h> |
| 34 | +#include <linux/dmapool.h> | |
| 34 | 35 | #include <linux/err.h> |
| 35 | 36 | #include <linux/init.h> |
| 36 | 37 | #include <linux/interrupt.h> |
| @@ -62,6 +63,11 @@ struct bcm2835_dma_cb { · 25 unmodified lines | ||
| 62 | 63 | uint32_t pad[2]; |
| 63 | 64 | }; |
| 64 | 65 | |
| 66 | +struct bcm2835_cb_entry { | |
| 67 | + struct bcm2835_dma_cb *cb; | |
| 68 | + dma_addr_t paddr; | |
| 69 | +}; | |
| 70 | + | |
| 65 | 71 | struct bcm2835_chan { |
| 66 | 72 | struct virt_dma_chan vc; |
| 67 | 73 | struct list_head node; |
| @@ -72,18 +78,18 @@ struct bcm2835_chan { · 4 unmodified lines | ||
| 72 | 78 | |
| 73 | 79 | int ch; |
| 74 | 80 | struct bcm2835_desc *desc; |
| 81 | + struct dma_pool *cb_pool; | |
| 75 | 82 | |
| 76 | 83 | void __iomem *chan_base; |
| 77 | 84 | int irq_number; |
| 78 | 85 | }; |
| 79 | 86 | |
| 80 | 87 | struct bcm2835_desc { |
| 88 | + struct bcm2835_chan *c; | |
| 81 | 89 | struct virt_dma_desc vd; |
| 82 | 90 | enum dma_transfer_direction dir; |
| 83 | 91 | |
| 84 | − unsigned int control_block_size; | |
| 85 | − struct bcm2835_dma_cb *control_block_base; | |
| 86 | − dma_addr_t control_block_base_phys; | |
| 92 | + struct bcm2835_cb_entry *cb_list; | |
| 87 | 93 | |
| 88 | 94 | unsigned int frames; |
| 89 | 95 | size_t size; |
| @@ -143,10 +149,13 @@ static inline struct bcm2835_desc *to_bcm2835_dma_desc( · 53 unmodified lines | ||
| 143 | 149 | static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) |
| 144 | 150 | { |
| 145 | 151 | struct bcm2835_desc *desc = container_of(vd, struct bcm2835_desc, vd); |
| 146 | − dma_free_coherent(desc->vd.tx.chan->device->dev, | |
| 147 | − desc->control_block_size, | |
| 148 | − desc->control_block_base, | |
| 149 | − desc->control_block_base_phys); | |
| 152 | + int i; | |
| 153 | + | |
| 154 | + for (i = 0; i < desc->frames; i++) | |
| 155 | + dma_pool_free(desc->c->cb_pool, desc->cb_list[i].cb, | |
| 156 | + desc->cb_list[i].paddr); | |
| 157 | + | |
| 158 | + kfree(desc->cb_list); | |
| 150 | 159 | kfree(desc); |
| 151 | 160 | } |
| 152 | 161 | |
| @@ -199,7 +208,7 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c) · 46 unmodified lines | ||
| 199 | 208 | |
| 200 | 209 | c->desc = d = to_bcm2835_dma_desc(&vd->tx); |
| 201 | 210 | |
| 202 | − writel(d->control_block_base_phys, c->chan_base + BCM2835_DMA_ADDR); | |
| 211 | + writel(d->cb_list[0].paddr, c->chan_base + BCM2835_DMA_ADDR); | |
| 203 | 212 | writel(BCM2835_DMA_ACTIVE, c->chan_base + BCM2835_DMA_CS); |
| 204 | 213 | } |
| 205 | 214 | |
| @@ -232,9 +241,16 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) · 26 unmodified lines | ||
| 232 | 241 | static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan) |
| 233 | 242 | { |
| 234 | 243 | struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); |
| 244 | + struct device *dev = c->vc.chan.device->dev; | |
| 245 | + | |
| 246 | + dev_dbg(dev, "Allocating DMA channel %d\n", c->ch); | |
| 235 | 247 | |
| 236 | − dev_dbg(c->vc.chan.device->dev, | |
| 237 | − "Allocating DMA channel %d\n", c->ch); | |
| 248 | + c->cb_pool = dma_pool_create(dev_name(dev), dev, | |
| 249 | + sizeof(struct bcm2835_dma_cb), 0, 0); | |
| 250 | + if (!c->cb_pool) { | |
| 251 | + dev_err(dev, "unable to allocate descriptor pool\n"); | |
| 252 | + return -ENOMEM; | |
| 253 | + } | |
| 238 | 254 | |
| 239 | 255 | return request_irq(c->irq_number, |
| 240 | 256 | bcm2835_dma_callback, 0, "DMA IRQ", c); |
| @@ -246,6 +262,7 @@ static void bcm2835_dma_free_chan_resources(struct dma_chan *chan) · 5 unmodified lines | ||
| 246 | 262 | |
| 247 | 263 | vchan_free_chan_resources(&c->vc); |
| 248 | 264 | free_irq(c->irq_number, c); |
| 265 | + dma_pool_destroy(c->cb_pool); | |
| 249 | 266 | |
| 250 | 267 | dev_dbg(c->vc.chan.device->dev, "Freeing DMA channel %u\n", c->ch); |
| 251 | 268 | } |
| @@ -261,8 +278,7 @@ static size_t bcm2835_dma_desc_size_pos(struct bcm2835_desc *d, dma_addr_t addr) · 9 unmodified lines | ||
| 261 | 278 | size_t size; |
| 262 | 279 | |
| 263 | 280 | for (size = i = 0; i < d->frames; i++) { |
| 264 | − struct bcm2835_dma_cb *control_block = | |
| 265 | − &d->control_block_base[i]; | |
| 281 | + struct bcm2835_dma_cb *control_block = d->cb_list[i].cb; | |
| 266 | 282 | size_t this_size = control_block->length; |
| 267 | 283 | dma_addr_t dma; |
| 268 | 284 | |
| @@ -343,6 +359,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( · 74 unmodified lines | ||
| 343 | 359 | dma_addr_t dev_addr; |
| 344 | 360 | unsigned int es, sync_type; |
| 345 | 361 | unsigned int frame; |
| 362 | + int i; | |
| 346 | 363 | |
| 347 | 364 | /* Grab configuration */ |
| 348 | 365 | if (!is_slave_direction(direction)) { |
| @@ -374,27 +391,31 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( · 25 unmodified lines | ||
| 374 | 391 | if (!d) |
| 375 | 392 | return NULL; |
| 376 | 393 | |
| 394 | + d->c = c; | |
| 377 | 395 | d->dir = direction; |
| 378 | 396 | d->frames = buf_len / period_len; |
| 379 | 397 | |
| 380 | − /* Allocate memory for control blocks */ | |
| 381 | − d->control_block_size = d->frames * sizeof(struct bcm2835_dma_cb); | |
| 382 | − d->control_block_base = dma_zalloc_coherent(chan->device->dev, | |
| 383 | − d->control_block_size, &d->control_block_base_phys, | |
| 384 | − GFP_NOWAIT); | |
| 385 | − | |
| 386 | − if (!d->control_block_base) { | |
| 398 | + d->cb_list = kcalloc(d->frames, sizeof(*d->cb_list), GFP_KERNEL); | |
| 399 | + if (!d->cb_list) { | |
| 387 | 400 | kfree(d); |
| 388 | 401 | return NULL; |
| 389 | 402 | } |
| 403 | + /* Allocate memory for control blocks */ | |
| 404 | + for (i = 0; i < d->frames; i++) { | |
| 405 | + struct bcm2835_cb_entry *cb_entry = &d->cb_list[i]; | |
| 406 | + | |
| 407 | + cb_entry->cb = dma_pool_zalloc(c->cb_pool, GFP_ATOMIC, | |
| 408 | + &cb_entry->paddr); | |
| 409 | + if (!cb_entry->cb) | |
| 410 | + goto error_cb; | |
| 411 | + } | |
| 390 | 412 | |
| 391 | 413 | /* |
| 392 | 414 | * Iterate over all frames, create a control block |
| 393 | 415 | * for each frame and link them together. |
| 394 | 416 | */ |
| 395 | 417 | for (frame = 0; frame < d->frames; frame++) { |
| 396 | − struct bcm2835_dma_cb *control_block = | |
| 397 | − &d->control_block_base[frame]; | |
| 418 | + struct bcm2835_dma_cb *control_block = d->cb_list[frame].cb; | |
| 398 | 419 | |
| 399 | 420 | /* Setup adresses */ |
| 400 | 421 | if (d->dir == DMA_DEV_TO_MEM) { |
| @@ -428,12 +449,21 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( · 27 unmodified lines | ||
| 428 | 449 | * This DMA engine driver currently only supports cyclic DMA. |
| 429 | 450 | * Therefore, wrap around at number of frames. |
| 430 | 451 | */ |
| 431 | − control_block->next = d->control_block_base_phys + | |
| 432 | − sizeof(struct bcm2835_dma_cb) | |
| 433 | − * ((frame + 1) % d->frames); | |
| 452 | + control_block->next = d->cb_list[((frame + 1) % d->frames)].paddr; | |
| 434 | 453 | } |
| 435 | 454 | |
| 436 | 455 | return vchan_tx_prep(&c->vc, &d->vd, flags); |
| 456 | +error_cb: | |
| 457 | + i--; | |
| 458 | + for (; i >= 0; i--) { | |
| 459 | + struct bcm2835_cb_entry *cb_entry = &d->cb_list[i]; | |
| 460 | + | |
| 461 | + dma_pool_free(c->cb_pool, cb_entry->cb, cb_entry->paddr); | |
| 462 | + } | |
| 463 | + | |
| 464 | + kfree(d->cb_list); | |
| 465 | + kfree(d); | |
| 466 | + return NULL; | |
| 437 | 467 | } |
| 438 | 468 | |
| 439 | 469 | static int bcm2835_dma_slave_config(struct dma_chan *chan, |
| @@ -1752,16 +1752,14 @@ static enum dma_status edma_tx_status(struct dma_chan *chan, · 1751 unmodified lines | ||
| 1752 | 1752 | return ret; |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | −static bool edma_is_memcpy_channel(int ch_num, u16 *memcpy_channels) | |
| 1755 | +static bool edma_is_memcpy_channel(int ch_num, s32 *memcpy_channels) | |
| 1756 | 1756 | { |
| 1757 | − s16 *memcpy_ch = memcpy_channels; | |
| 1758 | − | |
| 1759 | 1757 | if (!memcpy_channels) |
| 1760 | 1758 | return false; |
| 1761 | − while (*memcpy_ch != -1) { | |
| 1762 | − if (*memcpy_ch == ch_num) | |
| 1759 | + while (*memcpy_channels != -1) { | |
| 1760 | + if (*memcpy_channels == ch_num) | |
| 1763 | 1761 | return true; |
| 1764 | − memcpy_ch++; | |
| 1762 | + memcpy_channels++; | |
| 1765 | 1763 | } |
| 1766 | 1764 | return false; |
| 1767 | 1765 | } |
| @@ -1775,7 +1773,7 @@ static void edma_dma_init(struct edma_cc *ecc, bool legacy_mode) · 7 unmodified lines | ||
| 1775 | 1773 | { |
| 1776 | 1774 | struct dma_device *s_ddev = &ecc->dma_slave; |
| 1777 | 1775 | struct dma_device *m_ddev = NULL; |
| 1778 | − s16 *memcpy_channels = ecc->info->memcpy_channels; | |
| 1776 | + s32 *memcpy_channels = ecc->info->memcpy_channels; | |
| 1779 | 1777 | int i, j; |
| 1780 | 1778 | |
| 1781 | 1779 | dma_cap_zero(s_ddev->cap_mask); |
| @@ -1996,16 +1994,16 @@ static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev, · 214 unmodified lines | ||
| 1996 | 1994 | prop = of_find_property(dev->of_node, "ti,edma-memcpy-channels", &sz); |
| 1997 | 1995 | if (prop) { |
| 1998 | 1996 | const char pname[] = "ti,edma-memcpy-channels"; |
| 1999 | − size_t nelm = sz / sizeof(s16); | |
| 2000 | − s16 *memcpy_ch; | |
| 1997 | + size_t nelm = sz / sizeof(s32); | |
| 1998 | + s32 *memcpy_ch; | |
| 2001 | 1999 | |
| 2002 | − memcpy_ch = devm_kcalloc(dev, nelm + 1, sizeof(s16), | |
| 2000 | + memcpy_ch = devm_kcalloc(dev, nelm + 1, sizeof(s32), | |
| 2003 | 2001 | GFP_KERNEL); |
| 2004 | 2002 | if (!memcpy_ch) |
| 2005 | 2003 | return ERR_PTR(-ENOMEM); |
| 2006 | 2004 | |
| 2007 | − ret = of_property_read_u16_array(dev->of_node, pname, | |
| 2008 | − (u16 *)memcpy_ch, nelm); | |
| 2005 | + ret = of_property_read_u32_array(dev->of_node, pname, | |
| 2006 | + (u32 *)memcpy_ch, nelm); | |
| 2009 | 2007 | if (ret) |
| 2010 | 2008 | return ERR_PTR(ret); |
| 2011 | 2009 | |
| @@ -2017,31 +2015,50 @@ static struct edma_soc_info *edma_setup_info_from_dt(struct device *dev, · 5 unmodified lines | ||
| 2017 | 2015 | &sz); |
| 2018 | 2016 | if (prop) { |
| 2019 | 2017 | const char pname[] = "ti,edma-reserved-slot-ranges"; |
| 2018 | + u32 (*tmp)[2]; | |
| 2020 | 2019 | s16 (*rsv_slots)[2]; |
| 2021 | − size_t nelm = sz / sizeof(*rsv_slots); | |
| 2020 | + size_t nelm = sz / sizeof(*tmp); | |
| 2022 | 2021 | struct edma_rsv_info *rsv_info; |
| 2022 | + int i; | |
| 2023 | 2023 | |
| 2024 | 2024 | if (!nelm) |
| 2025 | 2025 | return info; |
| 2026 | 2026 | |
| 2027 | + tmp = kcalloc(nelm, sizeof(*tmp), GFP_KERNEL); | |
| 2028 | + if (!tmp) | |
| 2029 | + return ERR_PTR(-ENOMEM); | |
| 2030 | + | |
| 2027 | 2031 | rsv_info = devm_kzalloc(dev, sizeof(*rsv_info), GFP_KERNEL); |
| 2028 | − if (!rsv_info) | |
| 2032 | + if (!rsv_info) { | |
| 2033 | + kfree(tmp); | |
| 2029 | 2034 | return ERR_PTR(-ENOMEM); |
| 2035 | + } | |
| 2030 | 2036 | |
| 2031 | 2037 | rsv_slots = devm_kcalloc(dev, nelm + 1, sizeof(*rsv_slots), |
| 2032 | 2038 | GFP_KERNEL); |
| 2033 | − if (!rsv_slots) | |
| 2039 | + if (!rsv_slots) { | |
| 2040 | + kfree(tmp); | |
| 2034 | 2041 | return ERR_PTR(-ENOMEM); |
| 2042 | + } | |
| 2035 | 2043 | |
| 2036 | − ret = of_property_read_u16_array(dev->of_node, pname, | |
| 2037 | − (u16 *)rsv_slots, nelm * 2); | |
| 2038 | − if (ret) | |
| 2044 | + ret = of_property_read_u32_array(dev->of_node, pname, | |
| 2045 | + (u32 *)tmp, nelm * 2); | |
| 2046 | + if (ret) { | |
| 2047 | + kfree(tmp); | |
| 2039 | 2048 | return ERR_PTR(ret); |
| 2049 | + } | |
| 2040 | 2050 | |
| 2051 | + for (i = 0; i < nelm; i++) { | |
| 2052 | + rsv_slots[i][0] = tmp[i][0]; | |
| 2053 | + rsv_slots[i][1] = tmp[i][1]; | |
| 2054 | + } | |
| 2041 | 2055 | rsv_slots[nelm][0] = -1; |
| 2042 | 2056 | rsv_slots[nelm][1] = -1; |
| 2057 | + | |
| 2043 | 2058 | info->rsv = rsv_info; |
| 2044 | 2059 | info->rsv->rsv_slots = (const s16 (*)[2])rsv_slots; |
| 2060 | + | |
| 2061 | + kfree(tmp); | |
| 2045 | 2062 | } |
| 2046 | 2063 | |
| 2047 | 2064 | return info; |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include <linux/dmapool.h> |
| 30 | 30 | #include <linux/interrupt.h> |
| 31 | 31 | #include <linux/io.h> |
| 32 | +#include <linux/irq.h> | |
| 32 | 33 | #include <linux/module.h> |
| 33 | 34 | #include <linux/of_device.h> |
| 34 | 35 | |
| @@ -1610,6 +1611,7 @@ static int xgene_dma_request_irqs(struct xgene_dma *pdma) · 1575 unmodified lines | ||
| 1610 | 1611 | /* Register DMA channel rx irq */ |
| 1611 | 1612 | for (i = 0; i < XGENE_DMA_MAX_CHANNEL; i++) { |
| 1612 | 1613 | chan = &pdma->chan[i]; |
| 1614 | + irq_set_status_flags(chan->rx_irq, IRQ_DISABLE_UNLAZY); | |
| 1613 | 1615 | ret = devm_request_irq(chan->dev, chan->rx_irq, |
| 1614 | 1616 | xgene_dma_chan_ring_isr, |
| 1615 | 1617 | 0, chan->name, chan); |
| @@ -1620,6 +1622,7 @@ static int xgene_dma_request_irqs(struct xgene_dma *pdma) · 4 unmodified lines | ||
| 1620 | 1622 | |
| 1621 | 1623 | for (j = 0; j < i; j++) { |
| 1622 | 1624 | chan = &pdma->chan[i]; |
| 1625 | + irq_clear_status_flags(chan->rx_irq, IRQ_DISABLE_UNLAZY); | |
| 1623 | 1626 | devm_free_irq(chan->dev, chan->rx_irq, chan); |
| 1624 | 1627 | } |
| 1625 | 1628 | |
| @@ -1640,6 +1643,7 @@ static void xgene_dma_free_irqs(struct xgene_dma *pdma) · 14 unmodified lines | ||
| 1640 | 1643 | |
| 1641 | 1644 | for (i = 0; i < XGENE_DMA_MAX_CHANNEL; i++) { |
| 1642 | 1645 | chan = &pdma->chan[i]; |
| 1646 | + irq_clear_status_flags(chan->rx_irq, IRQ_DISABLE_UNLAZY); | |
| 1643 | 1647 | devm_free_irq(chan->dev, chan->rx_irq, chan); |
| 1644 | 1648 | } |
| 1645 | 1649 | } |
| @@ -521,6 +521,7 @@ static int __init dmi_present(const u8 *buf) · 520 unmodified lines | ||
| 521 | 521 | dmi_ver = smbios_ver; |
| 522 | 522 | else |
| 523 | 523 | dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F); |
| 524 | + dmi_ver <<= 8; | |
| 524 | 525 | dmi_num = get_unaligned_le16(buf + 12); |
| 525 | 526 | dmi_len = get_unaligned_le16(buf + 6); |
| 526 | 527 | dmi_base = get_unaligned_le32(buf + 8); |
| @@ -528,15 +529,14 @@ static int __init dmi_present(const u8 *buf) · 1 unmodified line | ||
| 528 | 529 | if (dmi_walk_early(dmi_decode) == 0) { |
| 529 | 530 | if (smbios_ver) { |
| 530 | 531 | pr_info("SMBIOS %d.%d present.\n", |
| 531 | − dmi_ver >> 8, dmi_ver & 0xFF); | |
| 532 | + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF); | |
| 532 | 533 | } else { |
| 533 | 534 | smbios_entry_point_size = 15; |
| 534 | 535 | memcpy(smbios_entry_point, buf, |
| 535 | 536 | smbios_entry_point_size); |
| 536 | 537 | pr_info("Legacy DMI %d.%d present.\n", |
| 537 | − dmi_ver >> 8, dmi_ver & 0xFF); | |
| 538 | + dmi_ver >> 16, (dmi_ver >> 8) & 0xFF); | |
| 538 | 539 | } |
| 539 | − dmi_ver <<= 8; | |
| 540 | 540 | dmi_format_ids(dmi_ids_string, sizeof(dmi_ids_string)); |
| 541 | 541 | printk(KERN_DEBUG "DMI: %s\n", dmi_ids_string); |
| 542 | 542 | return 0; |
| @@ -113,7 +113,7 @@ static int ar934x_gpio_direction_output(struct gpio_chip *chip, unsigned offset, · 112 unmodified lines | ||
| 113 | 113 | __raw_writel(BIT(offset), ctrl->base + AR71XX_GPIO_REG_CLEAR); |
| 114 | 114 | |
| 115 | 115 | __raw_writel( |
| 116 | − __raw_readl(ctrl->base + AR71XX_GPIO_REG_OE) & BIT(offset), | |
| 116 | + __raw_readl(ctrl->base + AR71XX_GPIO_REG_OE) & ~BIT(offset), | |
| 117 | 117 | ctrl->base + AR71XX_GPIO_REG_OE); |
| 118 | 118 | |
| 119 | 119 | spin_unlock_irqrestore(&ctrl->lock, flags); |
| @@ -141,9 +141,9 @@ static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio) · 140 unmodified lines | ||
| 141 | 141 | unsigned long pinmask = bgc->pin2mask(bgc, gpio); |
| 142 | 142 | |
| 143 | 143 | if (bgc->dir & pinmask) |
| 144 | − return bgc->read_reg(bgc->reg_set) & pinmask; | |
| 144 | + return !!(bgc->read_reg(bgc->reg_set) & pinmask); | |
| 145 | 145 | else |
| 146 | − return bgc->read_reg(bgc->reg_dat) & pinmask; | |
| 146 | + return !!(bgc->read_reg(bgc->reg_dat) & pinmask); | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | static int bgpio_get(struct gpio_chip *gc, unsigned int gpio) |
| @@ -1279,7 +1279,13 @@ static int _gpiod_get_raw_value(const struct gpio_desc *desc) · 1278 unmodified lines | ||
| 1279 | 1279 | chip = desc->chip; |
| 1280 | 1280 | offset = gpio_chip_hwgpio(desc); |
| 1281 | 1281 | value = chip->get ? chip->get(chip, offset) : -EIO; |
| 1282 | − value = value < 0 ? value : !!value; | |
| 1282 | + /* | |
| 1283 | + * FIXME: fix all drivers to clamp to [0,1] or return negative, | |
| 1284 | + * then change this to: | |
| 1285 | + * value = value < 0 ? value : !!value; | |
| 1286 | + * so we can properly propagate error codes. | |
| 1287 | + */ | |
| 1288 | + value = !!value; | |
| 1283 | 1289 | trace_gpio_value(desc_to_gpio(desc), 1, value); |
| 1284 | 1290 | return value; |
| 1285 | 1291 | } |
| @@ -1264,7 +1264,8 @@ struct amdgpu_cs_parser { · 1263 unmodified lines | ||
| 1264 | 1264 | struct ww_acquire_ctx ticket; |
| 1265 | 1265 | |
| 1266 | 1266 | /* user fence */ |
| 1267 | − struct amdgpu_user_fence uf; | |
| 1267 | + struct amdgpu_user_fence uf; | |
| 1268 | + struct amdgpu_bo_list_entry uf_entry; | |
| 1268 | 1269 | }; |
| 1269 | 1270 | |
| 1270 | 1271 | struct amdgpu_job { |
| @@ -127,6 +127,37 @@ int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · 126 unmodified lines | ||
| 127 | 127 | return 0; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | +static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | |
| 131 | + struct drm_amdgpu_cs_chunk_fence *fence_data) | |
| 132 | +{ | |
| 133 | + struct drm_gem_object *gobj; | |
| 134 | + uint32_t handle; | |
| 135 | + | |
| 136 | + handle = fence_data->handle; | |
| 137 | + gobj = drm_gem_object_lookup(p->adev->ddev, p->filp, | |
| 138 | + fence_data->handle); | |
| 139 | + if (gobj == NULL) | |
| 140 | + return -EINVAL; | |
| 141 | + | |
| 142 | + p->uf.bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); | |
| 143 | + p->uf.offset = fence_data->offset; | |
| 144 | + | |
| 145 | + if (amdgpu_ttm_tt_has_userptr(p->uf.bo->tbo.ttm)) { | |
| 146 | + drm_gem_object_unreference_unlocked(gobj); | |
| 147 | + return -EINVAL; | |
| 148 | + } | |
| 149 | + | |
| 150 | + p->uf_entry.robj = amdgpu_bo_ref(p->uf.bo); | |
| 151 | + p->uf_entry.prefered_domains = AMDGPU_GEM_DOMAIN_GTT; | |
| 152 | + p->uf_entry.allowed_domains = AMDGPU_GEM_DOMAIN_GTT; | |
| 153 | + p->uf_entry.priority = 0; | |
| 154 | + p->uf_entry.tv.bo = &p->uf_entry.robj->tbo; | |
| 155 | + p->uf_entry.tv.shared = true; | |
| 156 | + | |
| 157 | + drm_gem_object_unreference_unlocked(gobj); | |
| 158 | + return 0; | |
| 159 | +} | |
| 160 | + | |
| 130 | 161 | int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) |
| 131 | 162 | { |
| 132 | 163 | union drm_amdgpu_cs *cs = data; |
| @@ -207,28 +238,15 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) · 74 unmodified lines | ||
| 207 | 238 | |
| 208 | 239 | case AMDGPU_CHUNK_ID_FENCE: |
| 209 | 240 | size = sizeof(struct drm_amdgpu_cs_chunk_fence); |
| 210 | − if (p->chunks[i].length_dw * sizeof(uint32_t) >= size) { | |
| 211 | − uint32_t handle; | |
| 212 | − struct drm_gem_object *gobj; | |
| 213 | − struct drm_amdgpu_cs_chunk_fence *fence_data; | |
| 214 | − | |
| 215 | − fence_data = (void *)p->chunks[i].kdata; | |
| 216 | − handle = fence_data->handle; | |
| 217 | − gobj = drm_gem_object_lookup(p->adev->ddev, | |
| 218 | − p->filp, handle); | |
| 219 | − if (gobj == NULL) { | |
| 220 | − ret = -EINVAL; | |
| 221 | − goto free_partial_kdata; | |
| 222 | − } | |
| 223 | − | |
| 224 | − p->uf.bo = gem_to_amdgpu_bo(gobj); | |
| 225 | − amdgpu_bo_ref(p->uf.bo); | |
| 226 | − drm_gem_object_unreference_unlocked(gobj); | |
| 227 | − p->uf.offset = fence_data->offset; | |
| 228 | − } else { | |
| 241 | + if (p->chunks[i].length_dw * sizeof(uint32_t) < size) { | |
| 229 | 242 | ret = -EINVAL; |
| 230 | 243 | goto free_partial_kdata; |
| 231 | 244 | } |
| 245 | + | |
| 246 | + ret = amdgpu_cs_user_fence_chunk(p, (void *)p->chunks[i].kdata); | |
| 247 | + if (ret) | |
| 248 | + goto free_partial_kdata; | |
| 249 | + | |
| 232 | 250 | break; |
| 233 | 251 | |
| 234 | 252 | case AMDGPU_CHUNK_ID_DEPENDENCIES: |
| @@ -391,6 +409,9 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p) · 156 unmodified lines | ||
| 391 | 409 | p->vm_bos = amdgpu_vm_get_bos(p->adev, &fpriv->vm, |
| 392 | 410 | &p->validated); |
| 393 | 411 | |
| 412 | + if (p->uf.bo) | |
| 413 | + list_add(&p->uf_entry.tv.head, &p->validated); | |
| 414 | + | |
| 394 | 415 | if (need_mmap_lock) |
| 395 | 416 | down_read(¤t->mm->mmap_sem); |
| 396 | 417 | |
| @@ -488,8 +509,8 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bo · 91 unmodified lines | ||
| 488 | 509 | for (i = 0; i < parser->num_ibs; i++) |
| 489 | 510 | amdgpu_ib_free(parser->adev, &parser->ibs[i]); |
| 490 | 511 | kfree(parser->ibs); |
| 491 | − if (parser->uf.bo) | |
| 492 | − amdgpu_bo_unref(&parser->uf.bo); | |
| 512 | + amdgpu_bo_unref(&parser->uf.bo); | |
| 513 | + amdgpu_bo_unref(&parser->uf_entry.robj); | |
| 493 | 514 | } |
| 494 | 515 | |
| 495 | 516 | static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p, |
| @@ -229,7 +229,8 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect · 228 unmodified lines | ||
| 229 | 229 | mode_flags |= DRM_MODE_FLAG_3D_MASK; |
| 230 | 230 | |
| 231 | 231 | list_for_each_entry(mode, &connector->modes, head) { |
| 232 | − mode->status = drm_mode_validate_basic(mode); | |
| 232 | + if (mode->status == MODE_OK) | |
| 233 | + mode->status = drm_mode_validate_basic(mode); | |
| 233 | 234 | |
| 234 | 235 | if (mode->status == MODE_OK) |
| 235 | 236 | mode->status = drm_mode_validate_size(mode, maxX, maxY); |
| @@ -55,6 +55,9 @@ static int exynos_crtc_atomic_check(struct drm_crtc *crtc, · 54 unmodified lines | ||
| 55 | 55 | { |
| 56 | 56 | struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); |
| 57 | 57 | |
| 58 | + if (!state->enable) | |
| 59 | + return 0; | |
| 60 | + | |
| 58 | 61 | if (exynos_crtc->ops->atomic_check) |
| 59 | 62 | return exynos_crtc->ops->atomic_check(exynos_crtc, state); |
| 60 | 63 | |
| @@ -2193,8 +2193,17 @@ struct drm_i915_gem_request { · 2192 unmodified lines | ||
| 2193 | 2193 | struct drm_i915_private *i915; |
| 2194 | 2194 | struct intel_engine_cs *ring; |
| 2195 | 2195 | |
| 2196 | − /** GEM sequence number associated with this request. */ | |
| 2197 | − uint32_t seqno; | |
| 2196 | + /** GEM sequence number associated with the previous request, | |
| 2197 | + * when the HWS breadcrumb is equal to this the GPU is processing | |
| 2198 | + * this request. | |
| 2199 | + */ | |
| 2200 | + u32 previous_seqno; | |
| 2201 | + | |
| 2202 | + /** GEM sequence number associated with this request, | |
| 2203 | + * when the HWS breadcrumb is equal or greater than this the GPU | |
| 2204 | + * has finished processing this request. | |
| 2205 | + */ | |
| 2206 | + u32 seqno; | |
| 2198 | 2207 | |
| 2199 | 2208 | /** Position in the ringbuffer of the start of the request */ |
| 2200 | 2209 | u32 head; |
| @@ -2839,6 +2848,7 @@ i915_gem_object_ggtt_pin(struct drm_i915_gem_object *obj, · 638 unmodified lines | ||
| 2839 | 2848 | |
| 2840 | 2849 | int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level, |
| 2841 | 2850 | u32 flags); |
| 2851 | +void __i915_vma_set_map_and_fenceable(struct i915_vma *vma); | |
| 2842 | 2852 | int __must_check i915_vma_unbind(struct i915_vma *vma); |
| 2843 | 2853 | /* |
| 2844 | 2854 | * BEWARE: Do not use the function below unless you can _absolutely_ |
| @@ -2910,15 +2920,17 @@ i915_seqno_passed(uint32_t seq1, uint32_t seq2) · 65 unmodified lines | ||
| 2910 | 2920 | return (int32_t)(seq1 - seq2) >= 0; |
| 2911 | 2921 | } |
| 2912 | 2922 | |
| 2923 | +static inline bool i915_gem_request_started(struct drm_i915_gem_request *req, | |
| 2924 | + bool lazy_coherency) | |
| 2925 | +{ | |
| 2926 | + u32 seqno = req->ring->get_seqno(req->ring, lazy_coherency); | |
| 2927 | + return i915_seqno_passed(seqno, req->previous_seqno); | |
| 2928 | +} | |
| 2929 | + | |
| 2913 | 2930 | static inline bool i915_gem_request_completed(struct drm_i915_gem_request *req, |
| 2914 | 2931 | bool lazy_coherency) |
| 2915 | 2932 | { |
| 2916 | − u32 seqno; | |
| 2917 | − | |
| 2918 | − BUG_ON(req == NULL); | |
| 2919 | − | |
| 2920 | − seqno = req->ring->get_seqno(req->ring, lazy_coherency); | |
| 2921 | − | |
| 2933 | + u32 seqno = req->ring->get_seqno(req->ring, lazy_coherency); | |
| 2922 | 2934 | return i915_seqno_passed(seqno, req->seqno); |
| 2923 | 2935 | } |
| 2924 | 2936 | |
| @@ -1146,23 +1146,74 @@ static bool missed_irq(struct drm_i915_private *dev_priv, · 1145 unmodified lines | ||
| 1146 | 1146 | return test_bit(ring->id, &dev_priv->gpu_error.missed_irq_rings); |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | −static int __i915_spin_request(struct drm_i915_gem_request *req) | |
| 1149 | +static unsigned long local_clock_us(unsigned *cpu) | |
| 1150 | +{ | |
| 1151 | + unsigned long t; | |
| 1152 | + | |
| 1153 | + /* Cheaply and approximately convert from nanoseconds to microseconds. | |
| 1154 | + * The result and subsequent calculations are also defined in the same | |
| 1155 | + * approximate microseconds units. The principal source of timing | |
| 1156 | + * error here is from the simple truncation. | |
| 1157 | + * | |
| 1158 | + * Note that local_clock() is only defined wrt to the current CPU; | |
| 1159 | + * the comparisons are no longer valid if we switch CPUs. Instead of | |
| 1160 | + * blocking preemption for the entire busywait, we can detect the CPU | |
| 1161 | + * switch and use that as indicator of system load and a reason to | |
| 1162 | + * stop busywaiting, see busywait_stop(). | |
| 1163 | + */ | |
| 1164 | + *cpu = get_cpu(); | |
| 1165 | + t = local_clock() >> 10; | |
| 1166 | + put_cpu(); | |
| 1167 | + | |
| 1168 | + return t; | |
| 1169 | +} | |
| 1170 | + | |
| 1171 | +static bool busywait_stop(unsigned long timeout, unsigned cpu) | |
| 1172 | +{ | |
| 1173 | + unsigned this_cpu; | |
| 1174 | + | |
| 1175 | + if (time_after(local_clock_us(&this_cpu), timeout)) | |
| 1176 | + return true; | |
| 1177 | + | |
| 1178 | + return this_cpu != cpu; | |
| 1179 | +} | |
| 1180 | + | |
| 1181 | +static int __i915_spin_request(struct drm_i915_gem_request *req, int state) | |
| 1150 | 1182 | { |
| 1151 | 1183 | unsigned long timeout; |
| 1184 | + unsigned cpu; | |
| 1185 | + | |
| 1186 | + /* When waiting for high frequency requests, e.g. during synchronous | |
| 1187 | + * rendering split between the CPU and GPU, the finite amount of time | |
| 1188 | + * required to set up the irq and wait upon it limits the response | |
| 1189 | + * rate. By busywaiting on the request completion for a short while we | |
| 1190 | + * can service the high frequency waits as quick as possible. However, | |
| 1191 | + * if it is a slow request, we want to sleep as quickly as possible. | |
| 1192 | + * The tradeoff between waiting and sleeping is roughly the time it | |
| 1193 | + * takes to sleep on a request, on the order of a microsecond. | |
| 1194 | + */ | |
| 1152 | 1195 | |
| 1153 | − if (i915_gem_request_get_ring(req)->irq_refcount) | |
| 1196 | + if (req->ring->irq_refcount) | |
| 1154 | 1197 | return -EBUSY; |
| 1155 | 1198 | |
| 1156 | − timeout = jiffies + 1; | |
| 1199 | + /* Only spin if we know the GPU is processing this request */ | |
| 1200 | + if (!i915_gem_request_started(req, true)) | |
| 1201 | + return -EAGAIN; | |
| 1202 | + | |
| 1203 | + timeout = local_clock_us(&cpu) + 5; | |
| 1157 | 1204 | while (!need_resched()) { |
| 1158 | 1205 | if (i915_gem_request_completed(req, true)) |
| 1159 | 1206 | return 0; |
| 1160 | 1207 | |
| 1161 | − if (time_after_eq(jiffies, timeout)) | |
| 1208 | + if (signal_pending_state(state, current)) | |
| 1209 | + break; | |
| 1210 | + | |
| 1211 | + if (busywait_stop(timeout, cpu)) | |
| 1162 | 1212 | break; |
| 1163 | 1213 | |
| 1164 | 1214 | cpu_relax_lowlatency(); |
| 1165 | 1215 | } |
| 1216 | + | |
| 1166 | 1217 | if (i915_gem_request_completed(req, false)) |
| 1167 | 1218 | return 0; |
| 1168 | 1219 | |
| @@ -1197,6 +1248,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, · 28 unmodified lines | ||
| 1197 | 1248 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 1198 | 1249 | const bool irq_test_in_progress = |
| 1199 | 1250 | ACCESS_ONCE(dev_priv->gpu_error.test_irq_rings) & intel_ring_flag(ring); |
| 1251 | + int state = interruptible ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; | |
| 1200 | 1252 | DEFINE_WAIT(wait); |
| 1201 | 1253 | unsigned long timeout_expire; |
| 1202 | 1254 | s64 before, now; |
| @@ -1229,7 +1281,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, · 26 unmodified lines | ||
| 1229 | 1281 | before = ktime_get_raw_ns(); |
| 1230 | 1282 | |
| 1231 | 1283 | /* Optimistic spin for the next jiffie before touching IRQs */ |
| 1232 | − ret = __i915_spin_request(req); | |
| 1284 | + ret = __i915_spin_request(req, state); | |
| 1233 | 1285 | if (ret == 0) |
| 1234 | 1286 | goto out; |
| 1235 | 1287 | |
| @@ -1241,8 +1293,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, · 5 unmodified lines | ||
| 1241 | 1293 | for (;;) { |
| 1242 | 1294 | struct timer_list timer; |
| 1243 | 1295 | |
| 1244 | − prepare_to_wait(&ring->irq_queue, &wait, | |
| 1245 | − interruptible ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); | |
| 1296 | + prepare_to_wait(&ring->irq_queue, &wait, state); | |
| 1246 | 1297 | |
| 1247 | 1298 | /* We need to check whether any gpu reset happened in between |
| 1248 | 1299 | * the caller grabbing the seqno and now ... */ |
| @@ -1260,7 +1311,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, · 11 unmodified lines | ||
| 1260 | 1311 | break; |
| 1261 | 1312 | } |
| 1262 | 1313 | |
| 1263 | − if (interruptible && signal_pending(current)) { | |
| 1314 | + if (signal_pending_state(state, current)) { | |
| 1264 | 1315 | ret = -ERESTARTSYS; |
| 1265 | 1316 | break; |
| 1266 | 1317 | } |
| @@ -2554,6 +2605,7 @@ void __i915_add_request(struct drm_i915_gem_request *request, · 1287 unmodified lines | ||
| 2554 | 2605 | request->batch_obj = obj; |
| 2555 | 2606 | |
| 2556 | 2607 | request->emitted_jiffies = jiffies; |
| 2608 | + request->previous_seqno = ring->last_submitted_seqno; | |
| 2557 | 2609 | ring->last_submitted_seqno = request->seqno; |
| 2558 | 2610 | list_add_tail(&request->list, &ring->request_list); |
| 2559 | 2611 | |
| @@ -4080,6 +4132,29 @@ i915_vma_misplaced(struct i915_vma *vma, uint32_t alignment, uint64_t flags) · 1520 unmodified lines | ||
| 4080 | 4132 | return false; |
| 4081 | 4133 | } |
| 4082 | 4134 | |
| 4135 | +void __i915_vma_set_map_and_fenceable(struct i915_vma *vma) | |
| 4136 | +{ | |
| 4137 | + struct drm_i915_gem_object *obj = vma->obj; | |
| 4138 | + bool mappable, fenceable; | |
| 4139 | + u32 fence_size, fence_alignment; | |
| 4140 | + | |
| 4141 | + fence_size = i915_gem_get_gtt_size(obj->base.dev, | |
| 4142 | + obj->base.size, | |
| 4143 | + obj->tiling_mode); | |
| 4144 | + fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev, | |
| 4145 | + obj->base.size, | |
| 4146 | + obj->tiling_mode, | |
| 4147 | + true); | |
| 4148 | + | |
| 4149 | + fenceable = (vma->node.size == fence_size && | |
| 4150 | + (vma->node.start & (fence_alignment - 1)) == 0); | |
| 4151 | + | |
| 4152 | + mappable = (vma->node.start + fence_size <= | |
| 4153 | + to_i915(obj->base.dev)->gtt.mappable_end); | |
| 4154 | + | |
| 4155 | + obj->map_and_fenceable = mappable && fenceable; | |
| 4156 | +} | |
| 4157 | + | |
| 4083 | 4158 | static int |
| 4084 | 4159 | i915_gem_object_do_pin(struct drm_i915_gem_object *obj, |
| 4085 | 4160 | struct i915_address_space *vm, |
| @@ -4147,25 +4222,7 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj, · 61 unmodified lines | ||
| 4147 | 4222 | |
| 4148 | 4223 | if (ggtt_view && ggtt_view->type == I915_GGTT_VIEW_NORMAL && |
| 4149 | 4224 | (bound ^ vma->bound) & GLOBAL_BIND) { |
| 4150 | − bool mappable, fenceable; | |
| 4151 | − u32 fence_size, fence_alignment; | |
| 4152 | − | |
| 4153 | − fence_size = i915_gem_get_gtt_size(obj->base.dev, | |
| 4154 | − obj->base.size, | |
| 4155 | − obj->tiling_mode); | |
| 4156 | − fence_alignment = i915_gem_get_gtt_alignment(obj->base.dev, | |
| 4157 | − obj->base.size, | |
| 4158 | − obj->tiling_mode, | |
| 4159 | − true); | |
| 4160 | − | |
| 4161 | − fenceable = (vma->node.size == fence_size && | |
| 4162 | − (vma->node.start & (fence_alignment - 1)) == 0); | |
| 4163 | − | |
| 4164 | − mappable = (vma->node.start + fence_size <= | |
| 4165 | − dev_priv->gtt.mappable_end); | |
| 4166 | − | |
| 4167 | − obj->map_and_fenceable = mappable && fenceable; | |
| 4168 | − | |
| 4225 | + __i915_vma_set_map_and_fenceable(vma); | |
| 4169 | 4226 | WARN_ON(flags & PIN_MAPPABLE && !obj->map_and_fenceable); |
| 4170 | 4227 | } |
| 4171 | 4228 | |
| @@ -141,8 +141,6 @@ static void i915_gem_context_clean(struct intel_context *ctx) · 140 unmodified lines | ||
| 141 | 141 | if (!ppgtt) |
| 142 | 142 | return; |
| 143 | 143 | |
| 144 | − WARN_ON(!list_empty(&ppgtt->base.active_list)); | |
| 145 | − | |
| 146 | 144 | list_for_each_entry_safe(vma, next, &ppgtt->base.inactive_list, |
| 147 | 145 | mm_list) { |
| 148 | 146 | if (WARN_ON(__i915_vma_unbind_no_wait(vma))) |
| @@ -2676,6 +2676,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev, · 2675 unmodified lines | ||
| 2676 | 2676 | return ret; |
| 2677 | 2677 | } |
| 2678 | 2678 | vma->bound |= GLOBAL_BIND; |
| 2679 | + __i915_vma_set_map_and_fenceable(vma); | |
| 2679 | 2680 | list_add_tail(&vma->mm_list, &ggtt_vm->inactive_list); |
| 2680 | 2681 | } |
| 2681 | 2682 | |
| @@ -687,6 +687,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, · 686 unmodified lines | ||
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | vma->bound |= GLOBAL_BIND; |
| 690 | + __i915_vma_set_map_and_fenceable(vma); | |
| 690 | 691 | list_add_tail(&vma->mm_list, &ggtt->inactive_list); |
| 691 | 692 | } |
| 692 | 693 | |
| @@ -116,6 +116,7 @@ static void skylake_pfit_enable(struct intel_crtc *crtc); · 115 unmodified lines | ||
| 116 | 116 | static void ironlake_pfit_disable(struct intel_crtc *crtc, bool force); |
| 117 | 117 | static void ironlake_pfit_enable(struct intel_crtc *crtc); |
| 118 | 118 | static void intel_modeset_setup_hw_state(struct drm_device *dev); |
| 119 | +static void intel_pre_disable_primary(struct drm_crtc *crtc); | |
| 119 | 120 | |
| 120 | 121 | typedef struct { |
| 121 | 122 | int min, max; |
| @@ -2607,6 +2608,8 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, · 2485 unmodified lines | ||
| 2607 | 2608 | struct drm_i915_gem_object *obj; |
| 2608 | 2609 | struct drm_plane *primary = intel_crtc->base.primary; |
| 2609 | 2610 | struct drm_plane_state *plane_state = primary->state; |
| 2611 | + struct drm_crtc_state *crtc_state = intel_crtc->base.state; | |
| 2612 | + struct intel_plane *intel_plane = to_intel_plane(primary); | |
| 2610 | 2613 | struct drm_framebuffer *fb; |
| 2611 | 2614 | |
| 2612 | 2615 | if (!plane_config->fb) |
| @@ -2643,6 +2646,18 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, · 30 unmodified lines | ||
| 2643 | 2646 | } |
| 2644 | 2647 | } |
| 2645 | 2648 | |
| 2649 | + /* | |
| 2650 | + * We've failed to reconstruct the BIOS FB. Current display state | |
| 2651 | + * indicates that the primary plane is visible, but has a NULL FB, | |
| 2652 | + * which will lead to problems later if we don't fix it up. The | |
| 2653 | + * simplest solution is to just disable the primary plane now and | |
| 2654 | + * pretend the BIOS never had it enabled. | |
| 2655 | + */ | |
| 2656 | + to_intel_plane_state(plane_state)->visible = false; | |
| 2657 | + crtc_state->plane_mask &= ~(1 << drm_plane_index(primary)); | |
| 2658 | + intel_pre_disable_primary(&intel_crtc->base); | |
| 2659 | + intel_plane->disable_plane(primary, &intel_crtc->base); | |
| 2660 | + | |
| 2646 | 2661 | return; |
| 2647 | 2662 | |
| 2648 | 2663 | valid_fb: |
| @@ -6309,9 +6324,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc) · 3660 unmodified lines | ||
| 6309 | 6324 | if (to_intel_plane_state(crtc->primary->state)->visible) { |
| 6310 | 6325 | intel_crtc_wait_for_pending_flips(crtc); |
| 6311 | 6326 | intel_pre_disable_primary(crtc); |
| 6327 | + | |
| 6328 | + intel_crtc_disable_planes(crtc, 1 << drm_plane_index(crtc->primary)); | |
| 6329 | + to_intel_plane_state(crtc->primary->state)->visible = false; | |
| 6312 | 6330 | } |
| 6313 | 6331 | |
| 6314 | − intel_crtc_disable_planes(crtc, crtc->state->plane_mask); | |
| 6315 | 6332 | dev_priv->display.crtc_disable(crtc); |
| 6316 | 6333 | intel_crtc->active = false; |
| 6317 | 6334 | intel_update_watermarks(crtc); |
| @@ -9908,14 +9925,14 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc, · 3590 unmodified lines | ||
| 9908 | 9925 | return true; |
| 9909 | 9926 | } |
| 9910 | 9927 | |
| 9911 | −static void i845_update_cursor(struct drm_crtc *crtc, u32 base) | |
| 9928 | +static void i845_update_cursor(struct drm_crtc *crtc, u32 base, bool on) | |
| 9912 | 9929 | { |
| 9913 | 9930 | struct drm_device *dev = crtc->dev; |
| 9914 | 9931 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 9915 | 9932 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 9916 | 9933 | uint32_t cntl = 0, size = 0; |
| 9917 | 9934 | |
| 9918 | − if (base) { | |
| 9935 | + if (on) { | |
| 9919 | 9936 | unsigned int width = intel_crtc->base.cursor->state->crtc_w; |
| 9920 | 9937 | unsigned int height = intel_crtc->base.cursor->state->crtc_h; |
| 9921 | 9938 | unsigned int stride = roundup_pow_of_two(width) * 4; |
| @@ -9970,16 +9987,15 @@ static void i845_update_cursor(struct drm_crtc *crtc, u32 base) · 48 unmodified lines | ||
| 9970 | 9987 | } |
| 9971 | 9988 | } |
| 9972 | 9989 | |
| 9973 | −static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base) | |
| 9990 | +static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base, bool on) | |
| 9974 | 9991 | { |
| 9975 | 9992 | struct drm_device *dev = crtc->dev; |
| 9976 | 9993 | struct drm_i915_private *dev_priv = dev->dev_private; |
| 9977 | 9994 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
| 9978 | 9995 | int pipe = intel_crtc->pipe; |
| 9979 | − uint32_t cntl; | |
| 9996 | + uint32_t cntl = 0; | |
| 9980 | 9997 | |
| 9981 | − cntl = 0; | |
| 9982 | − if (base) { | |
| 9998 | + if (on) { | |
| 9983 | 9999 | cntl = MCURSOR_GAMMA_ENABLE; |
| 9984 | 10000 | switch (intel_crtc->base.cursor->state->crtc_w) { |
| 9985 | 10001 | case 64: |
| @@ -10030,18 +10046,17 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, · 44 unmodified lines | ||
| 10030 | 10046 | int y = cursor_state->crtc_y; |
| 10031 | 10047 | u32 base = 0, pos = 0; |
| 10032 | 10048 | |
| 10033 | − if (on) | |
| 10034 | − base = intel_crtc->cursor_addr; | |
| 10049 | + base = intel_crtc->cursor_addr; | |
| 10035 | 10050 | |
| 10036 | 10051 | if (x >= intel_crtc->config->pipe_src_w) |
| 10037 | − base = 0; | |
| 10052 | + on = false; | |
| 10038 | 10053 | |
| 10039 | 10054 | if (y >= intel_crtc->config->pipe_src_h) |
| 10040 | − base = 0; | |
| 10055 | + on = false; | |
| 10041 | 10056 | |
| 10042 | 10057 | if (x < 0) { |
| 10043 | 10058 | if (x + cursor_state->crtc_w <= 0) |
| 10044 | − base = 0; | |
| 10059 | + on = false; | |
| 10045 | 10060 | |
| 10046 | 10061 | pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT; |
| 10047 | 10062 | x = -x; |
| @@ -10050,16 +10065,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, · 2 unmodified lines | ||
| 10050 | 10065 | |
| 10051 | 10066 | if (y < 0) { |
| 10052 | 10067 | if (y + cursor_state->crtc_h <= 0) |
| 10053 | − base = 0; | |
| 10068 | + on = false; | |
| 10054 | 10069 | |
| 10055 | 10070 | pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT; |
| 10056 | 10071 | y = -y; |
| 10057 | 10072 | } |
| 10058 | 10073 | pos |= y << CURSOR_Y_SHIFT; |
| 10059 | 10074 | |
| 10060 | − if (base == 0 && intel_crtc->cursor_base == 0) | |
| 10061 | − return; | |
| 10062 | − | |
| 10063 | 10075 | I915_WRITE(CURPOS(pipe), pos); |
| 10064 | 10076 | |
| 10065 | 10077 | /* ILK+ do this automagically */ |
| @@ -10070,9 +10082,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, · 4 unmodified lines | ||
| 10070 | 10082 | } |
| 10071 | 10083 | |
| 10072 | 10084 | if (IS_845G(dev) || IS_I865G(dev)) |
| 10073 | − i845_update_cursor(crtc, base); | |
| 10085 | + i845_update_cursor(crtc, base, on); | |
| 10074 | 10086 | else |
| 10075 | − i9xx_update_cursor(crtc, base); | |
| 10087 | + i9xx_update_cursor(crtc, base, on); | |
| 10076 | 10088 | } |
| 10077 | 10089 | |
| 10078 | 10090 | static bool cursor_size_ok(struct drm_device *dev, |
| @@ -12111,18 +12123,22 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, · 2032 unmodified lines | ||
| 12111 | 12123 | static bool check_digital_port_conflicts(struct drm_atomic_state *state) |
| 12112 | 12124 | { |
| 12113 | 12125 | struct drm_device *dev = state->dev; |
| 12114 | − struct intel_encoder *encoder; | |
| 12115 | 12126 | struct drm_connector *connector; |
| 12116 | − struct drm_connector_state *connector_state; | |
| 12117 | 12127 | unsigned int used_ports = 0; |
| 12118 | − int i; | |
| 12119 | 12128 | |
| 12120 | 12129 | /* |
| 12121 | 12130 | * Walk the connector list instead of the encoder |
| 12122 | 12131 | * list to detect the problem on ddi platforms |
| 12123 | 12132 | * where there's just one encoder per digital port. |
| 12124 | 12133 | */ |
| 12125 | − for_each_connector_in_state(state, connector, connector_state, i) { | |
| 12134 | + drm_for_each_connector(connector, dev) { | |
| 12135 | + struct drm_connector_state *connector_state; | |
| 12136 | + struct intel_encoder *encoder; | |
| 12137 | + | |
| 12138 | + connector_state = drm_atomic_get_existing_connector_state(state, connector); | |
| 12139 | + if (!connector_state) | |
| 12140 | + connector_state = connector->state; | |
| 12141 | + | |
| 12126 | 12142 | if (!connector_state->best_encoder) |
| 12127 | 12143 | continue; |
| 12128 | 12144 | |
| @@ -13716,6 +13732,7 @@ intel_check_cursor_plane(struct drm_plane *plane, · 1587 unmodified lines | ||
| 13716 | 13732 | struct drm_crtc *crtc = crtc_state->base.crtc; |
| 13717 | 13733 | struct drm_framebuffer *fb = state->base.fb; |
| 13718 | 13734 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
| 13735 | + enum pipe pipe = to_intel_plane(plane)->pipe; | |
| 13719 | 13736 | unsigned stride; |
| 13720 | 13737 | int ret; |
| 13721 | 13738 | |
| @@ -13749,6 +13766,22 @@ intel_check_cursor_plane(struct drm_plane *plane, · 27 unmodified lines | ||
| 13749 | 13766 | return -EINVAL; |
| 13750 | 13767 | } |
| 13751 | 13768 | |
| 13769 | + /* | |
| 13770 | + * There's something wrong with the cursor on CHV pipe C. | |
| 13771 | + * If it straddles the left edge of the screen then | |
| 13772 | + * moving it away from the edge or disabling it often | |
| 13773 | + * results in a pipe underrun, and often that can lead to | |
| 13774 | + * dead pipe (constant underrun reported, and it scans | |
| 13775 | + * out just a solid color). To recover from that, the | |
| 13776 | + * display power well must be turned off and on again. | |
| 13777 | + * Refuse the put the cursor into that compromised position. | |
| 13778 | + */ | |
| 13779 | + if (IS_CHERRYVIEW(plane->dev) && pipe == PIPE_C && | |
| 13780 | + state->visible && state->base.crtc_x < 0) { | |
| 13781 | + DRM_DEBUG_KMS("CHV cursor C not allowed to straddle the left screen edge\n"); | |
| 13782 | + return -EINVAL; | |
| 13783 | + } | |
| 13784 | + | |
| 13752 | 13785 | return 0; |
| 13753 | 13786 | } |
| 13754 | 13787 | |
| @@ -13772,9 +13805,6 @@ intel_commit_cursor_plane(struct drm_plane *plane, · 17 unmodified lines | ||
| 13772 | 13805 | crtc = crtc ? crtc : plane->crtc; |
| 13773 | 13806 | intel_crtc = to_intel_crtc(crtc); |
| 13774 | 13807 | |
| 13775 | − if (intel_crtc->cursor_bo == obj) | |
| 13776 | − goto update; | |
| 13777 | − | |
| 13778 | 13808 | if (!obj) |
| 13779 | 13809 | addr = 0; |
| 13780 | 13810 | else if (!INTEL_INFO(dev)->cursor_needs_physical) |
| @@ -13783,9 +13813,7 @@ intel_commit_cursor_plane(struct drm_plane *plane, · 2 unmodified lines | ||
| 13783 | 13813 | addr = obj->phys_handle->busaddr; |
| 13784 | 13814 | |
| 13785 | 13815 | intel_crtc->cursor_addr = addr; |
| 13786 | − intel_crtc->cursor_bo = obj; | |
| 13787 | 13816 | |
| 13788 | −update: | |
| 13789 | 13817 | if (crtc->state->active) |
| 13790 | 13818 | intel_crtc_update_cursor(crtc, state->visible); |
| 13791 | 13819 | } |
| @@ -550,7 +550,6 @@ struct intel_crtc { · 549 unmodified lines | ||
| 550 | 550 | int adjusted_x; |
| 551 | 551 | int adjusted_y; |
| 552 | 552 | |
| 553 | − struct drm_i915_gem_object *cursor_bo; | |
| 554 | 553 | uint32_t cursor_addr; |
| 555 | 554 | uint32_t cursor_cntl; |
| 556 | 555 | uint32_t cursor_size; |
| @@ -1374,17 +1374,18 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) · 1373 unmodified lines | ||
| 1374 | 1374 | struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector); |
| 1375 | 1375 | struct drm_i915_private *dev_priv = to_i915(connector->dev); |
| 1376 | 1376 | bool live_status = false; |
| 1377 | − unsigned int retry = 3; | |
| 1377 | + unsigned int try; | |
| 1378 | 1378 | |
| 1379 | 1379 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
| 1380 | 1380 | connector->base.id, connector->name); |
| 1381 | 1381 | |
| 1382 | 1382 | intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS); |
| 1383 | 1383 | |
| 1384 | − while (!live_status && --retry) { | |
| 1384 | + for (try = 0; !live_status && try < 9; try++) { | |
| 1385 | + if (try) | |
| 1386 | + msleep(10); | |
| 1385 | 1387 | live_status = intel_digital_port_connected(dev_priv, |
| 1386 | 1388 | hdmi_to_dig_port(intel_hdmi)); |
| 1387 | − mdelay(10); | |
| 1388 | 1389 | } |
| 1389 | 1390 | |
| 1390 | 1391 | if (!live_status) |
| @@ -4782,8 +4782,7 @@ static void gen9_enable_rc6(struct drm_device *dev) · 4781 unmodified lines | ||
| 4782 | 4782 | /* 2b: Program RC6 thresholds.*/ |
| 4783 | 4783 | |
| 4784 | 4784 | /* WaRsDoubleRc6WrlWithCoarsePowerGating: Doubling WRL only when CPG is enabled */ |
| 4785 | − if (IS_SKYLAKE(dev) && !((IS_SKL_GT3(dev) || IS_SKL_GT4(dev)) && | |
| 4786 | − (INTEL_REVID(dev) <= SKL_REVID_E0))) | |
| 4785 | + if (IS_SKYLAKE(dev)) | |
| 4787 | 4786 | I915_WRITE(GEN6_RC6_WAKE_RATE_LIMIT, 108 << 16); |
| 4788 | 4787 | else |
| 4789 | 4788 | I915_WRITE(GEN6_RC6_WAKE_RATE_LIMIT, 54 << 16); |
| @@ -4825,7 +4824,7 @@ static void gen9_enable_rc6(struct drm_device *dev) · 35 unmodified lines | ||
| 4825 | 4824 | * WaRsDisableCoarsePowerGating:skl,bxt - Render/Media PG need to be disabled with RC6. |
| 4826 | 4825 | */ |
| 4827 | 4826 | if ((IS_BROXTON(dev) && (INTEL_REVID(dev) < BXT_REVID_B0)) || |
| 4828 | − ((IS_SKL_GT3(dev) || IS_SKL_GT4(dev)) && (INTEL_REVID(dev) <= SKL_REVID_E0))) | |
| 4827 | + ((IS_SKL_GT3(dev) || IS_SKL_GT4(dev)) && (INTEL_REVID(dev) <= SKL_REVID_F0))) | |
| 4829 | 4828 | I915_WRITE(GEN9_PG_ENABLE, 0); |
| 4830 | 4829 | else |
| 4831 | 4830 | I915_WRITE(GEN9_PG_ENABLE, (rc6_mask & GEN6_RC_CTL_RC6_ENABLE) ? |
| @@ -156,6 +156,7 @@ nv40_gr_chan_new(struct nvkm_gr *base, struct nvkm_fifo_chan *fifoch, · 155 unmodified lines | ||
| 156 | 156 | return -ENOMEM; |
| 157 | 157 | nvkm_object_ctor(&nv40_gr_chan, oclass, &chan->object); |
| 158 | 158 | chan->gr = gr; |
| 159 | + chan->fifo = fifoch; | |
| 159 | 160 | *pobject = &chan->object; |
| 160 | 161 | |
| 161 | 162 | spin_lock_irqsave(&chan->gr->base.engine.lock, flags); |
| @@ -83,6 +83,7 @@ nvbios_fan_parse(struct nvkm_bios *bios, struct nvbios_therm_fan *fan) · 82 unmodified lines | ||
| 83 | 83 | fan->type = NVBIOS_THERM_FAN_UNK; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | + fan->fan_mode = NVBIOS_THERM_FAN_LINEAR; | |
| 86 | 87 | fan->min_duty = nvbios_rd08(bios, data + 0x02); |
| 87 | 88 | fan->max_duty = nvbios_rd08(bios, data + 0x03); |
| 88 | 89 | |
| @@ -112,11 +112,8 @@ static int omap_fbdev_create(struct drm_fb_helper *helper, · 111 unmodified lines | ||
| 112 | 112 | dma_addr_t paddr; |
| 113 | 113 | int ret; |
| 114 | 114 | |
| 115 | − /* only doing ARGB32 since this is what is needed to alpha-blend | |
| 116 | − * with video overlays: | |
| 117 | − */ | |
| 118 | 115 | sizes->surface_bpp = 32; |
| 119 | − sizes->surface_depth = 32; | |
| 116 | + sizes->surface_depth = 24; | |
| 120 | 117 | |
| 121 | 118 | DBG("create fbdev: %dx%d@%d (%dx%d)", sizes->surface_width, |
| 122 | 119 | sizes->surface_height, sizes->surface_bpp, |
| @@ -1217,6 +1217,7 @@ config SENSORS_PWM_FAN · 1216 unmodified lines | ||
| 1217 | 1217 | config SENSORS_SHT15 |
| 1218 | 1218 | tristate "Sensiron humidity and temperature sensors. SHT15 and compat." |
| 1219 | 1219 | depends on GPIOLIB || COMPILE_TEST |
| 1220 | + select BITREVERSE | |
| 1220 | 1221 | help |
| 1221 | 1222 | If you say yes here you get support for the Sensiron SHT10, SHT11, |
| 1222 | 1223 | SHT15, SHT71, SHT75 humidity and temperature sensors. |
| @@ -58,6 +58,7 @@ struct tmp102 { · 57 unmodified lines | ||
| 58 | 58 | u16 config_orig; |
| 59 | 59 | unsigned long last_update; |
| 60 | 60 | int temp[3]; |
| 61 | + bool first_time; | |
| 61 | 62 | }; |
| 62 | 63 | |
| 63 | 64 | /* convert left adjusted 13-bit TMP102 register value to milliCelsius */ |
| @@ -93,6 +94,7 @@ static struct tmp102 *tmp102_update_device(struct device *dev) · 29 unmodified lines | ||
| 93 | 94 | tmp102->temp[i] = tmp102_reg_to_mC(status); |
| 94 | 95 | } |
| 95 | 96 | tmp102->last_update = jiffies; |
| 97 | + tmp102->first_time = false; | |
| 96 | 98 | } |
| 97 | 99 | mutex_unlock(&tmp102->lock); |
| 98 | 100 | return tmp102; |
| @@ -102,6 +104,12 @@ static int tmp102_read_temp(void *dev, int *temp) · 3 unmodified lines | ||
| 102 | 104 | { |
| 103 | 105 | struct tmp102 *tmp102 = tmp102_update_device(dev); |
| 104 | 106 | |
| 107 | + /* Is it too early even to return a conversion? */ | |
| 108 | + if (tmp102->first_time) { | |
| 109 | + dev_dbg(dev, "%s: Conversion not ready yet..\n", __func__); | |
| 110 | + return -EAGAIN; | |
| 111 | + } | |
| 112 | + | |
| 105 | 113 | *temp = tmp102->temp[0]; |
| 106 | 114 | |
| 107 | 115 | return 0; |
| @@ -114,6 +122,10 @@ static ssize_t tmp102_show_temp(struct device *dev, · 6 unmodified lines | ||
| 114 | 122 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); |
| 115 | 123 | struct tmp102 *tmp102 = tmp102_update_device(dev); |
| 116 | 124 | |
| 125 | + /* Is it too early even to return a read? */ | |
| 126 | + if (tmp102->first_time) | |
| 127 | + return -EAGAIN; | |
| 128 | + | |
| 117 | 129 | return sprintf(buf, "%d\n", tmp102->temp[sda->index]); |
| 118 | 130 | } |
| 119 | 131 | |
| @@ -207,7 +219,9 @@ static int tmp102_probe(struct i2c_client *client, · 87 unmodified lines | ||
| 207 | 219 | status = -ENODEV; |
| 208 | 220 | goto fail_restore_config; |
| 209 | 221 | } |
| 210 | − tmp102->last_update = jiffies - HZ; | |
| 222 | + tmp102->last_update = jiffies; | |
| 223 | + /* Mark that we are not ready with data until conversion is complete */ | |
| 224 | + tmp102->first_time = true; | |
| 211 | 225 | mutex_init(&tmp102->lock); |
| 212 | 226 | |
| 213 | 227 | hwmon_dev = hwmon_device_register_with_groups(dev, client->name, |
| @@ -202,8 +202,15 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev) · 201 unmodified lines | ||
| 202 | 202 | * d is always 6 on Keystone I2C controller |
| 203 | 203 | */ |
| 204 | 204 | |
| 205 | − /* get minimum of 7 MHz clock, but max of 12 MHz */ | |
| 206 | − psc = (input_clock / 7000000) - 1; | |
| 205 | + /* | |
| 206 | + * Both Davinci and current Keystone User Guides recommend a value | |
| 207 | + * between 7MHz and 12MHz. In reality 7MHz module clock doesn't | |
| 208 | + * always produce enough margin between SDA and SCL transitions. | |
| 209 | + * Measurements show that the higher the module clock is, the | |
| 210 | + * bigger is the margin, providing more reliable communication. | |
| 211 | + * So we better target for 12MHz. | |
| 212 | + */ | |
| 213 | + psc = (input_clock / 12000000) - 1; | |
| 207 | 214 | if ((input_clock / (psc + 1)) > 12000000) |
| 208 | 215 | psc++; /* better to run under spec than over */ |
| 209 | 216 | d = (psc >= 2) ? 5 : 7 - psc; |
| @@ -813,6 +813,12 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) · 812 unmodified lines | ||
| 813 | 813 | tx_aborted: |
| 814 | 814 | if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err) |
| 815 | 815 | complete(&dev->cmd_complete); |
| 816 | + else if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK)) { | |
| 817 | + /* workaround to trigger pending interrupt */ | |
| 818 | + stat = dw_readl(dev, DW_IC_INTR_MASK); | |
| 819 | + i2c_dw_disable_int(dev); | |
| 820 | + dw_writel(dev, stat, DW_IC_INTR_MASK); | |
| 821 | + } | |
| 816 | 822 | |
| 817 | 823 | return IRQ_HANDLED; |
| 818 | 824 | } |
| @@ -111,6 +111,7 @@ struct dw_i2c_dev { · 110 unmodified lines | ||
| 111 | 111 | |
| 112 | 112 | #define ACCESS_SWAP 0x00000001 |
| 113 | 113 | #define ACCESS_16BIT 0x00000002 |
| 114 | +#define ACCESS_INTR_MASK 0x00000004 | |
| 114 | 115 | |
| 115 | 116 | extern int i2c_dw_init(struct dw_i2c_dev *dev); |
| 116 | 117 | extern void i2c_dw_disable(struct dw_i2c_dev *dev); |
| @@ -93,6 +93,7 @@ static void dw_i2c_acpi_params(struct platform_device *pdev, char method[], · 92 unmodified lines | ||
| 93 | 93 | static int dw_i2c_acpi_configure(struct platform_device *pdev) |
| 94 | 94 | { |
| 95 | 95 | struct dw_i2c_dev *dev = platform_get_drvdata(pdev); |
| 96 | + const struct acpi_device_id *id; | |
| 96 | 97 | |
| 97 | 98 | dev->adapter.nr = -1; |
| 98 | 99 | dev->tx_fifo_depth = 32; |
| @@ -106,6 +107,10 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) · 7 unmodified lines | ||
| 106 | 107 | dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, |
| 107 | 108 | &dev->sda_hold_time); |
| 108 | 109 | |
| 110 | + id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); | |
| 111 | + if (id && id->driver_data) | |
| 112 | + dev->accessor_flags |= (u32)id->driver_data; | |
| 113 | + | |
| 109 | 114 | return 0; |
| 110 | 115 | } |
| 111 | 116 | |
| @@ -116,7 +121,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = { · 4 unmodified lines | ||
| 116 | 121 | { "INT3433", 0 }, |
| 117 | 122 | { "80860F41", 0 }, |
| 118 | 123 | { "808622C1", 0 }, |
| 119 | − { "AMD0010", 0 }, | |
| 124 | + { "AMD0010", ACCESS_INTR_MASK }, | |
| 120 | 125 | { } |
| 121 | 126 | }; |
| 122 | 127 | MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match); |
| @@ -240,12 +245,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 117 unmodified lines | ||
| 240 | 245 | } |
| 241 | 246 | |
| 242 | 247 | r = i2c_dw_probe(dev); |
| 243 | − if (r) { | |
| 248 | + if (r && !dev->pm_runtime_disabled) | |
| 244 | 249 | pm_runtime_disable(&pdev->dev); |
| 245 | − return r; | |
| 246 | − } | |
| 247 | 250 | |
| 248 | − return 0; | |
| 251 | + return r; | |
| 249 | 252 | } |
| 250 | 253 | |
| 251 | 254 | static int dw_i2c_plat_remove(struct platform_device *pdev) |
| @@ -260,7 +263,8 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) · 8 unmodified lines | ||
| 260 | 263 | |
| 261 | 264 | pm_runtime_dont_use_autosuspend(&pdev->dev); |
| 262 | 265 | pm_runtime_put_sync(&pdev->dev); |
| 263 | − pm_runtime_disable(&pdev->dev); | |
| 266 | + if (!dev->pm_runtime_disabled) | |
| 267 | + pm_runtime_disable(&pdev->dev); | |
| 264 | 268 | |
| 265 | 269 | return 0; |
| 266 | 270 | } |
| @@ -1119,6 +1119,8 @@ static int i2c_imx_probe(struct platform_device *pdev) · 1118 unmodified lines | ||
| 1119 | 1119 | i2c_imx, IMX_I2C_I2CR); |
| 1120 | 1120 | imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR); |
| 1121 | 1121 | |
| 1122 | + i2c_imx_init_recovery_info(i2c_imx, pdev); | |
| 1123 | + | |
| 1122 | 1124 | /* Add I2C adapter */ |
| 1123 | 1125 | ret = i2c_add_numbered_adapter(&i2c_imx->adapter); |
| 1124 | 1126 | if (ret < 0) { |
| @@ -1126,8 +1128,6 @@ static int i2c_imx_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 1126 | 1128 | goto clk_disable; |
| 1127 | 1129 | } |
| 1128 | 1130 | |
| 1129 | − i2c_imx_init_recovery_info(i2c_imx, pdev); | |
| 1130 | − | |
| 1131 | 1131 | /* Set up platform driver data */ |
| 1132 | 1132 | platform_set_drvdata(pdev, i2c_imx); |
| 1133 | 1133 | clk_disable_unprepare(i2c_imx->clk); |
| @@ -146,6 +146,8 @@ struct mv64xxx_i2c_data { · 145 unmodified lines | ||
| 146 | 146 | bool errata_delay; |
| 147 | 147 | struct reset_control *rstc; |
| 148 | 148 | bool irq_clear_inverted; |
| 149 | + /* Clk div is 2 to the power n, not 2 to the power n + 1 */ | |
| 150 | + bool clk_n_base_0; | |
| 149 | 151 | }; |
| 150 | 152 | |
| 151 | 153 | static struct mv64xxx_i2c_regs mv64xxx_i2c_regs_mv64xxx = { |
| @@ -757,25 +759,29 @@ MODULE_DEVICE_TABLE(of, mv64xxx_i2c_of_match_table); · 605 unmodified lines | ||
| 757 | 759 | #ifdef CONFIG_OF |
| 758 | 760 | #ifdef CONFIG_HAVE_CLK |
| 759 | 761 | static int |
| 760 | −mv64xxx_calc_freq(const int tclk, const int n, const int m) | |
| 762 | +mv64xxx_calc_freq(struct mv64xxx_i2c_data *drv_data, | |
| 763 | + const int tclk, const int n, const int m) | |
| 761 | 764 | { |
| 762 | − return tclk / (10 * (m + 1) * (2 << n)); | |
| 765 | + if (drv_data->clk_n_base_0) | |
| 766 | + return tclk / (10 * (m + 1) * (1 << n)); | |
| 767 | + else | |
| 768 | + return tclk / (10 * (m + 1) * (2 << n)); | |
| 763 | 769 | } |
| 764 | 770 | |
| 765 | 771 | static bool |
| 766 | −mv64xxx_find_baud_factors(const u32 req_freq, const u32 tclk, u32 *best_n, | |
| 767 | − u32 *best_m) | |
| 772 | +mv64xxx_find_baud_factors(struct mv64xxx_i2c_data *drv_data, | |
| 773 | + const u32 req_freq, const u32 tclk) | |
| 768 | 774 | { |
| 769 | 775 | int freq, delta, best_delta = INT_MAX; |
| 770 | 776 | int m, n; |
| 771 | 777 | |
| 772 | 778 | for (n = 0; n <= 7; n++) |
| 773 | 779 | for (m = 0; m <= 15; m++) { |
| 774 | − freq = mv64xxx_calc_freq(tclk, n, m); | |
| 780 | + freq = mv64xxx_calc_freq(drv_data, tclk, n, m); | |
| 775 | 781 | delta = req_freq - freq; |
| 776 | 782 | if (delta >= 0 && delta < best_delta) { |
| 777 | − *best_m = m; | |
| 778 | − *best_n = n; | |
| 783 | + drv_data->freq_m = m; | |
| 784 | + drv_data->freq_n = n; | |
| 779 | 785 | best_delta = delta; |
| 780 | 786 | } |
| 781 | 787 | if (best_delta == 0) |
| @@ -813,8 +819,11 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, · 31 unmodified lines | ||
| 813 | 819 | if (of_property_read_u32(np, "clock-frequency", &bus_freq)) |
| 814 | 820 | bus_freq = 100000; /* 100kHz by default */ |
| 815 | 821 | |
| 816 | − if (!mv64xxx_find_baud_factors(bus_freq, tclk, | |
| 817 | − &drv_data->freq_n, &drv_data->freq_m)) { | |
| 822 | + if (of_device_is_compatible(np, "allwinner,sun4i-a10-i2c") || | |
| 823 | + of_device_is_compatible(np, "allwinner,sun6i-a31-i2c")) | |
| 824 | + drv_data->clk_n_base_0 = true; | |
| 825 | + | |
| 826 | + if (!mv64xxx_find_baud_factors(drv_data, bus_freq, tclk)) { | |
| 818 | 827 | rc = -EINVAL; |
| 819 | 828 | goto out; |
| 820 | 829 | } |
| @@ -576,7 +576,7 @@ static int rcar_reg_slave(struct i2c_client *slave) · 575 unmodified lines | ||
| 576 | 576 | if (slave->flags & I2C_CLIENT_TEN) |
| 577 | 577 | return -EAFNOSUPPORT; |
| 578 | 578 | |
| 579 | − pm_runtime_forbid(rcar_i2c_priv_to_dev(priv)); | |
| 579 | + pm_runtime_get_sync(rcar_i2c_priv_to_dev(priv)); | |
| 580 | 580 | |
| 581 | 581 | priv->slave = slave; |
| 582 | 582 | rcar_i2c_write(priv, ICSAR, slave->addr); |
| @@ -598,7 +598,7 @@ static int rcar_unreg_slave(struct i2c_client *slave) · 15 unmodified lines | ||
| 598 | 598 | |
| 599 | 599 | priv->slave = NULL; |
| 600 | 600 | |
| 601 | − pm_runtime_allow(rcar_i2c_priv_to_dev(priv)); | |
| 601 | + pm_runtime_put(rcar_i2c_priv_to_dev(priv)); | |
| 602 | 602 | |
| 603 | 603 | return 0; |
| 604 | 604 | } |
| @@ -908,7 +908,7 @@ static int rk3x_i2c_probe(struct platform_device *pdev) · 907 unmodified lines | ||
| 908 | 908 | &i2c->scl_fall_ns)) |
| 909 | 909 | i2c->scl_fall_ns = 300; |
| 910 | 910 | if (of_property_read_u32(pdev->dev.of_node, "i2c-sda-falling-time-ns", |
| 911 | − &i2c->scl_fall_ns)) | |
| 911 | + &i2c->sda_fall_ns)) | |
| 912 | 912 | i2c->sda_fall_ns = i2c->scl_fall_ns; |
| 913 | 913 | |
| 914 | 914 | strlcpy(i2c->adap.name, "rk3x-i2c", sizeof(i2c->adap.name)); |
| @@ -822,7 +822,7 @@ static int st_i2c_probe(struct platform_device *pdev) · 821 unmodified lines | ||
| 822 | 822 | |
| 823 | 823 | adap = &i2c_dev->adap; |
| 824 | 824 | i2c_set_adapdata(adap, i2c_dev); |
| 825 | − snprintf(adap->name, sizeof(adap->name), "ST I2C(0x%pa)", &res->start); | |
| 825 | + snprintf(adap->name, sizeof(adap->name), "ST I2C(%pa)", &res->start); | |
| 826 | 826 | adap->owner = THIS_MODULE; |
| 827 | 827 | adap->timeout = 2 * HZ; |
| 828 | 828 | adap->retries = 0; |
| @@ -1265,15 +1265,17 @@ static bool cma_protocol_roce(const struct rdma_cm_id *id) · 1264 unmodified lines | ||
| 1265 | 1265 | return cma_protocol_roce_dev_port(device, port_num); |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | −static bool cma_match_net_dev(const struct rdma_id_private *id_priv, | |
| 1269 | − const struct net_device *net_dev) | |
| 1268 | +static bool cma_match_net_dev(const struct rdma_cm_id *id, | |
| 1269 | + const struct net_device *net_dev, | |
| 1270 | + u8 port_num) | |
| 1270 | 1271 | { |
| 1271 | − const struct rdma_addr *addr = &id_priv->id.route.addr; | |
| 1272 | + const struct rdma_addr *addr = &id->route.addr; | |
| 1272 | 1273 | |
| 1273 | 1274 | if (!net_dev) |
| 1274 | 1275 | /* This request is an AF_IB request or a RoCE request */ |
| 1275 | − return addr->src_addr.ss_family == AF_IB || | |
| 1276 | − cma_protocol_roce(&id_priv->id); | |
| 1276 | + return (!id->port_num || id->port_num == port_num) && | |
| 1277 | + (addr->src_addr.ss_family == AF_IB || | |
| 1278 | + cma_protocol_roce_dev_port(id->device, port_num)); | |
| 1277 | 1279 | |
| 1278 | 1280 | return !addr->dev_addr.bound_dev_if || |
| 1279 | 1281 | (net_eq(dev_net(net_dev), addr->dev_addr.net) && |
| @@ -1295,13 +1297,13 @@ static struct rdma_id_private *cma_find_listener( · 15 unmodified lines | ||
| 1295 | 1297 | hlist_for_each_entry(id_priv, &bind_list->owners, node) { |
| 1296 | 1298 | if (cma_match_private_data(id_priv, ib_event->private_data)) { |
| 1297 | 1299 | if (id_priv->id.device == cm_id->device && |
| 1298 | − cma_match_net_dev(id_priv, net_dev)) | |
| 1300 | + cma_match_net_dev(&id_priv->id, net_dev, req->port)) | |
| 1299 | 1301 | return id_priv; |
| 1300 | 1302 | list_for_each_entry(id_priv_dev, |
| 1301 | 1303 | &id_priv->listen_list, |
| 1302 | 1304 | listen_list) { |
| 1303 | 1305 | if (id_priv_dev->id.device == cm_id->device && |
| 1304 | − cma_match_net_dev(id_priv_dev, net_dev)) | |
| 1306 | + cma_match_net_dev(&id_priv_dev->id, net_dev, req->port)) | |
| 1305 | 1307 | return id_priv_dev; |
| 1306 | 1308 | } |
| 1307 | 1309 | } |
| @@ -286,7 +286,7 @@ int mlx4_ib_destroy_srq(struct ib_srq *srq) · 285 unmodified lines | ||
| 286 | 286 | mlx4_ib_db_unmap_user(to_mucontext(srq->uobject->context), &msrq->db); |
| 287 | 287 | ib_umem_release(msrq->umem); |
| 288 | 288 | } else { |
| 289 | − kfree(msrq->wrid); | |
| 289 | + kvfree(msrq->wrid); | |
| 290 | 290 | mlx4_buf_free(dev->dev, msrq->msrq.max << msrq->msrq.wqe_shift, |
| 291 | 291 | &msrq->buf); |
| 292 | 292 | mlx4_db_free(dev->dev, &msrq->db); |
| @@ -232,6 +232,10 @@ struct phy_info { · 231 unmodified lines | ||
| 232 | 232 | u16 interface_type; |
| 233 | 233 | }; |
| 234 | 234 | |
| 235 | +enum ocrdma_flags { | |
| 236 | + OCRDMA_FLAGS_LINK_STATUS_INIT = 0x01 | |
| 237 | +}; | |
| 238 | + | |
| 235 | 239 | struct ocrdma_dev { |
| 236 | 240 | struct ib_device ibdev; |
| 237 | 241 | struct ocrdma_dev_attr attr; |
| @@ -287,6 +291,7 @@ struct ocrdma_dev { · 49 unmodified lines | ||
| 287 | 291 | atomic_t update_sl; |
| 288 | 292 | u16 pvid; |
| 289 | 293 | u32 asic_id; |
| 294 | + u32 flags; | |
| 290 | 295 | |
| 291 | 296 | ulong last_stats_time; |
| 292 | 297 | struct mutex stats_lock; /* provide synch for debugfs operations */ |
| @@ -591,4 +596,9 @@ static inline u8 ocrdma_is_enabled_and_synced(u32 state) · 298 unmodified lines | ||
| 591 | 596 | (state & OCRDMA_STATE_FLAG_SYNC); |
| 592 | 597 | } |
| 593 | 598 | |
| 599 | +static inline u8 ocrdma_get_ae_link_state(u32 ae_state) | |
| 600 | +{ | |
| 601 | + return ((ae_state & OCRDMA_AE_LSC_LS_MASK) >> OCRDMA_AE_LSC_LS_SHIFT); | |
| 602 | +} | |
| 603 | + | |
| 594 | 604 | #endif |
| @@ -579,6 +579,8 @@ static int ocrdma_mbx_create_mq(struct ocrdma_dev *dev, · 578 unmodified lines | ||
| 579 | 579 | |
| 580 | 580 | cmd->async_event_bitmap = BIT(OCRDMA_ASYNC_GRP5_EVE_CODE); |
| 581 | 581 | cmd->async_event_bitmap |= BIT(OCRDMA_ASYNC_RDMA_EVE_CODE); |
| 582 | + /* Request link events on this MQ. */ | |
| 583 | + cmd->async_event_bitmap |= BIT(OCRDMA_ASYNC_LINK_EVE_CODE); | |
| 582 | 584 | |
| 583 | 585 | cmd->async_cqid_ringsize = cq->id; |
| 584 | 586 | cmd->async_cqid_ringsize |= (ocrdma_encoded_q_len(mq->len) << |
| @@ -819,20 +821,42 @@ static void ocrdma_process_grp5_aync(struct ocrdma_dev *dev, · 234 unmodified lines | ||
| 819 | 821 | } |
| 820 | 822 | } |
| 821 | 823 | |
| 824 | +static void ocrdma_process_link_state(struct ocrdma_dev *dev, | |
| 825 | + struct ocrdma_ae_mcqe *cqe) | |
| 826 | +{ | |
| 827 | + struct ocrdma_ae_lnkst_mcqe *evt; | |
| 828 | + u8 lstate; | |
| 829 | + | |
| 830 | + evt = (struct ocrdma_ae_lnkst_mcqe *)cqe; | |
| 831 | + lstate = ocrdma_get_ae_link_state(evt->speed_state_ptn); | |
| 832 | + | |
| 833 | + if (!(lstate & OCRDMA_AE_LSC_LLINK_MASK)) | |
| 834 | + return; | |
| 835 | + | |
| 836 | + if (dev->flags & OCRDMA_FLAGS_LINK_STATUS_INIT) | |
| 837 | + ocrdma_update_link_state(dev, (lstate & OCRDMA_LINK_ST_MASK)); | |
| 838 | +} | |
| 839 | + | |
| 822 | 840 | static void ocrdma_process_acqe(struct ocrdma_dev *dev, void *ae_cqe) |
| 823 | 841 | { |
| 824 | 842 | /* async CQE processing */ |
| 825 | 843 | struct ocrdma_ae_mcqe *cqe = ae_cqe; |
| 826 | 844 | u32 evt_code = (cqe->valid_ae_event & OCRDMA_AE_MCQE_EVENT_CODE_MASK) >> |
| 827 | 845 | OCRDMA_AE_MCQE_EVENT_CODE_SHIFT; |
| 828 | − | |
| 829 | − if (evt_code == OCRDMA_ASYNC_RDMA_EVE_CODE) | |
| 846 | + switch (evt_code) { | |
| 847 | + case OCRDMA_ASYNC_LINK_EVE_CODE: | |
| 848 | + ocrdma_process_link_state(dev, cqe); | |
| 849 | + break; | |
| 850 | + case OCRDMA_ASYNC_RDMA_EVE_CODE: | |
| 830 | 851 | ocrdma_dispatch_ibevent(dev, cqe); |
| 831 | − else if (evt_code == OCRDMA_ASYNC_GRP5_EVE_CODE) | |
| 852 | + break; | |
| 853 | + case OCRDMA_ASYNC_GRP5_EVE_CODE: | |
| 832 | 854 | ocrdma_process_grp5_aync(dev, cqe); |
| 833 | − else | |
| 855 | + break; | |
| 856 | + default: | |
| 834 | 857 | pr_err("%s(%d) invalid evt code=0x%x\n", __func__, |
| 835 | 858 | dev->id, evt_code); |
| 859 | + } | |
| 836 | 860 | } |
| 837 | 861 | |
| 838 | 862 | static void ocrdma_process_mcqe(struct ocrdma_dev *dev, struct ocrdma_mcqe *cqe) |
| @@ -1363,7 +1387,8 @@ mbx_err: · 524 unmodified lines | ||
| 1363 | 1387 | return status; |
| 1364 | 1388 | } |
| 1365 | 1389 | |
| 1366 | −int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed) | |
| 1390 | +int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed, | |
| 1391 | + u8 *lnk_state) | |
| 1367 | 1392 | { |
| 1368 | 1393 | int status = -ENOMEM; |
| 1369 | 1394 | struct ocrdma_get_link_speed_rsp *rsp; |
| @@ -1384,8 +1409,11 @@ int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed) · 14 unmodified lines | ||
| 1384 | 1409 | goto mbx_err; |
| 1385 | 1410 | |
| 1386 | 1411 | rsp = (struct ocrdma_get_link_speed_rsp *)cmd; |
| 1387 | − *lnk_speed = (rsp->pflt_pps_ld_pnum & OCRDMA_PHY_PS_MASK) | |
| 1388 | − >> OCRDMA_PHY_PS_SHIFT; | |
| 1412 | + if (lnk_speed) | |
| 1413 | + *lnk_speed = (rsp->pflt_pps_ld_pnum & OCRDMA_PHY_PS_MASK) | |
| 1414 | + >> OCRDMA_PHY_PS_SHIFT; | |
| 1415 | + if (lnk_state) | |
| 1416 | + *lnk_state = (rsp->res_lnk_st & OCRDMA_LINK_ST_MASK); | |
| 1389 | 1417 | |
| 1390 | 1418 | mbx_err: |
| 1391 | 1419 | kfree(cmd); |
| @@ -2515,9 +2543,10 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp, · 1123 unmodified lines | ||
| 2515 | 2543 | ocrdma_cpu_to_le32(&cmd->params.sgid[0], sizeof(cmd->params.sgid)); |
| 2516 | 2544 | cmd->params.vlan_dmac_b4_to_b5 = mac_addr[4] | (mac_addr[5] << 8); |
| 2517 | 2545 | |
| 2518 | − if (vlan_id < 0x1000) { | |
| 2519 | − if (dev->pfc_state) { | |
| 2520 | − vlan_id = 0; | |
| 2546 | + if (vlan_id == 0xFFFF) | |
| 2547 | + vlan_id = 0; | |
| 2548 | + if (vlan_id || dev->pfc_state) { | |
| 2549 | + if (!vlan_id) { | |
| 2521 | 2550 | pr_err("ocrdma%d:Using VLAN with PFC is recommended\n", |
| 2522 | 2551 | dev->id); |
| 2523 | 2552 | pr_err("ocrdma%d:Using VLAN 0 for this connection\n", |
| @@ -106,7 +106,8 @@ void ocrdma_ring_cq_db(struct ocrdma_dev *, u16 cq_id, bool armed, · 105 unmodified lines | ||
| 106 | 106 | bool solicited, u16 cqe_popped); |
| 107 | 107 | |
| 108 | 108 | /* verbs specific mailbox commands */ |
| 109 | −int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed); | |
| 109 | +int ocrdma_mbx_get_link_speed(struct ocrdma_dev *dev, u8 *lnk_speed, | |
| 110 | + u8 *lnk_st); | |
| 110 | 111 | int ocrdma_query_config(struct ocrdma_dev *, |
| 111 | 112 | struct ocrdma_mbx_query_config *config); |
| 112 | 113 | |
| @@ -153,5 +154,6 @@ char *port_speed_string(struct ocrdma_dev *dev); · 40 unmodified lines | ||
| 153 | 154 | void ocrdma_init_service_level(struct ocrdma_dev *); |
| 154 | 155 | void ocrdma_alloc_pd_pool(struct ocrdma_dev *dev); |
| 155 | 156 | void ocrdma_free_pd_range(struct ocrdma_dev *dev); |
| 157 | +void ocrdma_update_link_state(struct ocrdma_dev *dev, u8 lstate); | |
| 156 | 158 | |
| 157 | 159 | #endif /* __OCRDMA_HW_H__ */ |
| @@ -290,6 +290,7 @@ static void ocrdma_remove_sysfiles(struct ocrdma_dev *dev) · 289 unmodified lines | ||
| 290 | 290 | static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) |
| 291 | 291 | { |
| 292 | 292 | int status = 0, i; |
| 293 | + u8 lstate = 0; | |
| 293 | 294 | struct ocrdma_dev *dev; |
| 294 | 295 | |
| 295 | 296 | dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(struct ocrdma_dev)); |
| @@ -319,6 +320,11 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) · 23 unmodified lines | ||
| 319 | 320 | if (status) |
| 320 | 321 | goto alloc_err; |
| 321 | 322 | |
| 323 | + /* Query Link state and update */ | |
| 324 | + status = ocrdma_mbx_get_link_speed(dev, NULL, &lstate); | |
| 325 | + if (!status) | |
| 326 | + ocrdma_update_link_state(dev, lstate); | |
| 327 | + | |
| 322 | 328 | for (i = 0; i < ARRAY_SIZE(ocrdma_attributes); i++) |
| 323 | 329 | if (device_create_file(&dev->ibdev.dev, ocrdma_attributes[i])) |
| 324 | 330 | goto sysfs_err; |
| @@ -373,7 +379,7 @@ static void ocrdma_remove(struct ocrdma_dev *dev) · 48 unmodified lines | ||
| 373 | 379 | ocrdma_remove_free(dev); |
| 374 | 380 | } |
| 375 | 381 | |
| 376 | −static int ocrdma_open(struct ocrdma_dev *dev) | |
| 382 | +static int ocrdma_dispatch_port_active(struct ocrdma_dev *dev) | |
| 377 | 383 | { |
| 378 | 384 | struct ib_event port_event; |
| 379 | 385 | |
| @@ -384,32 +390,9 @@ static int ocrdma_open(struct ocrdma_dev *dev) · 4 unmodified lines | ||
| 384 | 390 | return 0; |
| 385 | 391 | } |
| 386 | 392 | |
| 387 | −static int ocrdma_close(struct ocrdma_dev *dev) | |
| 393 | +static int ocrdma_dispatch_port_error(struct ocrdma_dev *dev) | |
| 388 | 394 | { |
| 389 | − int i; | |
| 390 | − struct ocrdma_qp *qp, **cur_qp; | |
| 391 | 395 | struct ib_event err_event; |
| 392 | − struct ib_qp_attr attrs; | |
| 393 | − int attr_mask = IB_QP_STATE; | |
| 394 | − | |
| 395 | − attrs.qp_state = IB_QPS_ERR; | |
| 396 | − mutex_lock(&dev->dev_lock); | |
| 397 | − if (dev->qp_tbl) { | |
| 398 | − cur_qp = dev->qp_tbl; | |
| 399 | − for (i = 0; i < OCRDMA_MAX_QP; i++) { | |
| 400 | − qp = cur_qp[i]; | |
| 401 | − if (qp && qp->ibqp.qp_type != IB_QPT_GSI) { | |
| 402 | − /* change the QP state to ERROR */ | |
| 403 | − _ocrdma_modify_qp(&qp->ibqp, &attrs, attr_mask); | |
| 404 | − | |
| 405 | − err_event.event = IB_EVENT_QP_FATAL; | |
| 406 | − err_event.element.qp = &qp->ibqp; | |
| 407 | − err_event.device = &dev->ibdev; | |
| 408 | − ib_dispatch_event(&err_event); | |
| 409 | − } | |
| 410 | − } | |
| 411 | − } | |
| 412 | − mutex_unlock(&dev->dev_lock); | |
| 413 | 396 | |
| 414 | 397 | err_event.event = IB_EVENT_PORT_ERR; |
| 415 | 398 | err_event.element.port_num = 1; |
| @@ -420,7 +403,7 @@ static int ocrdma_close(struct ocrdma_dev *dev) · 4 unmodified lines | ||
| 420 | 403 | |
| 421 | 404 | static void ocrdma_shutdown(struct ocrdma_dev *dev) |
| 422 | 405 | { |
| 423 | − ocrdma_close(dev); | |
| 406 | + ocrdma_dispatch_port_error(dev); | |
| 424 | 407 | ocrdma_remove(dev); |
| 425 | 408 | } |
| 426 | 409 | |
| @@ -431,18 +414,28 @@ static void ocrdma_shutdown(struct ocrdma_dev *dev) · 4 unmodified lines | ||
| 431 | 414 | static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event) |
| 432 | 415 | { |
| 433 | 416 | switch (event) { |
| 434 | − case BE_DEV_UP: | |
| 435 | − ocrdma_open(dev); | |
| 436 | − break; | |
| 437 | − case BE_DEV_DOWN: | |
| 438 | − ocrdma_close(dev); | |
| 439 | − break; | |
| 440 | 417 | case BE_DEV_SHUTDOWN: |
| 441 | 418 | ocrdma_shutdown(dev); |
| 442 | 419 | break; |
| 420 | + default: | |
| 421 | + break; | |
| 443 | 422 | } |
| 444 | 423 | } |
| 445 | 424 | |
| 425 | +void ocrdma_update_link_state(struct ocrdma_dev *dev, u8 lstate) | |
| 426 | +{ | |
| 427 | + if (!(dev->flags & OCRDMA_FLAGS_LINK_STATUS_INIT)) { | |
| 428 | + dev->flags |= OCRDMA_FLAGS_LINK_STATUS_INIT; | |
| 429 | + if (!lstate) | |
| 430 | + return; | |
| 431 | + } | |
| 432 | + | |
| 433 | + if (!lstate) | |
| 434 | + ocrdma_dispatch_port_error(dev); | |
| 435 | + else | |
| 436 | + ocrdma_dispatch_port_active(dev); | |
| 437 | +} | |
| 438 | + | |
| 446 | 439 | static struct ocrdma_driver ocrdma_drv = { |
| 447 | 440 | .name = "ocrdma_driver", |
| 448 | 441 | .add = ocrdma_add, |
| @@ -465,8 +465,11 @@ struct ocrdma_ae_qp_mcqe { · 464 unmodified lines | ||
| 465 | 465 | u32 valid_ae_event; |
| 466 | 466 | }; |
| 467 | 467 | |
| 468 | −#define OCRDMA_ASYNC_RDMA_EVE_CODE 0x14 | |
| 469 | −#define OCRDMA_ASYNC_GRP5_EVE_CODE 0x5 | |
| 468 | +enum ocrdma_async_event_code { | |
| 469 | + OCRDMA_ASYNC_LINK_EVE_CODE = 0x01, | |
| 470 | + OCRDMA_ASYNC_GRP5_EVE_CODE = 0x05, | |
| 471 | + OCRDMA_ASYNC_RDMA_EVE_CODE = 0x14 | |
| 472 | +}; | |
| 470 | 473 | |
| 471 | 474 | enum ocrdma_async_grp5_events { |
| 472 | 475 | OCRDMA_ASYNC_EVENT_QOS_VALUE = 0x01, |
| @@ -489,6 +492,44 @@ enum OCRDMA_ASYNC_EVENT_TYPE { · 16 unmodified lines | ||
| 489 | 492 | OCRDMA_MAX_ASYNC_ERRORS |
| 490 | 493 | }; |
| 491 | 494 | |
| 495 | +struct ocrdma_ae_lnkst_mcqe { | |
| 496 | + u32 speed_state_ptn; | |
| 497 | + u32 qos_reason_falut; | |
| 498 | + u32 evt_tag; | |
| 499 | + u32 valid_ae_event; | |
| 500 | +}; | |
| 501 | + | |
| 502 | +enum { | |
| 503 | + OCRDMA_AE_LSC_PORT_NUM_MASK = 0x3F, | |
| 504 | + OCRDMA_AE_LSC_PT_SHIFT = 0x06, | |
| 505 | + OCRDMA_AE_LSC_PT_MASK = (0x03 << | |
| 506 | + OCRDMA_AE_LSC_PT_SHIFT), | |
| 507 | + OCRDMA_AE_LSC_LS_SHIFT = 0x08, | |
| 508 | + OCRDMA_AE_LSC_LS_MASK = (0xFF << | |
| 509 | + OCRDMA_AE_LSC_LS_SHIFT), | |
| 510 | + OCRDMA_AE_LSC_LD_SHIFT = 0x10, | |
| 511 | + OCRDMA_AE_LSC_LD_MASK = (0xFF << | |
| 512 | + OCRDMA_AE_LSC_LD_SHIFT), | |
| 513 | + OCRDMA_AE_LSC_PPS_SHIFT = 0x18, | |
| 514 | + OCRDMA_AE_LSC_PPS_MASK = (0xFF << | |
| 515 | + OCRDMA_AE_LSC_PPS_SHIFT), | |
| 516 | + OCRDMA_AE_LSC_PPF_MASK = 0xFF, | |
| 517 | + OCRDMA_AE_LSC_ER_SHIFT = 0x08, | |
| 518 | + OCRDMA_AE_LSC_ER_MASK = (0xFF << | |
| 519 | + OCRDMA_AE_LSC_ER_SHIFT), | |
| 520 | + OCRDMA_AE_LSC_QOS_SHIFT = 0x10, | |
| 521 | + OCRDMA_AE_LSC_QOS_MASK = (0xFFFF << | |
| 522 | + OCRDMA_AE_LSC_QOS_SHIFT) | |
| 523 | +}; | |
| 524 | + | |
| 525 | +enum { | |
| 526 | + OCRDMA_AE_LSC_PLINK_DOWN = 0x00, | |
| 527 | + OCRDMA_AE_LSC_PLINK_UP = 0x01, | |
| 528 | + OCRDMA_AE_LSC_LLINK_DOWN = 0x02, | |
| 529 | + OCRDMA_AE_LSC_LLINK_MASK = 0x02, | |
| 530 | + OCRDMA_AE_LSC_LLINK_UP = 0x03 | |
| 531 | +}; | |
| 532 | + | |
| 492 | 533 | /* mailbox command request and responses */ |
| 493 | 534 | enum { |
| 494 | 535 | OCRDMA_MBX_QUERY_CFG_CQ_OVERFLOW_SHIFT = 2, |
| @@ -676,7 +717,7 @@ enum { · 181 unmodified lines | ||
| 676 | 717 | OCRDMA_PHY_PFLT_SHIFT = 0x18, |
| 677 | 718 | OCRDMA_QOS_LNKSP_MASK = 0xFFFF0000, |
| 678 | 719 | OCRDMA_QOS_LNKSP_SHIFT = 0x10, |
| 679 | − OCRDMA_LLST_MASK = 0xFF, | |
| 720 | + OCRDMA_LINK_ST_MASK = 0x01, | |
| 680 | 721 | OCRDMA_PLFC_MASK = 0x00000400, |
| 681 | 722 | OCRDMA_PLFC_SHIFT = 0x8, |
| 682 | 723 | OCRDMA_PLRFC_MASK = 0x00000200, |
| @@ -691,7 +732,7 @@ struct ocrdma_get_link_speed_rsp { · 8 unmodified lines | ||
| 691 | 732 | |
| 692 | 733 | u32 pflt_pps_ld_pnum; |
| 693 | 734 | u32 qos_lsp; |
| 694 | − u32 res_lls; | |
| 735 | + u32 res_lnk_st; | |
| 695 | 736 | }; |
| 696 | 737 | |
| 697 | 738 | enum { |
| @@ -171,7 +171,7 @@ static inline void get_link_speed_and_width(struct ocrdma_dev *dev, · 170 unmodified lines | ||
| 171 | 171 | int status; |
| 172 | 172 | u8 speed; |
| 173 | 173 | |
| 174 | − status = ocrdma_mbx_get_link_speed(dev, &speed); | |
| 174 | + status = ocrdma_mbx_get_link_speed(dev, &speed, NULL); | |
| 175 | 175 | if (status) |
| 176 | 176 | speed = OCRDMA_PHYS_LINK_SPEED_ZERO; |
| 177 | 177 | |
| @@ -592,6 +592,7 @@ static void db9_attach(struct parport *pp) · 591 unmodified lines | ||
| 592 | 592 | return; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | + memset(&db9_parport_cb, 0, sizeof(db9_parport_cb)); | |
| 595 | 596 | db9_parport_cb.flags = PARPORT_FLAG_EXCL; |
| 596 | 597 | |
| 597 | 598 | pd = parport_register_dev_model(pp, "db9", &db9_parport_cb, port_idx); |
| @@ -951,6 +951,7 @@ static void gc_attach(struct parport *pp) · 950 unmodified lines | ||
| 951 | 951 | pads = gc_cfg[port_idx].args + 1; |
| 952 | 952 | n_pads = gc_cfg[port_idx].nargs - 1; |
| 953 | 953 | |
| 954 | + memset(&gc_parport_cb, 0, sizeof(gc_parport_cb)); | |
| 954 | 955 | gc_parport_cb.flags = PARPORT_FLAG_EXCL; |
| 955 | 956 | |
| 956 | 957 | pd = parport_register_dev_model(pp, "gamecon", &gc_parport_cb, |
| @@ -181,6 +181,7 @@ static void tgfx_attach(struct parport *pp) · 180 unmodified lines | ||
| 181 | 181 | n_buttons = tgfx_cfg[port_idx].args + 1; |
| 182 | 182 | n_devs = tgfx_cfg[port_idx].nargs - 1; |
| 183 | 183 | |
| 184 | + memset(&tgfx_parport_cb, 0, sizeof(tgfx_parport_cb)); | |
| 184 | 185 | tgfx_parport_cb.flags = PARPORT_FLAG_EXCL; |
| 185 | 186 | |
| 186 | 187 | pd = parport_register_dev_model(pp, "turbografx", &tgfx_parport_cb, |
| @@ -218,6 +218,7 @@ static void walkera0701_attach(struct parport *pp) · 217 unmodified lines | ||
| 218 | 218 | |
| 219 | 219 | w->parport = pp; |
| 220 | 220 | |
| 221 | + memset(&walkera0701_parport_cb, 0, sizeof(walkera0701_parport_cb)); | |
| 221 | 222 | walkera0701_parport_cb.flags = PARPORT_FLAG_EXCL; |
| 222 | 223 | walkera0701_parport_cb.irq_func = walkera0701_irq_handler; |
| 223 | 224 | walkera0701_parport_cb.private = w; |
| @@ -97,8 +97,7 @@ static void arizona_haptics_work(struct work_struct *work) · 96 unmodified lines | ||
| 97 | 97 | |
| 98 | 98 | ret = regmap_update_bits(arizona->regmap, |
| 99 | 99 | ARIZONA_HAPTICS_CONTROL_1, |
| 100 | − ARIZONA_HAP_CTRL_MASK, | |
| 101 | − 1 << ARIZONA_HAP_CTRL_SHIFT); | |
| 100 | + ARIZONA_HAP_CTRL_MASK, 0); | |
| 102 | 101 | if (ret != 0) { |
| 103 | 102 | dev_err(arizona->dev, "Failed to stop haptics: %d\n", |
| 104 | 103 | ret); |
| @@ -20,70 +20,78 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <linux/input.h> |
| 21 | 21 | #include <linux/device.h> |
| 22 | 22 | #include <linux/platform_device.h> |
| 23 | −#include <linux/gpio.h> | |
| 24 | −#include <linux/rotary_encoder.h> | |
| 23 | +#include <linux/gpio/consumer.h> | |
| 25 | 24 | #include <linux/slab.h> |
| 26 | 25 | #include <linux/of.h> |
| 27 | −#include <linux/of_platform.h> | |
| 28 | −#include <linux/of_gpio.h> | |
| 29 | 26 | #include <linux/pm.h> |
| 27 | +#include <linux/property.h> | |
| 30 | 28 | |
| 31 | 29 | #define DRV_NAME "rotary-encoder" |
| 32 | 30 | |
| 33 | 31 | struct rotary_encoder { |
| 34 | 32 | struct input_dev *input; |
| 35 | − const struct rotary_encoder_platform_data *pdata; | |
| 36 | 33 | |
| 37 | − unsigned int axis; | |
| 34 | + struct mutex access_mutex; | |
| 35 | + | |
| 36 | + u32 steps; | |
| 37 | + u32 axis; | |
| 38 | + bool relative_axis; | |
| 39 | + bool rollover; | |
| 40 | + | |
| 38 | 41 | unsigned int pos; |
| 39 | 42 | |
| 40 | − unsigned int irq_a; | |
| 41 | − unsigned int irq_b; | |
| 43 | + struct gpio_descs *gpios; | |
| 44 | + | |
| 45 | + unsigned int *irq; | |
| 42 | 46 | |
| 43 | 47 | bool armed; |
| 44 | − unsigned char dir; /* 0 - clockwise, 1 - CCW */ | |
| 48 | + signed char dir; /* 1 - clockwise, -1 - CCW */ | |
| 45 | 49 | |
| 46 | − char last_stable; | |
| 50 | + unsigned last_stable; | |
| 47 | 51 | }; |
| 48 | 52 | |
| 49 | −static int rotary_encoder_get_state(const struct rotary_encoder_platform_data *pdata) | |
| 53 | +static unsigned rotary_encoder_get_state(struct rotary_encoder *encoder) | |
| 50 | 54 | { |
| 51 | − int a = !!gpio_get_value(pdata->gpio_a); | |
| 52 | − int b = !!gpio_get_value(pdata->gpio_b); | |
| 55 | + int i; | |
| 56 | + unsigned ret = 0; | |
| 53 | 57 | |
| 54 | − a ^= pdata->inverted_a; | |
| 55 | − b ^= pdata->inverted_b; | |
| 58 | + for (i = 0; i < encoder->gpios->ndescs; ++i) { | |
| 59 | + int val = gpiod_get_value_cansleep(encoder->gpios->desc[i]); | |
| 60 | + /* convert from gray encoding to normal */ | |
| 61 | + if (ret & 1) | |
| 62 | + val = !val; | |
| 56 | 63 | |
| 57 | − return ((a << 1) | b); | |
| 64 | + ret = ret << 1 | val; | |
| 65 | + } | |
| 66 | + | |
| 67 | + return ret & 3; | |
| 58 | 68 | } |
| 59 | 69 | |
| 60 | 70 | static void rotary_encoder_report_event(struct rotary_encoder *encoder) |
| 61 | 71 | { |
| 62 | − const struct rotary_encoder_platform_data *pdata = encoder->pdata; | |
| 63 | − | |
| 64 | − if (pdata->relative_axis) { | |
| 72 | + if (encoder->relative_axis) { | |
| 65 | 73 | input_report_rel(encoder->input, |
| 66 | − pdata->axis, encoder->dir ? -1 : 1); | |
| 74 | + encoder->axis, encoder->dir); | |
| 67 | 75 | } else { |
| 68 | 76 | unsigned int pos = encoder->pos; |
| 69 | 77 | |
| 70 | − if (encoder->dir) { | |
| 78 | + if (encoder->dir < 0) { | |
| 71 | 79 | /* turning counter-clockwise */ |
| 72 | − if (pdata->rollover) | |
| 73 | − pos += pdata->steps; | |
| 80 | + if (encoder->rollover) | |
| 81 | + pos += encoder->steps; | |
| 74 | 82 | if (pos) |
| 75 | 83 | pos--; |
| 76 | 84 | } else { |
| 77 | 85 | /* turning clockwise */ |
| 78 | − if (pdata->rollover || pos < pdata->steps) | |
| 86 | + if (encoder->rollover || pos < encoder->steps) | |
| 79 | 87 | pos++; |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | − if (pdata->rollover) | |
| 83 | − pos %= pdata->steps; | |
| 90 | + if (encoder->rollover) | |
| 91 | + pos %= encoder->steps; | |
| 84 | 92 | |
| 85 | 93 | encoder->pos = pos; |
| 86 | − input_report_abs(encoder->input, pdata->axis, encoder->pos); | |
| 94 | + input_report_abs(encoder->input, encoder->axis, encoder->pos); | |
| 87 | 95 | } |
| 88 | 96 | |
| 89 | 97 | input_sync(encoder->input); |
| @@ -92,9 +100,11 @@ static void rotary_encoder_report_event(struct rotary_encoder *encoder) · 2 unmodified lines | ||
| 92 | 100 | static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) |
| 93 | 101 | { |
| 94 | 102 | struct rotary_encoder *encoder = dev_id; |
| 95 | − int state; | |
| 103 | + unsigned state; | |
| 96 | 104 | |
| 97 | − state = rotary_encoder_get_state(encoder->pdata); | |
| 105 | + mutex_lock(&encoder->access_mutex); | |
| 106 | + | |
| 107 | + state = rotary_encoder_get_state(encoder); | |
| 98 | 108 | |
| 99 | 109 | switch (state) { |
| 100 | 110 | case 0x0: |
| @@ -105,334 +115,227 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) · 4 unmodified lines | ||
| 105 | 115 | break; |
| 106 | 116 | |
| 107 | 117 | case 0x1: |
| 108 | − case 0x2: | |
| 118 | + case 0x3: | |
| 109 | 119 | if (encoder->armed) |
| 110 | − encoder->dir = state - 1; | |
| 120 | + encoder->dir = 2 - state; | |
| 111 | 121 | break; |
| 112 | 122 | |
| 113 | − case 0x3: | |
| 123 | + case 0x2: | |
| 114 | 124 | encoder->armed = true; |
| 115 | 125 | break; |
| 116 | 126 | } |
| 117 | 127 | |
| 128 | + mutex_unlock(&encoder->access_mutex); | |
| 129 | + | |
| 118 | 130 | return IRQ_HANDLED; |
| 119 | 131 | } |
| 120 | 132 | |
| 121 | 133 | static irqreturn_t rotary_encoder_half_period_irq(int irq, void *dev_id) |
| 122 | 134 | { |
| 123 | 135 | struct rotary_encoder *encoder = dev_id; |
| 124 | − int state; | |
| 136 | + unsigned int state; | |
| 125 | 137 | |
| 126 | − state = rotary_encoder_get_state(encoder->pdata); | |
| 138 | + mutex_lock(&encoder->access_mutex); | |
| 127 | 139 | |
| 128 | − switch (state) { | |
| 129 | − case 0x00: | |
| 130 | − case 0x03: | |
| 140 | + state = rotary_encoder_get_state(encoder); | |
| 141 | + | |
| 142 | + if (state & 1) { | |
| 143 | + encoder->dir = ((encoder->last_stable - state + 1) % 4) - 1; | |
| 144 | + } else { | |
| 131 | 145 | if (state != encoder->last_stable) { |
| 132 | 146 | rotary_encoder_report_event(encoder); |
| 133 | 147 | encoder->last_stable = state; |
| 134 | 148 | } |
| 135 | − break; | |
| 136 | − | |
| 137 | − case 0x01: | |
| 138 | − case 0x02: | |
| 139 | − encoder->dir = (encoder->last_stable + state) & 0x01; | |
| 140 | − break; | |
| 141 | 149 | } |
| 142 | 150 | |
| 151 | + mutex_unlock(&encoder->access_mutex); | |
| 152 | + | |
| 143 | 153 | return IRQ_HANDLED; |
| 144 | 154 | } |
| 145 | 155 | |
| 146 | 156 | static irqreturn_t rotary_encoder_quarter_period_irq(int irq, void *dev_id) |
| 147 | 157 | { |
| 148 | 158 | struct rotary_encoder *encoder = dev_id; |
| 149 | − unsigned char sum; | |
| 150 | − int state; | |
| 151 | − | |
| 152 | − state = rotary_encoder_get_state(encoder->pdata); | |
| 153 | − | |
| 154 | − /* | |
| 155 | − * We encode the previous and the current state using a byte. | |
| 156 | − * The previous state in the MSB nibble, the current state in the LSB | |
| 157 | − * nibble. Then use a table to decide the direction of the turn. | |
| 158 | − */ | |
| 159 | − sum = (encoder->last_stable << 4) + state; | |
| 160 | − switch (sum) { | |
| 161 | − case 0x31: | |
| 162 | − case 0x10: | |
| 163 | − case 0x02: | |
| 164 | − case 0x23: | |
| 165 | − encoder->dir = 0; /* clockwise */ | |
| 166 | − break; | |
| 159 | + unsigned int state; | |
| 167 | 160 | |
| 168 | − case 0x13: | |
| 169 | − case 0x01: | |
| 170 | − case 0x20: | |
| 171 | − case 0x32: | |
| 172 | − encoder->dir = 1; /* counter-clockwise */ | |
| 173 | − break; | |
| 161 | + mutex_lock(&encoder->access_mutex); | |
| 174 | 162 | |
| 175 | − default: | |
| 176 | − /* | |
| 177 | − * Ignore all other values. This covers the case when the | |
| 178 | − * state didn't change (a spurious interrupt) and the | |
| 179 | − * cases where the state changed by two steps, making it | |
| 180 | − * impossible to tell the direction. | |
| 181 | − * | |
| 182 | − * In either case, don't report any event and save the | |
| 183 | − * state for later. | |
| 184 | − */ | |
| 163 | + state = rotary_encoder_get_state(encoder); | |
| 164 | + | |
| 165 | + if ((encoder->last_stable + 1) % 4 == state) | |
| 166 | + encoder->dir = 1; | |
| 167 | + else if (encoder->last_stable == (state + 1) % 4) | |
| 168 | + encoder->dir = -1; | |
| 169 | + else | |
| 185 | 170 | goto out; |
| 186 | − } | |
| 187 | 171 | |
| 188 | 172 | rotary_encoder_report_event(encoder); |
| 189 | 173 | |
| 190 | 174 | out: |
| 191 | 175 | encoder->last_stable = state; |
| 176 | + mutex_unlock(&encoder->access_mutex); | |
| 177 | + | |
| 192 | 178 | return IRQ_HANDLED; |
| 193 | 179 | } |
| 194 | 180 | |
| 195 | −#ifdef CONFIG_OF | |
| 196 | −static const struct of_device_id rotary_encoder_of_match[] = { | |
| 197 | − { .compatible = "rotary-encoder", }, | |
| 198 | − { }, | |
| 199 | −}; | |
| 200 | −MODULE_DEVICE_TABLE(of, rotary_encoder_of_match); | |
| 201 | − | |
| 202 | −static struct rotary_encoder_platform_data *rotary_encoder_parse_dt(struct device *dev) | |
| 181 | +static int rotary_encoder_probe(struct platform_device *pdev) | |
| 203 | 182 | { |
| 204 | − const struct of_device_id *of_id = | |
| 205 | − of_match_device(rotary_encoder_of_match, dev); | |
| 206 | − struct device_node *np = dev->of_node; | |
| 207 | − struct rotary_encoder_platform_data *pdata; | |
| 208 | − enum of_gpio_flags flags; | |
| 209 | − int error; | |
| 210 | − | |
| 211 | − if (!of_id || !np) | |
| 212 | − return NULL; | |
| 213 | − | |
| 214 | − pdata = kzalloc(sizeof(struct rotary_encoder_platform_data), | |
| 215 | − GFP_KERNEL); | |
| 216 | − if (!pdata) | |
| 217 | − return ERR_PTR(-ENOMEM); | |
| 218 | − | |
| 219 | − of_property_read_u32(np, "rotary-encoder,steps", &pdata->steps); | |
| 220 | − of_property_read_u32(np, "linux,axis", &pdata->axis); | |
| 183 | + struct device *dev = &pdev->dev; | |
| 184 | + struct rotary_encoder *encoder; | |
| 185 | + struct input_dev *input; | |
| 186 | + irq_handler_t handler; | |
| 187 | + u32 steps_per_period; | |
| 188 | + unsigned int i; | |
| 189 | + int err; | |
| 221 | 190 | |
| 222 | − pdata->gpio_a = of_get_gpio_flags(np, 0, &flags); | |
| 223 | − pdata->inverted_a = flags & OF_GPIO_ACTIVE_LOW; | |
| 191 | + encoder = devm_kzalloc(dev, sizeof(struct rotary_encoder), GFP_KERNEL); | |
| 192 | + if (!encoder) | |
| 193 | + return -ENOMEM; | |
| 224 | 194 | |
| 225 | − pdata->gpio_b = of_get_gpio_flags(np, 1, &flags); | |
| 226 | − pdata->inverted_b = flags & OF_GPIO_ACTIVE_LOW; | |
| 195 | + mutex_init(&encoder->access_mutex); | |
| 227 | 196 | |
| 228 | − pdata->relative_axis = | |
| 229 | − of_property_read_bool(np, "rotary-encoder,relative-axis"); | |
| 230 | − pdata->rollover = of_property_read_bool(np, "rotary-encoder,rollover"); | |
| 197 | + device_property_read_u32(dev, "rotary-encoder,steps", &encoder->steps); | |
| 231 | 198 | |
| 232 | − error = of_property_read_u32(np, "rotary-encoder,steps-per-period", | |
| 233 | − &pdata->steps_per_period); | |
| 234 | − if (error) { | |
| 199 | + err = device_property_read_u32(dev, "rotary-encoder,steps-per-period", | |
| 200 | + &steps_per_period); | |
| 201 | + if (err) { | |
| 235 | 202 | /* |
| 236 | − * The 'half-period' property has been deprecated, you must use | |
| 237 | − * 'steps-per-period' and set an appropriate value, but we still | |
| 238 | − * need to parse it to maintain compatibility. | |
| 203 | + * The 'half-period' property has been deprecated, you must | |
| 204 | + * use 'steps-per-period' and set an appropriate value, but | |
| 205 | + * we still need to parse it to maintain compatibility. If | |
| 206 | + * neither property is present we fall back to the one step | |
| 207 | + * per period behavior. | |
| 239 | 208 | */ |
| 240 | − if (of_property_read_bool(np, "rotary-encoder,half-period")) { | |
| 241 | − pdata->steps_per_period = 2; | |
| 242 | − } else { | |
| 243 | − /* Fallback to one step per period behavior */ | |
| 244 | − pdata->steps_per_period = 1; | |
| 245 | − } | |
| 209 | + steps_per_period = device_property_read_bool(dev, | |
| 210 | + "rotary-encoder,half-period") ? 2 : 1; | |
| 246 | 211 | } |
| 247 | 212 | |
| 248 | − pdata->wakeup_source = of_property_read_bool(np, "wakeup-source"); | |
| 213 | + encoder->rollover = | |
| 214 | + device_property_read_bool(dev, "rotary-encoder,rollover"); | |
| 249 | 215 | |
| 250 | − return pdata; | |
| 251 | −} | |
| 252 | −#else | |
| 253 | −static inline struct rotary_encoder_platform_data * | |
| 254 | −rotary_encoder_parse_dt(struct device *dev) | |
| 255 | −{ | |
| 256 | − return NULL; | |
| 257 | −} | |
| 258 | −#endif | |
| 259 | − | |
| 260 | −static int rotary_encoder_probe(struct platform_device *pdev) | |
| 261 | −{ | |
| 262 | − struct device *dev = &pdev->dev; | |
| 263 | − const struct rotary_encoder_platform_data *pdata = dev_get_platdata(dev); | |
| 264 | − struct rotary_encoder *encoder; | |
| 265 | − struct input_dev *input; | |
| 266 | − irq_handler_t handler; | |
| 267 | − int err; | |
| 268 | − | |
| 269 | − if (!pdata) { | |
| 270 | − pdata = rotary_encoder_parse_dt(dev); | |
| 271 | − if (IS_ERR(pdata)) | |
| 272 | − return PTR_ERR(pdata); | |
| 216 | + device_property_read_u32(dev, "linux,axis", &encoder->axis); | |
| 217 | + encoder->relative_axis = | |
| 218 | + device_property_read_bool(dev, "rotary-encoder,relative-axis"); | |
| 273 | 219 | |
| 274 | − if (!pdata) { | |
| 275 | − dev_err(dev, "missing platform data\n"); | |
| 276 | − return -EINVAL; | |
| 277 | − } | |
| 220 | + encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN); | |
| 221 | + if (IS_ERR(encoder->gpios)) { | |
| 222 | + dev_err(dev, "unable to get gpios\n"); | |
| 223 | + return PTR_ERR(encoder->gpios); | |
| 278 | 224 | } |
| 279 | − | |
| 280 | − encoder = kzalloc(sizeof(struct rotary_encoder), GFP_KERNEL); | |
| 281 | − input = input_allocate_device(); | |
| 282 | − if (!encoder || !input) { | |
| 283 | − err = -ENOMEM; | |
| 284 | − goto exit_free_mem; | |
| 225 | + if (encoder->gpios->ndescs < 2) { | |
| 226 | + dev_err(dev, "not enough gpios found\n"); | |
| 227 | + return -EINVAL; | |
| 285 | 228 | } |
| 286 | 229 | |
| 230 | + input = devm_input_allocate_device(dev); | |
| 231 | + if (!input) | |
| 232 | + return -ENOMEM; | |
| 233 | + | |
| 287 | 234 | encoder->input = input; |
| 288 | − encoder->pdata = pdata; | |
| 289 | 235 | |
| 290 | 236 | input->name = pdev->name; |
| 291 | 237 | input->id.bustype = BUS_HOST; |
| 292 | 238 | input->dev.parent = dev; |
| 293 | 239 | |
| 294 | − if (pdata->relative_axis) { | |
| 295 | − input->evbit[0] = BIT_MASK(EV_REL); | |
| 296 | − input->relbit[0] = BIT_MASK(pdata->axis); | |
| 297 | − } else { | |
| 298 | − input->evbit[0] = BIT_MASK(EV_ABS); | |
| 299 | − input_set_abs_params(encoder->input, | |
| 300 | − pdata->axis, 0, pdata->steps, 0, 1); | |
| 301 | − } | |
| 302 | − | |
| 303 | − /* request the GPIOs */ | |
| 304 | − err = gpio_request_one(pdata->gpio_a, GPIOF_IN, dev_name(dev)); | |
| 305 | − if (err) { | |
| 306 | − dev_err(dev, "unable to request GPIO %d\n", pdata->gpio_a); | |
| 307 | − goto exit_free_mem; | |
| 308 | − } | |
| 309 | − | |
| 310 | − err = gpio_request_one(pdata->gpio_b, GPIOF_IN, dev_name(dev)); | |
| 311 | − if (err) { | |
| 312 | − dev_err(dev, "unable to request GPIO %d\n", pdata->gpio_b); | |
| 313 | − goto exit_free_gpio_a; | |
| 314 | − } | |
| 315 | − | |
| 316 | − encoder->irq_a = gpio_to_irq(pdata->gpio_a); | |
| 317 | − encoder->irq_b = gpio_to_irq(pdata->gpio_b); | |
| 240 | + if (encoder->relative_axis) | |
| 241 | + input_set_capability(input, EV_REL, encoder->axis); | |
| 242 | + else | |
| 243 | + input_set_abs_params(input, | |
| 244 | + encoder->axis, 0, encoder->steps, 0, 1); | |
| 318 | 245 | |
| 319 | − switch (pdata->steps_per_period) { | |
| 246 | + switch (steps_per_period >> (encoder->gpios->ndescs - 2)) { | |
| 320 | 247 | case 4: |
| 321 | 248 | handler = &rotary_encoder_quarter_period_irq; |
| 322 | − encoder->last_stable = rotary_encoder_get_state(pdata); | |
| 249 | + encoder->last_stable = rotary_encoder_get_state(encoder); | |
| 323 | 250 | break; |
| 324 | 251 | case 2: |
| 325 | 252 | handler = &rotary_encoder_half_period_irq; |
| 326 | − encoder->last_stable = rotary_encoder_get_state(pdata); | |
| 253 | + encoder->last_stable = rotary_encoder_get_state(encoder); | |
| 327 | 254 | break; |
| 328 | 255 | case 1: |
| 329 | 256 | handler = &rotary_encoder_irq; |
| 330 | 257 | break; |
| 331 | 258 | default: |
| 332 | 259 | dev_err(dev, "'%d' is not a valid steps-per-period value\n", |
| 333 | − pdata->steps_per_period); | |
| 334 | − err = -EINVAL; | |
| 335 | − goto exit_free_gpio_b; | |
| 260 | + steps_per_period); | |
| 261 | + return -EINVAL; | |
| 336 | 262 | } |
| 337 | 263 | |
| 338 | − err = request_irq(encoder->irq_a, handler, | |
| 339 | − IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | |
| 340 | − DRV_NAME, encoder); | |
| 341 | − if (err) { | |
| 342 | − dev_err(dev, "unable to request IRQ %d\n", encoder->irq_a); | |
| 343 | − goto exit_free_gpio_b; | |
| 344 | − } | |
| 345 | − | |
| 346 | − err = request_irq(encoder->irq_b, handler, | |
| 347 | − IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | |
| 348 | − DRV_NAME, encoder); | |
| 349 | − if (err) { | |
| 350 | − dev_err(dev, "unable to request IRQ %d\n", encoder->irq_b); | |
| 351 | − goto exit_free_irq_a; | |
| 264 | + encoder->irq = | |
| 265 | + devm_kzalloc(dev, | |
| 266 | + sizeof(*encoder->irq) * encoder->gpios->ndescs, | |
| 267 | + GFP_KERNEL); | |
| 268 | + if (!encoder->irq) | |
| 269 | + return -ENOMEM; | |
| 270 | + | |
| 271 | + for (i = 0; i < encoder->gpios->ndescs; ++i) { | |
| 272 | + encoder->irq[i] = gpiod_to_irq(encoder->gpios->desc[i]); | |
| 273 | + | |
| 274 | + err = devm_request_threaded_irq(dev, encoder->irq[i], | |
| 275 | + NULL, handler, | |
| 276 | + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | | |
| 277 | + IRQF_ONESHOT, | |
| 278 | + DRV_NAME, encoder); | |
| 279 | + if (err) { | |
| 280 | + dev_err(dev, "unable to request IRQ %d (gpio#%d)\n", | |
| 281 | + encoder->irq[i], i); | |
| 282 | + return err; | |
| 283 | + } | |
| 352 | 284 | } |
| 353 | 285 | |
| 354 | 286 | err = input_register_device(input); |
| 355 | 287 | if (err) { |
| 356 | 288 | dev_err(dev, "failed to register input device\n"); |
| 357 | − goto exit_free_irq_b; | |
| 289 | + return err; | |
| 358 | 290 | } |
| 359 | 291 | |
| 360 | − device_init_wakeup(&pdev->dev, pdata->wakeup_source); | |
| 292 | + device_init_wakeup(dev, | |
| 293 | + device_property_read_bool(dev, "wakeup-source")); | |
| 361 | 294 | |
| 362 | 295 | platform_set_drvdata(pdev, encoder); |
| 363 | 296 | |
| 364 | 297 | return 0; |
| 365 | − | |
| 366 | −exit_free_irq_b: | |
| 367 | − free_irq(encoder->irq_b, encoder); | |
| 368 | −exit_free_irq_a: | |
| 369 | − free_irq(encoder->irq_a, encoder); | |
| 370 | −exit_free_gpio_b: | |
| 371 | − gpio_free(pdata->gpio_b); | |
| 372 | −exit_free_gpio_a: | |
| 373 | − gpio_free(pdata->gpio_a); | |
| 374 | −exit_free_mem: | |
| 375 | − input_free_device(input); | |
| 376 | − kfree(encoder); | |
| 377 | − if (!dev_get_platdata(&pdev->dev)) | |
| 378 | − kfree(pdata); | |
| 379 | − | |
| 380 | − return err; | |
| 381 | 298 | } |
| 382 | 299 | |
| 383 | −static int rotary_encoder_remove(struct platform_device *pdev) | |
| 384 | −{ | |
| 385 | − struct rotary_encoder *encoder = platform_get_drvdata(pdev); | |
| 386 | − const struct rotary_encoder_platform_data *pdata = encoder->pdata; | |
| 387 | − | |
| 388 | − device_init_wakeup(&pdev->dev, false); | |
| 389 | − | |
| 390 | − free_irq(encoder->irq_a, encoder); | |
| 391 | − free_irq(encoder->irq_b, encoder); | |
| 392 | − gpio_free(pdata->gpio_a); | |
| 393 | − gpio_free(pdata->gpio_b); | |
| 394 | − | |
| 395 | − input_unregister_device(encoder->input); | |
| 396 | − kfree(encoder); | |
| 397 | − | |
| 398 | − if (!dev_get_platdata(&pdev->dev)) | |
| 399 | − kfree(pdata); | |
| 400 | − | |
| 401 | − return 0; | |
| 402 | −} | |
| 403 | − | |
| 404 | −#ifdef CONFIG_PM_SLEEP | |
| 405 | −static int rotary_encoder_suspend(struct device *dev) | |
| 300 | +static int __maybe_unused rotary_encoder_suspend(struct device *dev) | |
| 406 | 301 | { |
| 407 | 302 | struct rotary_encoder *encoder = dev_get_drvdata(dev); |
| 303 | + unsigned int i; | |
| 408 | 304 | |
| 409 | 305 | if (device_may_wakeup(dev)) { |
| 410 | − enable_irq_wake(encoder->irq_a); | |
| 411 | − enable_irq_wake(encoder->irq_b); | |
| 306 | + for (i = 0; i < encoder->gpios->ndescs; ++i) | |
| 307 | + enable_irq_wake(encoder->irq[i]); | |
| 412 | 308 | } |
| 413 | 309 | |
| 414 | 310 | return 0; |
| 415 | 311 | } |
| 416 | 312 | |
| 417 | −static int rotary_encoder_resume(struct device *dev) | |
| 313 | +static int __maybe_unused rotary_encoder_resume(struct device *dev) | |
| 418 | 314 | { |
| 419 | 315 | struct rotary_encoder *encoder = dev_get_drvdata(dev); |
| 316 | + unsigned int i; | |
| 420 | 317 | |
| 421 | 318 | if (device_may_wakeup(dev)) { |
| 422 | − disable_irq_wake(encoder->irq_a); | |
| 423 | − disable_irq_wake(encoder->irq_b); | |
| 319 | + for (i = 0; i < encoder->gpios->ndescs; ++i) | |
| 320 | + disable_irq_wake(encoder->irq[i]); | |
| 424 | 321 | } |
| 425 | 322 | |
| 426 | 323 | return 0; |
| 427 | 324 | } |
| 428 | −#endif | |
| 429 | 325 | |
| 430 | 326 | static SIMPLE_DEV_PM_OPS(rotary_encoder_pm_ops, |
| 431 | − rotary_encoder_suspend, rotary_encoder_resume); | |
| 327 | + rotary_encoder_suspend, rotary_encoder_resume); | |
| 328 | + | |
| 329 | +#ifdef CONFIG_OF | |
| 330 | +static const struct of_device_id rotary_encoder_of_match[] = { | |
| 331 | + { .compatible = "rotary-encoder", }, | |
| 332 | + { }, | |
| 333 | +}; | |
| 334 | +MODULE_DEVICE_TABLE(of, rotary_encoder_of_match); | |
| 335 | +#endif | |
| 432 | 336 | |
| 433 | 337 | static struct platform_driver rotary_encoder_driver = { |
| 434 | 338 | .probe = rotary_encoder_probe, |
| 435 | − .remove = rotary_encoder_remove, | |
| 436 | 339 | .driver = { |
| 437 | 340 | .name = DRV_NAME, |
| 438 | 341 | .pm = &rotary_encoder_pm_ops, |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | #define DRIVER_NAME "elan_i2c" |
| 43 | 43 | #define ELAN_DRIVER_VERSION "1.6.1" |
| 44 | +#define ELAN_VENDOR_ID 0x04f3 | |
| 44 | 45 | #define ETP_MAX_PRESSURE 255 |
| 45 | 46 | #define ETP_FWIDTH_REDUCE 90 |
| 46 | 47 | #define ETP_FINGER_WIDTH 15 |
| @@ -914,6 +915,8 @@ static int elan_setup_input_device(struct elan_tp_data *data) · 867 unmodified lines | ||
| 914 | 915 | |
| 915 | 916 | input->name = "Elan Touchpad"; |
| 916 | 917 | input->id.bustype = BUS_I2C; |
| 918 | + input->id.vendor = ELAN_VENDOR_ID; | |
| 919 | + input->id.product = data->product_id; | |
| 917 | 920 | input_set_drvdata(input, data); |
| 918 | 921 | |
| 919 | 922 | error = input_mt_init_slots(input, ETP_MAX_FINGERS, |
| @@ -145,6 +145,7 @@ static int parkbd_getport(struct parport *pp) · 144 unmodified lines | ||
| 145 | 145 | { |
| 146 | 146 | struct pardev_cb parkbd_parport_cb; |
| 147 | 147 | |
| 148 | + memset(&parkbd_parport_cb, 0, sizeof(parkbd_parport_cb)); | |
| 148 | 149 | parkbd_parport_cb.irq_func = parkbd_interrupt; |
| 149 | 150 | parkbd_parport_cb.flags = PARPORT_FLAG_EXCL; |
| 150 | 151 | |
| @@ -1819,6 +1819,14 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) · 1818 unmodified lines | ||
| 1819 | 1819 | input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); |
| 1820 | 1820 | input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0); |
| 1821 | 1821 | |
| 1822 | + /* Verify that a device really has an endpoint */ | |
| 1823 | + if (intf->altsetting[0].desc.bNumEndpoints < 1) { | |
| 1824 | + dev_err(&intf->dev, | |
| 1825 | + "interface has %d endpoints, but must have minimum 1\n", | |
| 1826 | + intf->altsetting[0].desc.bNumEndpoints); | |
| 1827 | + err = -EINVAL; | |
| 1828 | + goto fail3; | |
| 1829 | + } | |
| 1822 | 1830 | endpoint = &intf->altsetting[0].endpoint[0].desc; |
| 1823 | 1831 | |
| 1824 | 1832 | /* Go set up our URB, which is called when the tablet receives |
| @@ -1861,6 +1869,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) · 36 unmodified lines | ||
| 1861 | 1869 | if (i == ARRAY_SIZE(speeds)) { |
| 1862 | 1870 | dev_info(&intf->dev, |
| 1863 | 1871 | "Aiptek tried all speeds, no sane response\n"); |
| 1872 | + err = -EINVAL; | |
| 1864 | 1873 | goto fail3; |
| 1865 | 1874 | } |
| 1866 | 1875 | |
| @@ -2471,6 +2471,31 @@ static struct mxt_acpi_platform_data samus_platform_data[] = { · 2470 unmodified lines | ||
| 2471 | 2471 | { } |
| 2472 | 2472 | }; |
| 2473 | 2473 | |
| 2474 | +static unsigned int chromebook_tp_buttons[] = { | |
| 2475 | + KEY_RESERVED, | |
| 2476 | + KEY_RESERVED, | |
| 2477 | + KEY_RESERVED, | |
| 2478 | + KEY_RESERVED, | |
| 2479 | + KEY_RESERVED, | |
| 2480 | + BTN_LEFT | |
| 2481 | +}; | |
| 2482 | + | |
| 2483 | +static struct mxt_acpi_platform_data chromebook_platform_data[] = { | |
| 2484 | + { | |
| 2485 | + /* Touchpad */ | |
| 2486 | + .hid = "ATML0000", | |
| 2487 | + .pdata = { | |
| 2488 | + .t19_num_keys = ARRAY_SIZE(chromebook_tp_buttons), | |
| 2489 | + .t19_keymap = chromebook_tp_buttons, | |
| 2490 | + }, | |
| 2491 | + }, | |
| 2492 | + { | |
| 2493 | + /* Touchscreen */ | |
| 2494 | + .hid = "ATML0001", | |
| 2495 | + }, | |
| 2496 | + { } | |
| 2497 | +}; | |
| 2498 | + | |
| 2474 | 2499 | static const struct dmi_system_id mxt_dmi_table[] = { |
| 2475 | 2500 | { |
| 2476 | 2501 | /* 2015 Google Pixel */ |
| @@ -2481,6 +2506,14 @@ static const struct dmi_system_id mxt_dmi_table[] = { · 4 unmodified lines | ||
| 2481 | 2506 | }, |
| 2482 | 2507 | .driver_data = samus_platform_data, |
| 2483 | 2508 | }, |
| 2509 | + { | |
| 2510 | + /* Other Google Chromebooks */ | |
| 2511 | + .ident = "Chromebook", | |
| 2512 | + .matches = { | |
| 2513 | + DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), | |
| 2514 | + }, | |
| 2515 | + .driver_data = chromebook_platform_data, | |
| 2516 | + }, | |
| 2484 | 2517 | { } |
| 2485 | 2518 | }; |
| 2486 | 2519 | |
| @@ -2685,6 +2718,7 @@ static const struct i2c_device_id mxt_id[] = { · 198 unmodified lines | ||
| 2685 | 2718 | { "qt602240_ts", 0 }, |
| 2686 | 2719 | { "atmel_mxt_ts", 0 }, |
| 2687 | 2720 | { "atmel_mxt_tp", 0 }, |
| 2721 | + { "maxtouch", 0 }, | |
| 2688 | 2722 | { "mXT224", 0 }, |
| 2689 | 2723 | { } |
| 2690 | 2724 | }; |
| @@ -1316,7 +1316,13 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) · 1315 unmodified lines | ||
| 1316 | 1316 | |
| 1317 | 1317 | disable_irq(client->irq); |
| 1318 | 1318 | |
| 1319 | − if (device_may_wakeup(dev) || ts->keep_power_in_suspend) { | |
| 1319 | + if (device_may_wakeup(dev)) { | |
| 1320 | + /* | |
| 1321 | + * The device will automatically enter idle mode | |
| 1322 | + * that has reduced power consumption. | |
| 1323 | + */ | |
| 1324 | + ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); | |
| 1325 | + } else if (ts->keep_power_in_suspend) { | |
| 1320 | 1326 | for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { |
| 1321 | 1327 | error = elants_i2c_send(client, set_sleep_cmd, |
| 1322 | 1328 | sizeof(set_sleep_cmd)); |
| @@ -1326,10 +1332,6 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) · 3 unmodified lines | ||
| 1326 | 1332 | dev_err(&client->dev, |
| 1327 | 1333 | "suspend command failed: %d\n", error); |
| 1328 | 1334 | } |
| 1329 | − | |
| 1330 | − if (device_may_wakeup(dev)) | |
| 1331 | − ts->wake_irq_enabled = | |
| 1332 | − (enable_irq_wake(client->irq) == 0); | |
| 1333 | 1335 | } else { |
| 1334 | 1336 | elants_i2c_power_off(ts); |
| 1335 | 1337 | } |
| @@ -1345,10 +1347,11 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) · 9 unmodified lines | ||
| 1345 | 1347 | int retry_cnt; |
| 1346 | 1348 | int error; |
| 1347 | 1349 | |
| 1348 | − if (device_may_wakeup(dev) && ts->wake_irq_enabled) | |
| 1349 | − disable_irq_wake(client->irq); | |
| 1350 | − | |
| 1351 | − if (ts->keep_power_in_suspend) { | |
| 1350 | + if (device_may_wakeup(dev)) { | |
| 1351 | + if (ts->wake_irq_enabled) | |
| 1352 | + disable_irq_wake(client->irq); | |
| 1353 | + elants_i2c_sw_reset(client); | |
| 1354 | + } else if (ts->keep_power_in_suspend) { | |
| 1352 | 1355 | for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { |
| 1353 | 1356 | error = elants_i2c_send(client, set_active_cmd, |
| 1354 | 1357 | sizeof(set_active_cmd)); |
| @@ -494,6 +494,22 @@ static void handle_fault_error(struct fault *fault) · 493 unmodified lines | ||
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | +static bool access_error(struct vm_area_struct *vma, struct fault *fault) | |
| 498 | +{ | |
| 499 | + unsigned long requested = 0; | |
| 500 | + | |
| 501 | + if (fault->flags & PPR_FAULT_EXEC) | |
| 502 | + requested |= VM_EXEC; | |
| 503 | + | |
| 504 | + if (fault->flags & PPR_FAULT_READ) | |
| 505 | + requested |= VM_READ; | |
| 506 | + | |
| 507 | + if (fault->flags & PPR_FAULT_WRITE) | |
| 508 | + requested |= VM_WRITE; | |
| 509 | + | |
| 510 | + return (requested & ~vma->vm_flags) != 0; | |
| 511 | +} | |
| 512 | + | |
| 497 | 513 | static void do_fault(struct work_struct *work) |
| 498 | 514 | { |
| 499 | 515 | struct fault *fault = container_of(work, struct fault, work); |
| @@ -516,8 +532,8 @@ static void do_fault(struct work_struct *work) · 16 unmodified lines | ||
| 516 | 532 | goto out; |
| 517 | 533 | } |
| 518 | 534 | |
| 519 | − if (!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))) { | |
| 520 | − /* handle_mm_fault would BUG_ON() */ | |
| 535 | + /* Check if we have the right permissions on the vma */ | |
| 536 | + if (access_error(vma, fault)) { | |
| 521 | 537 | up_read(&mm->mmap_sem); |
| 522 | 538 | handle_fault_error(fault); |
| 523 | 539 | goto out; |
| @@ -21,10 +21,13 @@ · 20 unmodified lines | ||
| 21 | 21 | |
| 22 | 22 | #include <linux/device.h> |
| 23 | 23 | #include <linux/dma-iommu.h> |
| 24 | +#include <linux/gfp.h> | |
| 24 | 25 | #include <linux/huge_mm.h> |
| 25 | 26 | #include <linux/iommu.h> |
| 26 | 27 | #include <linux/iova.h> |
| 27 | 28 | #include <linux/mm.h> |
| 29 | +#include <linux/scatterlist.h> | |
| 30 | +#include <linux/vmalloc.h> | |
| 28 | 31 | |
| 29 | 32 | int iommu_dma_init(void) |
| 30 | 33 | { |
| @@ -191,6 +194,7 @@ static struct page **__iommu_dma_alloc_pages(unsigned int count, gfp_t gfp) · 160 unmodified lines | ||
| 191 | 194 | { |
| 192 | 195 | struct page **pages; |
| 193 | 196 | unsigned int i = 0, array_size = count * sizeof(*pages); |
| 197 | + unsigned int order = MAX_ORDER; | |
| 194 | 198 | |
| 195 | 199 | if (array_size <= PAGE_SIZE) |
| 196 | 200 | pages = kzalloc(array_size, GFP_KERNEL); |
| @@ -204,14 +208,15 @@ static struct page **__iommu_dma_alloc_pages(unsigned int count, gfp_t gfp) · 7 unmodified lines | ||
| 204 | 208 | |
| 205 | 209 | while (count) { |
| 206 | 210 | struct page *page = NULL; |
| 207 | − int j, order = __fls(count); | |
| 211 | + int j; | |
| 208 | 212 | |
| 209 | 213 | /* |
| 210 | 214 | * Higher-order allocations are a convenience rather |
| 211 | 215 | * than a necessity, hence using __GFP_NORETRY until |
| 212 | 216 | * falling back to single-page allocations. |
| 213 | 217 | */ |
| 214 | − for (order = min(order, MAX_ORDER); order > 0; order--) { | |
| 218 | + for (order = min_t(unsigned int, order, __fls(count)); | |
| 219 | + order > 0; order--) { | |
| 215 | 220 | page = alloc_pages(gfp | __GFP_NORETRY, order); |
| 216 | 221 | if (!page) |
| 217 | 222 | continue; |
| @@ -453,7 +458,7 @@ int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg, · 235 unmodified lines | ||
| 453 | 458 | size_t s_offset = iova_offset(iovad, s->offset); |
| 454 | 459 | size_t s_length = s->length; |
| 455 | 460 | |
| 456 | − sg_dma_address(s) = s->offset; | |
| 461 | + sg_dma_address(s) = s_offset; | |
| 457 | 462 | sg_dma_len(s) = s_length; |
| 458 | 463 | s->offset -= s_offset; |
| 459 | 464 | s_length = iova_align(iovad, s_length + s_offset); |
| @@ -2159,7 +2159,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, · 2158 unmodified lines | ||
| 2159 | 2159 | sg_res = aligned_nrpages(sg->offset, sg->length); |
| 2160 | 2160 | sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset; |
| 2161 | 2161 | sg->dma_length = sg->length; |
| 2162 | − pteval = (sg_phys(sg) & PAGE_MASK) | prot; | |
| 2162 | + pteval = page_to_phys(sg_page(sg)) | prot; | |
| 2163 | 2163 | phys_pfn = pteval >> VTD_PAGE_SHIFT; |
| 2164 | 2164 | } |
| 2165 | 2165 | |
| @@ -3704,7 +3704,7 @@ static int intel_nontranslate_map_sg(struct device *hddev, · 1538 unmodified lines | ||
| 3704 | 3704 | |
| 3705 | 3705 | for_each_sg(sglist, sg, nelems, i) { |
| 3706 | 3706 | BUG_ON(!sg_page(sg)); |
| 3707 | − sg->dma_address = sg_phys(sg); | |
| 3707 | + sg->dma_address = page_to_phys(sg_page(sg)) + sg->offset; | |
| 3708 | 3708 | sg->dma_length = sg->length; |
| 3709 | 3709 | } |
| 3710 | 3710 | return nelems; |
| @@ -484,6 +484,23 @@ struct page_req_dsc { · 483 unmodified lines | ||
| 484 | 484 | }; |
| 485 | 485 | |
| 486 | 486 | #define PRQ_RING_MASK ((0x1000 << PRQ_ORDER) - 0x10) |
| 487 | + | |
| 488 | +static bool access_error(struct vm_area_struct *vma, struct page_req_dsc *req) | |
| 489 | +{ | |
| 490 | + unsigned long requested = 0; | |
| 491 | + | |
| 492 | + if (req->exe_req) | |
| 493 | + requested |= VM_EXEC; | |
| 494 | + | |
| 495 | + if (req->rd_req) | |
| 496 | + requested |= VM_READ; | |
| 497 | + | |
| 498 | + if (req->wr_req) | |
| 499 | + requested |= VM_WRITE; | |
| 500 | + | |
| 501 | + return (requested & ~vma->vm_flags) != 0; | |
| 502 | +} | |
| 503 | + | |
| 487 | 504 | static irqreturn_t prq_event_thread(int irq, void *d) |
| 488 | 505 | { |
| 489 | 506 | struct intel_iommu *iommu = d; |
| @@ -539,6 +556,9 @@ static irqreturn_t prq_event_thread(int irq, void *d) · 49 unmodified lines | ||
| 539 | 556 | if (!vma || address < vma->vm_start) |
| 540 | 557 | goto invalid; |
| 541 | 558 | |
| 559 | + if (access_error(vma, req)) | |
| 560 | + goto invalid; | |
| 561 | + | |
| 542 | 562 | ret = handle_mm_fault(svm->mm, vma, address, |
| 543 | 563 | req->wr_req ? FAULT_FLAG_WRITE : 0); |
| 544 | 564 | if (ret & VM_FAULT_ERROR) |
| @@ -1430,7 +1430,7 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, · 1429 unmodified lines | ||
| 1430 | 1430 | min_pagesz = 1 << __ffs(domain->ops->pgsize_bitmap); |
| 1431 | 1431 | |
| 1432 | 1432 | for_each_sg(sg, s, nents, i) { |
| 1433 | − phys_addr_t phys = sg_phys(s); | |
| 1433 | + phys_addr_t phys = page_to_phys(sg_page(s)) + s->offset; | |
| 1434 | 1434 | |
| 1435 | 1435 | /* |
| 1436 | 1436 | * We are mapping on IOMMU page boundaries, so offset within |
| @@ -295,7 +295,7 @@ static struct iommu_gather_ops ipmmu_gather_ops = { · 294 unmodified lines | ||
| 295 | 295 | |
| 296 | 296 | static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain) |
| 297 | 297 | { |
| 298 | − phys_addr_t ttbr; | |
| 298 | + u64 ttbr; | |
| 299 | 299 | |
| 300 | 300 | /* |
| 301 | 301 | * Allocate the page table operations. |
| @@ -67,8 +67,7 @@ static int write_modem(struct cardstate *cs) · 66 unmodified lines | ||
| 67 | 67 | struct sk_buff *skb = bcs->tx_skb; |
| 68 | 68 | int sent = -EOPNOTSUPP; |
| 69 | 69 | |
| 70 | − if (!tty || !tty->driver || !skb) | |
| 71 | − return -EINVAL; | |
| 70 | + WARN_ON(!tty || !tty->ops || !skb); | |
| 72 | 71 | |
| 73 | 72 | if (!skb->len) { |
| 74 | 73 | dev_kfree_skb_any(skb); |
| @@ -109,8 +108,7 @@ static int send_cb(struct cardstate *cs) · 34 unmodified lines | ||
| 109 | 108 | unsigned long flags; |
| 110 | 109 | int sent = 0; |
| 111 | 110 | |
| 112 | − if (!tty || !tty->driver) | |
| 113 | − return -EFAULT; | |
| 111 | + WARN_ON(!tty || !tty->ops); | |
| 114 | 112 | |
| 115 | 113 | cb = cs->cmdbuf; |
| 116 | 114 | if (!cb) |
| @@ -370,19 +368,18 @@ static void gigaset_freecshw(struct cardstate *cs) · 253 unmodified lines | ||
| 370 | 368 | tasklet_kill(&cs->write_tasklet); |
| 371 | 369 | if (!cs->hw.ser) |
| 372 | 370 | return; |
| 373 | − dev_set_drvdata(&cs->hw.ser->dev.dev, NULL); | |
| 374 | 371 | platform_device_unregister(&cs->hw.ser->dev); |
| 375 | − kfree(cs->hw.ser); | |
| 376 | − cs->hw.ser = NULL; | |
| 377 | 372 | } |
| 378 | 373 | |
| 379 | 374 | static void gigaset_device_release(struct device *dev) |
| 380 | 375 | { |
| 381 | − struct platform_device *pdev = to_platform_device(dev); | |
| 376 | + struct cardstate *cs = dev_get_drvdata(dev); | |
| 382 | 377 | |
| 383 | − /* adapted from platform_device_release() in drivers/base/platform.c */ | |
| 384 | − kfree(dev->platform_data); | |
| 385 | − kfree(pdev->resource); | |
| 378 | + if (!cs) | |
| 379 | + return; | |
| 380 | + dev_set_drvdata(dev, NULL); | |
| 381 | + kfree(cs->hw.ser); | |
| 382 | + cs->hw.ser = NULL; | |
| 386 | 383 | } |
| 387 | 384 | |
| 388 | 385 | /* |
| @@ -432,7 +429,9 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, · 43 unmodified lines | ||
| 432 | 429 | struct tty_struct *tty = cs->hw.ser->tty; |
| 433 | 430 | unsigned int set, clear; |
| 434 | 431 | |
| 435 | − if (!tty || !tty->driver || !tty->ops->tiocmset) | |
| 432 | + WARN_ON(!tty || !tty->ops); | |
| 433 | + /* tiocmset is an optional tty driver method */ | |
| 434 | + if (!tty->ops->tiocmset) | |
| 436 | 435 | return -EINVAL; |
| 437 | 436 | set = new_state & ~old_state; |
| 438 | 437 | clear = old_state & ~new_state; |
| @@ -1170,7 +1170,7 @@ mISDNipac_irq(struct ipac_hw *ipac, int maxloop) · 1169 unmodified lines | ||
| 1170 | 1170 | |
| 1171 | 1171 | if (ipac->type & IPAC_TYPE_IPACX) { |
| 1172 | 1172 | ista = ReadIPAC(ipac, ISACX_ISTA); |
| 1173 | − while (ista && cnt--) { | |
| 1173 | + while (ista && --cnt) { | |
| 1174 | 1174 | pr_debug("%s: ISTA %02x\n", ipac->name, ista); |
| 1175 | 1175 | if (ista & IPACX__ICA) |
| 1176 | 1176 | ipac_irq(&ipac->hscx[0], ista); |
| @@ -1182,7 +1182,7 @@ mISDNipac_irq(struct ipac_hw *ipac, int maxloop) · 5 unmodified lines | ||
| 1182 | 1182 | } |
| 1183 | 1183 | } else if (ipac->type & IPAC_TYPE_IPAC) { |
| 1184 | 1184 | ista = ReadIPAC(ipac, IPAC_ISTA); |
| 1185 | − while (ista && cnt--) { | |
| 1185 | + while (ista && --cnt) { | |
| 1186 | 1186 | pr_debug("%s: ISTA %02x\n", ipac->name, ista); |
| 1187 | 1187 | if (ista & (IPAC__ICD | IPAC__EXD)) { |
| 1188 | 1188 | istad = ReadISAC(isac, ISAC_ISTA); |
| @@ -1200,7 +1200,7 @@ mISDNipac_irq(struct ipac_hw *ipac, int maxloop) · 11 unmodified lines | ||
| 1200 | 1200 | ista = ReadIPAC(ipac, IPAC_ISTA); |
| 1201 | 1201 | } |
| 1202 | 1202 | } else if (ipac->type & IPAC_TYPE_HSCX) { |
| 1203 | − while (cnt) { | |
| 1203 | + while (--cnt) { | |
| 1204 | 1204 | ista = ReadIPAC(ipac, IPAC_ISTAB + ipac->hscx[1].off); |
| 1205 | 1205 | pr_debug("%s: B2 ISTA %02x\n", ipac->name, ista); |
| 1206 | 1206 | if (ista) |
| @@ -1211,7 +1211,6 @@ mISDNipac_irq(struct ipac_hw *ipac, int maxloop) · 4 unmodified lines | ||
| 1211 | 1211 | mISDNisac_irq(isac, istad); |
| 1212 | 1212 | if (0 == (ista | istad)) |
| 1213 | 1213 | break; |
| 1214 | − cnt--; | |
| 1215 | 1214 | } |
| 1216 | 1215 | } |
| 1217 | 1216 | if (cnt > maxloop) /* only for ISAC/HSCX without PCI IRQ test */ |
| @@ -75,7 +75,7 @@ static int gennvm_block_bb(struct ppa_addr ppa, int nr_blocks, u8 *blks, · 74 unmodified lines | ||
| 75 | 75 | struct nvm_block *blk; |
| 76 | 76 | int i; |
| 77 | 77 | |
| 78 | − lun = &gn->luns[(dev->nr_luns * ppa.g.ch) + ppa.g.lun]; | |
| 78 | + lun = &gn->luns[(dev->luns_per_chnl * ppa.g.ch) + ppa.g.lun]; | |
| 79 | 79 | |
| 80 | 80 | for (i = 0; i < nr_blocks; i++) { |
| 81 | 81 | if (blks[i] == 0) |
| @@ -314,8 +314,8 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio) · 313 unmodified lines | ||
| 314 | 314 | */ |
| 315 | 315 | void mddev_suspend(struct mddev *mddev) |
| 316 | 316 | { |
| 317 | − BUG_ON(mddev->suspended); | |
| 318 | − mddev->suspended = 1; | |
| 317 | + if (mddev->suspended++) | |
| 318 | + return; | |
| 319 | 319 | synchronize_rcu(); |
| 320 | 320 | wait_event(mddev->sb_wait, atomic_read(&mddev->active_io) == 0); |
| 321 | 321 | mddev->pers->quiesce(mddev, 1); |
| @@ -326,7 +326,8 @@ EXPORT_SYMBOL_GPL(mddev_suspend); · 4 unmodified lines | ||
| 326 | 326 | |
| 327 | 327 | void mddev_resume(struct mddev *mddev) |
| 328 | 328 | { |
| 329 | − mddev->suspended = 0; | |
| 329 | + if (--mddev->suspended) | |
| 330 | + return; | |
| 330 | 331 | wake_up(&mddev->sb_wait); |
| 331 | 332 | mddev->pers->quiesce(mddev, 0); |
| 332 | 333 | |
| @@ -1652,7 +1653,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev) · 1319 unmodified lines | ||
| 1652 | 1653 | rdev->journal_tail = le64_to_cpu(sb->journal_tail); |
| 1653 | 1654 | if (mddev->recovery_cp == MaxSector) |
| 1654 | 1655 | set_bit(MD_JOURNAL_CLEAN, &mddev->flags); |
| 1655 | − rdev->raid_disk = mddev->raid_disks; | |
| 1656 | + rdev->raid_disk = 0; | |
| 1656 | 1657 | break; |
| 1657 | 1658 | default: |
| 1658 | 1659 | rdev->saved_raid_disk = role; |
| @@ -2773,6 +2774,7 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len) · 1114 unmodified lines | ||
| 2773 | 2774 | /* Activating a spare .. or possibly reactivating |
| 2774 | 2775 | * if we ever get bitmaps working here. |
| 2775 | 2776 | */ |
| 2777 | + int err; | |
| 2776 | 2778 | |
| 2777 | 2779 | if (rdev->raid_disk != -1) |
| 2778 | 2780 | return -EBUSY; |
| @@ -2794,9 +2796,15 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len) · 15 unmodified lines | ||
| 2794 | 2796 | rdev->saved_raid_disk = -1; |
| 2795 | 2797 | clear_bit(In_sync, &rdev->flags); |
| 2796 | 2798 | clear_bit(Bitmap_sync, &rdev->flags); |
| 2797 | − remove_and_add_spares(rdev->mddev, rdev); | |
| 2798 | − if (rdev->raid_disk == -1) | |
| 2799 | − return -EBUSY; | |
| 2799 | + err = rdev->mddev->pers-> | |
| 2800 | + hot_add_disk(rdev->mddev, rdev); | |
| 2801 | + if (err) { | |
| 2802 | + rdev->raid_disk = -1; | |
| 2803 | + return err; | |
| 2804 | + } else | |
| 2805 | + sysfs_notify_dirent_safe(rdev->sysfs_state); | |
| 2806 | + if (sysfs_link_rdev(rdev->mddev, rdev)) | |
| 2807 | + /* failure here is OK */; | |
| 2800 | 2808 | /* don't wakeup anyone, leave that to userspace. */ |
| 2801 | 2809 | } else { |
| 2802 | 2810 | if (slot >= rdev->mddev->raid_disks && |
| @@ -4318,8 +4326,7 @@ action_store(struct mddev *mddev, const char *page, size_t len) · 1515 unmodified lines | ||
| 4318 | 4326 | } |
| 4319 | 4327 | mddev_unlock(mddev); |
| 4320 | 4328 | } |
| 4321 | − } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || | |
| 4322 | − test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) | |
| 4329 | + } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) | |
| 4323 | 4330 | return -EBUSY; |
| 4324 | 4331 | else if (cmd_match(page, "resync")) |
| 4325 | 4332 | clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); |
| @@ -4332,8 +4339,12 @@ action_store(struct mddev *mddev, const char *page, size_t len) · 6 unmodified lines | ||
| 4332 | 4339 | return -EINVAL; |
| 4333 | 4340 | err = mddev_lock(mddev); |
| 4334 | 4341 | if (!err) { |
| 4335 | − clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); | |
| 4336 | − err = mddev->pers->start_reshape(mddev); | |
| 4342 | + if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) | |
| 4343 | + err = -EBUSY; | |
| 4344 | + else { | |
| 4345 | + clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); | |
| 4346 | + err = mddev->pers->start_reshape(mddev); | |
| 4347 | + } | |
| 4337 | 4348 | mddev_unlock(mddev); |
| 4338 | 4349 | } |
| 4339 | 4350 | if (err) |
| @@ -566,7 +566,9 @@ static inline char * mdname (struct mddev * mddev) · 565 unmodified lines | ||
| 566 | 566 | static inline int sysfs_link_rdev(struct mddev *mddev, struct md_rdev *rdev) |
| 567 | 567 | { |
| 568 | 568 | char nm[20]; |
| 569 | − if (!test_bit(Replacement, &rdev->flags) && mddev->kobj.sd) { | |
| 569 | + if (!test_bit(Replacement, &rdev->flags) && | |
| 570 | + !test_bit(Journal, &rdev->flags) && | |
| 571 | + mddev->kobj.sd) { | |
| 570 | 572 | sprintf(nm, "rd%d", rdev->raid_disk); |
| 571 | 573 | return sysfs_create_link(&mddev->kobj, &rdev->kobj, nm); |
| 572 | 574 | } else |
| @@ -576,7 +578,9 @@ static inline int sysfs_link_rdev(struct mddev *mddev, struct md_rdev *rdev) · 3 unmodified lines | ||
| 576 | 578 | static inline void sysfs_unlink_rdev(struct mddev *mddev, struct md_rdev *rdev) |
| 577 | 579 | { |
| 578 | 580 | char nm[20]; |
| 579 | − if (!test_bit(Replacement, &rdev->flags) && mddev->kobj.sd) { | |
| 581 | + if (!test_bit(Replacement, &rdev->flags) && | |
| 582 | + !test_bit(Journal, &rdev->flags) && | |
| 583 | + mddev->kobj.sd) { | |
| 580 | 584 | sprintf(nm, "rd%d", rdev->raid_disk); |
| 581 | 585 | sysfs_remove_link(&mddev->kobj, nm); |
| 582 | 586 | } |
| @@ -1946,6 +1946,8 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) · 1945 unmodified lines | ||
| 1946 | 1946 | |
| 1947 | 1947 | first = i; |
| 1948 | 1948 | fbio = r10_bio->devs[i].bio; |
| 1949 | + fbio->bi_iter.bi_size = r10_bio->sectors << 9; | |
| 1950 | + fbio->bi_iter.bi_idx = 0; | |
| 1949 | 1951 | |
| 1950 | 1952 | vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9); |
| 1951 | 1953 | /* now find blocks with errors */ |
| @@ -1989,7 +1991,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) · 37 unmodified lines | ||
| 1989 | 1991 | bio_reset(tbio); |
| 1990 | 1992 | |
| 1991 | 1993 | tbio->bi_vcnt = vcnt; |
| 1992 | − tbio->bi_iter.bi_size = r10_bio->sectors << 9; | |
| 1994 | + tbio->bi_iter.bi_size = fbio->bi_iter.bi_size; | |
| 1993 | 1995 | tbio->bi_rw = WRITE; |
| 1994 | 1996 | tbio->bi_private = r10_bio; |
| 1995 | 1997 | tbio->bi_iter.bi_sector = r10_bio->devs[i].addr; |
| @@ -805,11 +805,11 @@ static void ivtv_init_struct2(struct ivtv *itv) · 804 unmodified lines | ||
| 805 | 805 | { |
| 806 | 806 | int i; |
| 807 | 807 | |
| 808 | − for (i = 0; i < IVTV_CARD_MAX_VIDEO_INPUTS - 1; i++) | |
| 808 | + for (i = 0; i < IVTV_CARD_MAX_VIDEO_INPUTS; i++) | |
| 809 | 809 | if (itv->card->video_inputs[i].video_type == 0) |
| 810 | 810 | break; |
| 811 | 811 | itv->nof_inputs = i; |
| 812 | − for (i = 0; i < IVTV_CARD_MAX_AUDIO_INPUTS - 1; i++) | |
| 812 | + for (i = 0; i < IVTV_CARD_MAX_AUDIO_INPUTS; i++) | |
| 813 | 813 | if (itv->card->audio_inputs[i].audio_type == 0) |
| 814 | 814 | break; |
| 815 | 815 | itv->nof_audio_inputs = i; |
| @@ -134,7 +134,7 @@ struct airspy { · 133 unmodified lines | ||
| 134 | 134 | int urbs_submitted; |
| 135 | 135 | |
| 136 | 136 | /* USB control message buffer */ |
| 137 | − #define BUF_SIZE 24 | |
| 137 | + #define BUF_SIZE 128 | |
| 138 | 138 | u8 buf[BUF_SIZE]; |
| 139 | 139 | |
| 140 | 140 | /* Current configuration */ |
| @@ -24,6 +24,15 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <media/videobuf2-v4l2.h> |
| 25 | 25 | #include <media/videobuf2-vmalloc.h> |
| 26 | 26 | |
| 27 | +/* | |
| 28 | + * Used Avago MGA-81563 RF amplifier could be destroyed pretty easily with too | |
| 29 | + * strong signal or transmitting to bad antenna. | |
| 30 | + * Set RF gain control to 'grabbed' state by default for sure. | |
| 31 | + */ | |
| 32 | +static bool hackrf_enable_rf_gain_ctrl; | |
| 33 | +module_param_named(enable_rf_gain_ctrl, hackrf_enable_rf_gain_ctrl, bool, 0644); | |
| 34 | +MODULE_PARM_DESC(enable_rf_gain_ctrl, "enable RX/TX RF amplifier control (warn: could damage amplifier)"); | |
| 35 | + | |
| 27 | 36 | /* HackRF USB API commands (from HackRF Library) */ |
| 28 | 37 | enum { |
| 29 | 38 | CMD_SET_TRANSCEIVER_MODE = 0x01, |
| @@ -1451,6 +1460,7 @@ static int hackrf_probe(struct usb_interface *intf, · 1421 unmodified lines | ||
| 1451 | 1460 | dev_err(dev->dev, "Could not initialize controls\n"); |
| 1452 | 1461 | goto err_v4l2_ctrl_handler_free_rx; |
| 1453 | 1462 | } |
| 1463 | + v4l2_ctrl_grab(dev->rx_rf_gain, !hackrf_enable_rf_gain_ctrl); | |
| 1454 | 1464 | v4l2_ctrl_handler_setup(&dev->rx_ctrl_handler); |
| 1455 | 1465 | |
| 1456 | 1466 | /* Register controls for transmitter */ |
| @@ -1471,6 +1481,7 @@ static int hackrf_probe(struct usb_interface *intf, · 14 unmodified lines | ||
| 1471 | 1481 | dev_err(dev->dev, "Could not initialize controls\n"); |
| 1472 | 1482 | goto err_v4l2_ctrl_handler_free_tx; |
| 1473 | 1483 | } |
| 1484 | + v4l2_ctrl_grab(dev->tx_rf_gain, !hackrf_enable_rf_gain_ctrl); | |
| 1474 | 1485 | v4l2_ctrl_handler_setup(&dev->tx_ctrl_handler); |
| 1475 | 1486 | |
| 1476 | 1487 | /* Register the v4l2_device structure */ |
| @@ -1530,7 +1541,7 @@ err_v4l2_ctrl_handler_free_rx: · 53 unmodified lines | ||
| 1530 | 1541 | err_kfree: |
| 1531 | 1542 | kfree(dev); |
| 1532 | 1543 | err: |
| 1533 | − dev_dbg(dev->dev, "failed=%d\n", ret); | |
| 1544 | + dev_dbg(&intf->dev, "failed=%d\n", ret); | |
| 1534 | 1545 | return ret; |
| 1535 | 1546 | } |
| 1536 | 1547 | |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <linux/module.h> |
| 23 | 23 | #include <linux/kernel.h> |
| 24 | 24 | #include <linux/compiler.h> |
| 25 | +#include <linux/sched.h> | |
| 25 | 26 | #include <linux/spinlock.h> |
| 26 | 27 | #include <linux/types.h> |
| 27 | 28 | #include <linux/slab.h> |
| @@ -426,15 +426,6 @@ int add_mtd_device(struct mtd_info *mtd) · 425 unmodified lines | ||
| 426 | 426 | mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1; |
| 427 | 427 | mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; |
| 428 | 428 | |
| 429 | − if (mtd->dev.parent) { | |
| 430 | − if (!mtd->owner && mtd->dev.parent->driver) | |
| 431 | − mtd->owner = mtd->dev.parent->driver->owner; | |
| 432 | − if (!mtd->name) | |
| 433 | − mtd->name = dev_name(mtd->dev.parent); | |
| 434 | − } else { | |
| 435 | − pr_debug("mtd device won't show a device symlink in sysfs\n"); | |
| 436 | − } | |
| 437 | − | |
| 438 | 429 | /* Some chips always power up locked. Unlock them now */ |
| 439 | 430 | if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) { |
| 440 | 431 | error = mtd_unlock(mtd, 0, mtd->size); |
| @@ -549,6 +540,21 @@ static int mtd_add_device_partitions(struct mtd_info *mtd, · 108 unmodified lines | ||
| 549 | 540 | return 0; |
| 550 | 541 | } |
| 551 | 542 | |
| 543 | +/* | |
| 544 | + * Set a few defaults based on the parent devices, if not provided by the | |
| 545 | + * driver | |
| 546 | + */ | |
| 547 | +static void mtd_set_dev_defaults(struct mtd_info *mtd) | |
| 548 | +{ | |
| 549 | + if (mtd->dev.parent) { | |
| 550 | + if (!mtd->owner && mtd->dev.parent->driver) | |
| 551 | + mtd->owner = mtd->dev.parent->driver->owner; | |
| 552 | + if (!mtd->name) | |
| 553 | + mtd->name = dev_name(mtd->dev.parent); | |
| 554 | + } else { | |
| 555 | + pr_debug("mtd device won't show a device symlink in sysfs\n"); | |
| 556 | + } | |
| 557 | +} | |
| 552 | 558 | |
| 553 | 559 | /** |
| 554 | 560 | * mtd_device_parse_register - parse partitions and register an MTD device. |
| @@ -587,6 +593,8 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, · 32 unmodified lines | ||
| 587 | 593 | int ret; |
| 588 | 594 | struct mtd_partition *real_parts = NULL; |
| 589 | 595 | |
| 596 | + mtd_set_dev_defaults(mtd); | |
| 597 | + | |
| 590 | 598 | ret = parse_mtd_partitions(mtd, types, &real_parts, parser_data); |
| 591 | 599 | if (ret <= 0 && nr_parts && parts) { |
| 592 | 600 | real_parts = kmemdup(parts, sizeof(*parts) * nr_parts, |
| @@ -46,10 +46,18 @@ static int parse_ofpart_partitions(struct mtd_info *master, · 45 unmodified lines | ||
| 46 | 46 | |
| 47 | 47 | ofpart_node = of_get_child_by_name(mtd_node, "partitions"); |
| 48 | 48 | if (!ofpart_node) { |
| 49 | − pr_warn("%s: 'partitions' subnode not found on %s. Trying to parse direct subnodes as partitions.\n", | |
| 50 | − master->name, mtd_node->full_name); | |
| 49 | + /* | |
| 50 | + * We might get here even when ofpart isn't used at all (e.g., | |
| 51 | + * when using another parser), so don't be louder than | |
| 52 | + * KERN_DEBUG | |
| 53 | + */ | |
| 54 | + pr_debug("%s: 'partitions' subnode not found on %s. Trying to parse direct subnodes as partitions.\n", | |
| 55 | + master->name, mtd_node->full_name); | |
| 51 | 56 | ofpart_node = mtd_node; |
| 52 | 57 | dedicated = false; |
| 58 | + } else if (!of_device_is_compatible(ofpart_node, "fixed-partitions")) { | |
| 59 | + /* The 'partitions' subnode might be used by another parser */ | |
| 60 | + return 0; | |
| 53 | 61 | } |
| 54 | 62 | |
| 55 | 63 | /* First count the subnodes */ |
| @@ -516,8 +516,8 @@ static int stm_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) · 515 unmodified lines | ||
| 516 | 516 | status_old = read_sr(nor); |
| 517 | 517 | |
| 518 | 518 | /* Cannot unlock; would unlock larger region than requested */ |
| 519 | − if (stm_is_locked_sr(nor, status_old, ofs - mtd->erasesize, | |
| 520 | − mtd->erasesize)) | |
| 519 | + if (stm_is_locked_sr(nor, ofs - mtd->erasesize, mtd->erasesize, | |
| 520 | + status_old)) | |
| 521 | 521 | return -EINVAL; |
| 522 | 522 | |
| 523 | 523 | /* |
| @@ -1200,8 +1200,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) · 676 unmodified lines | ||
| 1200 | 1200 | |
| 1201 | 1201 | if (JEDEC_MFR(info) == SNOR_MFR_ATMEL || |
| 1202 | 1202 | JEDEC_MFR(info) == SNOR_MFR_INTEL || |
| 1203 | − JEDEC_MFR(info) == SNOR_MFR_SST || | |
| 1204 | − JEDEC_MFR(info) == SNOR_MFR_WINBOND) { | |
| 1203 | + JEDEC_MFR(info) == SNOR_MFR_SST) { | |
| 1205 | 1204 | write_enable(nor); |
| 1206 | 1205 | write_sr(nor, 0); |
| 1207 | 1206 | } |
| @@ -1217,8 +1216,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode) · 9 unmodified lines | ||
| 1217 | 1216 | mtd->_read = spi_nor_read; |
| 1218 | 1217 | |
| 1219 | 1218 | /* NOR protection support for STmicro/Micron chips and similar */ |
| 1220 | − if (JEDEC_MFR(info) == SNOR_MFR_MICRON || | |
| 1221 | − JEDEC_MFR(info) == SNOR_MFR_WINBOND) { | |
| 1219 | + if (JEDEC_MFR(info) == SNOR_MFR_MICRON) { | |
| 1222 | 1220 | nor->flash_lock = stm_lock; |
| 1223 | 1221 | nor->flash_unlock = stm_unlock; |
| 1224 | 1222 | nor->flash_is_locked = stm_is_locked; |
| @@ -236,7 +236,7 @@ int ubi_debugfs_init(void) · 235 unmodified lines | ||
| 236 | 236 | |
| 237 | 237 | dfs_rootdir = debugfs_create_dir("ubi", NULL); |
| 238 | 238 | if (IS_ERR_OR_NULL(dfs_rootdir)) { |
| 239 | − int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir); | |
| 239 | + int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV; | |
| 240 | 240 | |
| 241 | 241 | pr_err("UBI error: cannot create \"ubi\" debugfs directory, error %d\n", |
| 242 | 242 | err); |
| @@ -1299,7 +1299,7 @@ static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) · 1298 unmodified lines | ||
| 1299 | 1299 | if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err)) |
| 1300 | 1300 | goto exit; |
| 1301 | 1301 | |
| 1302 | − crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); | |
| 1302 | + crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC); | |
| 1303 | 1303 | hdr_crc = be32_to_cpu(vid_hdr->hdr_crc); |
| 1304 | 1304 | if (hdr_crc != crc) { |
| 1305 | 1305 | ubi_err(ubi, "bad VID header CRC at PEB %d, calculated %#08x, read %#08x", |
| @@ -603,6 +603,7 @@ static int schedule_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, · 602 unmodified lines | ||
| 603 | 603 | return 0; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | +static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk); | |
| 606 | 607 | /** |
| 607 | 608 | * do_sync_erase - run the erase worker synchronously. |
| 608 | 609 | * @ubi: UBI device description object |
| @@ -615,20 +616,16 @@ static int schedule_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, · 6 unmodified lines | ||
| 615 | 616 | static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, |
| 616 | 617 | int vol_id, int lnum, int torture) |
| 617 | 618 | { |
| 618 | − struct ubi_work *wl_wrk; | |
| 619 | + struct ubi_work wl_wrk; | |
| 619 | 620 | |
| 620 | 621 | dbg_wl("sync erase of PEB %i", e->pnum); |
| 621 | 622 | |
| 622 | − wl_wrk = kmalloc(sizeof(struct ubi_work), GFP_NOFS); | |
| 623 | − if (!wl_wrk) | |
| 624 | − return -ENOMEM; | |
| 625 | − | |
| 626 | − wl_wrk->e = e; | |
| 627 | − wl_wrk->vol_id = vol_id; | |
| 628 | − wl_wrk->lnum = lnum; | |
| 629 | − wl_wrk->torture = torture; | |
| 623 | + wl_wrk.e = e; | |
| 624 | + wl_wrk.vol_id = vol_id; | |
| 625 | + wl_wrk.lnum = lnum; | |
| 626 | + wl_wrk.torture = torture; | |
| 630 | 627 | |
| 631 | − return erase_worker(ubi, wl_wrk, 0); | |
| 628 | + return __erase_worker(ubi, &wl_wrk); | |
| 632 | 629 | } |
| 633 | 630 | |
| 634 | 631 | /** |
| @@ -1014,7 +1011,7 @@ out_unlock: · 379 unmodified lines | ||
| 1014 | 1011 | } |
| 1015 | 1012 | |
| 1016 | 1013 | /** |
| 1017 | − * erase_worker - physical eraseblock erase worker function. | |
| 1014 | + * __erase_worker - physical eraseblock erase worker function. | |
| 1018 | 1015 | * @ubi: UBI device description object |
| 1019 | 1016 | * @wl_wrk: the work object |
| 1020 | 1017 | * @shutdown: non-zero if the worker has to free memory and exit |
| @@ -1025,8 +1022,7 @@ out_unlock: · 4 unmodified lines | ||
| 1025 | 1022 | * needed. Returns zero in case of success and a negative error code in case of |
| 1026 | 1023 | * failure. |
| 1027 | 1024 | */ |
| 1028 | −static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, | |
| 1029 | − int shutdown) | |
| 1025 | +static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk) | |
| 1030 | 1026 | { |
| 1031 | 1027 | struct ubi_wl_entry *e = wl_wrk->e; |
| 1032 | 1028 | int pnum = e->pnum; |
| @@ -1034,21 +1030,11 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, · 1 unmodified line | ||
| 1034 | 1030 | int lnum = wl_wrk->lnum; |
| 1035 | 1031 | int err, available_consumed = 0; |
| 1036 | 1032 | |
| 1037 | − if (shutdown) { | |
| 1038 | − dbg_wl("cancel erasure of PEB %d EC %d", pnum, e->ec); | |
| 1039 | − kfree(wl_wrk); | |
| 1040 | − wl_entry_destroy(ubi, e); | |
| 1041 | − return 0; | |
| 1042 | − } | |
| 1043 | − | |
| 1044 | 1033 | dbg_wl("erase PEB %d EC %d LEB %d:%d", |
| 1045 | 1034 | pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum); |
| 1046 | 1035 | |
| 1047 | 1036 | err = sync_erase(ubi, e, wl_wrk->torture); |
| 1048 | 1037 | if (!err) { |
| 1049 | − /* Fine, we've erased it successfully */ | |
| 1050 | − kfree(wl_wrk); | |
| 1051 | − | |
| 1052 | 1038 | spin_lock(&ubi->wl_lock); |
| 1053 | 1039 | wl_tree_add(e, &ubi->free); |
| 1054 | 1040 | ubi->free_count++; |
| @@ -1066,7 +1052,6 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, · 11 unmodified lines | ||
| 1066 | 1052 | } |
| 1067 | 1053 | |
| 1068 | 1054 | ubi_err(ubi, "failed to erase PEB %d, error %d", pnum, err); |
| 1069 | − kfree(wl_wrk); | |
| 1070 | 1055 | |
| 1071 | 1056 | if (err == -EINTR || err == -ENOMEM || err == -EAGAIN || |
| 1072 | 1057 | err == -EBUSY) { |
| @@ -1075,6 +1060,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, · 2 unmodified lines | ||
| 1075 | 1060 | /* Re-schedule the LEB for erasure */ |
| 1076 | 1061 | err1 = schedule_erase(ubi, e, vol_id, lnum, 0); |
| 1077 | 1062 | if (err1) { |
| 1063 | + wl_entry_destroy(ubi, e); | |
| 1078 | 1064 | err = err1; |
| 1079 | 1065 | goto out_ro; |
| 1080 | 1066 | } |
| @@ -1150,6 +1136,25 @@ out_ro: · 69 unmodified lines | ||
| 1150 | 1136 | return err; |
| 1151 | 1137 | } |
| 1152 | 1138 | |
| 1139 | +static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, | |
| 1140 | + int shutdown) | |
| 1141 | +{ | |
| 1142 | + int ret; | |
| 1143 | + | |
| 1144 | + if (shutdown) { | |
| 1145 | + struct ubi_wl_entry *e = wl_wrk->e; | |
| 1146 | + | |
| 1147 | + dbg_wl("cancel erasure of PEB %d EC %d", e->pnum, e->ec); | |
| 1148 | + kfree(wl_wrk); | |
| 1149 | + wl_entry_destroy(ubi, e); | |
| 1150 | + return 0; | |
| 1151 | + } | |
| 1152 | + | |
| 1153 | + ret = __erase_worker(ubi, wl_wrk); | |
| 1154 | + kfree(wl_wrk); | |
| 1155 | + return ret; | |
| 1156 | +} | |
| 1157 | + | |
| 1153 | 1158 | /** |
| 1154 | 1159 | * ubi_wl_put_peb - return a PEB to the wear-leveling sub-system. |
| 1155 | 1160 | * @ubi: UBI device description object |
| @@ -1849,7 +1849,7 @@ static int xgbe_exit(struct xgbe_prv_data *pdata) · 1848 unmodified lines | ||
| 1849 | 1849 | usleep_range(10, 15); |
| 1850 | 1850 | |
| 1851 | 1851 | /* Poll Until Poll Condition */ |
| 1852 | − while (count-- && XGMAC_IOREAD_BITS(pdata, DMA_MR, SWR)) | |
| 1852 | + while (--count && XGMAC_IOREAD_BITS(pdata, DMA_MR, SWR)) | |
| 1853 | 1853 | usleep_range(500, 600); |
| 1854 | 1854 | |
| 1855 | 1855 | if (!count) |
| @@ -1873,7 +1873,7 @@ static int xgbe_flush_tx_queues(struct xgbe_prv_data *pdata) · 17 unmodified lines | ||
| 1873 | 1873 | /* Poll Until Poll Condition */ |
| 1874 | 1874 | for (i = 0; i < pdata->tx_q_count; i++) { |
| 1875 | 1875 | count = 2000; |
| 1876 | − while (count-- && XGMAC_MTL_IOREAD_BITS(pdata, i, | |
| 1876 | + while (--count && XGMAC_MTL_IOREAD_BITS(pdata, i, | |
| 1877 | 1877 | MTL_Q_TQOMR, FTQ)) |
| 1878 | 1878 | usleep_range(500, 600); |
| 1879 | 1879 | |
| @@ -289,6 +289,7 @@ static int xgene_enet_setup_tx_desc(struct xgene_enet_desc_ring *tx_ring, · 288 unmodified lines | ||
| 289 | 289 | struct sk_buff *skb) |
| 290 | 290 | { |
| 291 | 291 | struct device *dev = ndev_to_dev(tx_ring->ndev); |
| 292 | + struct xgene_enet_pdata *pdata = netdev_priv(tx_ring->ndev); | |
| 292 | 293 | struct xgene_enet_raw_desc *raw_desc; |
| 293 | 294 | __le64 *exp_desc = NULL, *exp_bufs = NULL; |
| 294 | 295 | dma_addr_t dma_addr, pbuf_addr, *frag_dma_addr; |
| @@ -419,6 +420,7 @@ out: · 124 unmodified lines | ||
| 419 | 420 | raw_desc->m0 = cpu_to_le64(SET_VAL(LL, ll) | SET_VAL(NV, nv) | |
| 420 | 421 | SET_VAL(USERINFO, tx_ring->tail)); |
| 421 | 422 | tx_ring->cp_ring->cp_skb[tx_ring->tail] = skb; |
| 423 | + pdata->tx_level += count; | |
| 422 | 424 | tx_ring->tail = tail; |
| 423 | 425 | |
| 424 | 426 | return count; |
| @@ -429,14 +431,13 @@ static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb, · 4 unmodified lines | ||
| 429 | 431 | { |
| 430 | 432 | struct xgene_enet_pdata *pdata = netdev_priv(ndev); |
| 431 | 433 | struct xgene_enet_desc_ring *tx_ring = pdata->tx_ring; |
| 432 | − struct xgene_enet_desc_ring *cp_ring = tx_ring->cp_ring; | |
| 433 | − u32 tx_level, cq_level; | |
| 434 | + u32 tx_level = pdata->tx_level; | |
| 434 | 435 | int count; |
| 435 | 436 | |
| 436 | − tx_level = pdata->ring_ops->len(tx_ring); | |
| 437 | − cq_level = pdata->ring_ops->len(cp_ring); | |
| 438 | − if (unlikely(tx_level > pdata->tx_qcnt_hi || | |
| 439 | − cq_level > pdata->cp_qcnt_hi)) { | |
| 437 | + if (tx_level < pdata->txc_level) | |
| 438 | + tx_level += ((typeof(pdata->tx_level))~0U); | |
| 439 | + | |
| 440 | + if ((tx_level - pdata->txc_level) > pdata->tx_qcnt_hi) { | |
| 440 | 441 | netif_stop_queue(ndev); |
| 441 | 442 | return NETDEV_TX_BUSY; |
| 442 | 443 | } |
| @@ -539,10 +540,13 @@ static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring, · 96 unmodified lines | ||
| 539 | 540 | struct xgene_enet_raw_desc *raw_desc, *exp_desc; |
| 540 | 541 | u16 head = ring->head; |
| 541 | 542 | u16 slots = ring->slots - 1; |
| 542 | − int ret, count = 0, processed = 0; | |
| 543 | + int ret, desc_count, count = 0, processed = 0; | |
| 544 | + bool is_completion; | |
| 543 | 545 | |
| 544 | 546 | do { |
| 545 | 547 | raw_desc = &ring->raw_desc[head]; |
| 548 | + desc_count = 0; | |
| 549 | + is_completion = false; | |
| 546 | 550 | exp_desc = NULL; |
| 547 | 551 | if (unlikely(xgene_enet_is_desc_slot_empty(raw_desc))) |
| 548 | 552 | break; |
| @@ -559,18 +563,24 @@ static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring, · 10 unmodified lines | ||
| 559 | 563 | } |
| 560 | 564 | dma_rmb(); |
| 561 | 565 | count++; |
| 566 | + desc_count++; | |
| 562 | 567 | } |
| 563 | − if (is_rx_desc(raw_desc)) | |
| 568 | + if (is_rx_desc(raw_desc)) { | |
| 564 | 569 | ret = xgene_enet_rx_frame(ring, raw_desc); |
| 565 | − else | |
| 570 | + } else { | |
| 566 | 571 | ret = xgene_enet_tx_completion(ring, raw_desc); |
| 572 | + is_completion = true; | |
| 573 | + } | |
| 567 | 574 | xgene_enet_mark_desc_slot_empty(raw_desc); |
| 568 | 575 | if (exp_desc) |
| 569 | 576 | xgene_enet_mark_desc_slot_empty(exp_desc); |
| 570 | 577 | |
| 571 | 578 | head = (head + 1) & slots; |
| 572 | 579 | count++; |
| 580 | + desc_count++; | |
| 573 | 581 | processed++; |
| 582 | + if (is_completion) | |
| 583 | + pdata->txc_level += desc_count; | |
| 574 | 584 | |
| 575 | 585 | if (ret) |
| 576 | 586 | break; |
| @@ -580,10 +590,8 @@ static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring, · 3 unmodified lines | ||
| 580 | 590 | pdata->ring_ops->wr_cmd(ring, -count); |
| 581 | 591 | ring->head = head; |
| 582 | 592 | |
| 583 | − if (netif_queue_stopped(ring->ndev)) { | |
| 584 | − if (pdata->ring_ops->len(ring) < pdata->cp_qcnt_low) | |
| 585 | − netif_wake_queue(ring->ndev); | |
| 586 | − } | |
| 593 | + if (netif_queue_stopped(ring->ndev)) | |
| 594 | + netif_start_queue(ring->ndev); | |
| 587 | 595 | } |
| 588 | 596 | |
| 589 | 597 | return processed; |
| @@ -1033,9 +1041,7 @@ static int xgene_enet_create_desc_rings(struct net_device *ndev) · 443 unmodified lines | ||
| 1033 | 1041 | pdata->tx_ring->cp_ring = cp_ring; |
| 1034 | 1042 | pdata->tx_ring->dst_ring_num = xgene_enet_dst_ring_num(cp_ring); |
| 1035 | 1043 | |
| 1036 | − pdata->tx_qcnt_hi = pdata->tx_ring->slots / 2; | |
| 1037 | − pdata->cp_qcnt_hi = pdata->rx_ring->slots / 2; | |
| 1038 | − pdata->cp_qcnt_low = pdata->cp_qcnt_hi / 2; | |
| 1044 | + pdata->tx_qcnt_hi = pdata->tx_ring->slots - 128; | |
| 1039 | 1045 | |
| 1040 | 1046 | return 0; |
| 1041 | 1047 | |
| @@ -155,11 +155,11 @@ struct xgene_enet_pdata { · 154 unmodified lines | ||
| 155 | 155 | enum xgene_enet_id enet_id; |
| 156 | 156 | struct xgene_enet_desc_ring *tx_ring; |
| 157 | 157 | struct xgene_enet_desc_ring *rx_ring; |
| 158 | + u16 tx_level; | |
| 159 | + u16 txc_level; | |
| 158 | 160 | char *dev_name; |
| 159 | 161 | u32 rx_buff_cnt; |
| 160 | 162 | u32 tx_qcnt_hi; |
| 161 | − u32 cp_qcnt_hi; | |
| 162 | − u32 cp_qcnt_low; | |
| 163 | 163 | u32 rx_irq; |
| 164 | 164 | u32 txc_irq; |
| 165 | 165 | u8 cq_cnt; |
| @@ -1016,13 +1016,12 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter) · 1015 unmodified lines | ||
| 1016 | 1016 | sizeof(struct atl1c_recv_ret_status) * rx_desc_count + |
| 1017 | 1017 | 8 * 4; |
| 1018 | 1018 | |
| 1019 | − ring_header->desc = pci_alloc_consistent(pdev, ring_header->size, | |
| 1020 | − &ring_header->dma); | |
| 1019 | + ring_header->desc = dma_zalloc_coherent(&pdev->dev, ring_header->size, | |
| 1020 | + &ring_header->dma, GFP_KERNEL); | |
| 1021 | 1021 | if (unlikely(!ring_header->desc)) { |
| 1022 | − dev_err(&pdev->dev, "pci_alloc_consistend failed\n"); | |
| 1022 | + dev_err(&pdev->dev, "could not get memory for DMA buffer\n"); | |
| 1023 | 1023 | goto err_nomem; |
| 1024 | 1024 | } |
| 1025 | − memset(ring_header->desc, 0, ring_header->size); | |
| 1026 | 1025 | /* init TPD ring */ |
| 1027 | 1026 | |
| 1028 | 1027 | tpd_ring[0].dma = roundup(ring_header->dma, 8); |
| @@ -13,6 +13,7 @@ if NET_VENDOR_AURORA · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | config AURORA_NB8800 |
| 15 | 15 | tristate "Aurora AU-NB8800 support" |
| 16 | + depends on HAS_DMA | |
| 16 | 17 | select PHYLIB |
| 17 | 18 | help |
| 18 | 19 | Support for the AU-NB8800 gigabit Ethernet controller. |
| @@ -3430,25 +3430,29 @@ static u32 bnx2x_xmit_type(struct bnx2x *bp, struct sk_buff *skb) · 3429 unmodified lines | ||
| 3430 | 3430 | return rc; |
| 3431 | 3431 | } |
| 3432 | 3432 | |
| 3433 | −#if (MAX_SKB_FRAGS >= MAX_FETCH_BD - 3) | |
| 3433 | +/* VXLAN: 4 = 1 (for linear data BD) + 3 (2 for PBD and last BD) */ | |
| 3434 | +#define BNX2X_NUM_VXLAN_TSO_WIN_SUB_BDS 4 | |
| 3435 | + | |
| 3436 | +/* Regular: 3 = 1 (for linear data BD) + 2 (for PBD and last BD) */ | |
| 3437 | +#define BNX2X_NUM_TSO_WIN_SUB_BDS 3 | |
| 3438 | + | |
| 3439 | +#if (MAX_SKB_FRAGS >= MAX_FETCH_BD - BDS_PER_TX_PKT) | |
| 3434 | 3440 | /* check if packet requires linearization (packet is too fragmented) |
| 3435 | 3441 | no need to check fragmentation if page size > 8K (there will be no |
| 3436 | 3442 | violation to FW restrictions) */ |
| 3437 | 3443 | static int bnx2x_pkt_req_lin(struct bnx2x *bp, struct sk_buff *skb, |
| 3438 | 3444 | u32 xmit_type) |
| 3439 | 3445 | { |
| 3440 | − int to_copy = 0; | |
| 3441 | − int hlen = 0; | |
| 3442 | − int first_bd_sz = 0; | |
| 3446 | + int first_bd_sz = 0, num_tso_win_sub = BNX2X_NUM_TSO_WIN_SUB_BDS; | |
| 3447 | + int to_copy = 0, hlen = 0; | |
| 3443 | 3448 | |
| 3444 | − /* 3 = 1 (for linear data BD) + 2 (for PBD and last BD) */ | |
| 3445 | − if (skb_shinfo(skb)->nr_frags >= (MAX_FETCH_BD - 3)) { | |
| 3449 | + if (xmit_type & XMIT_GSO_ENC) | |
| 3450 | + num_tso_win_sub = BNX2X_NUM_VXLAN_TSO_WIN_SUB_BDS; | |
| 3446 | 3451 | |
| 3452 | + if (skb_shinfo(skb)->nr_frags >= (MAX_FETCH_BD - num_tso_win_sub)) { | |
| 3447 | 3453 | if (xmit_type & XMIT_GSO) { |
| 3448 | 3454 | unsigned short lso_mss = skb_shinfo(skb)->gso_size; |
| 3449 | − /* Check if LSO packet needs to be copied: | |
| 3450 | − 3 = 1 (for headers BD) + 2 (for PBD and last BD) */ | |
| 3451 | − int wnd_size = MAX_FETCH_BD - 3; | |
| 3455 | + int wnd_size = MAX_FETCH_BD - num_tso_win_sub; | |
| 3452 | 3456 | /* Number of windows to check */ |
| 3453 | 3457 | int num_wnds = skb_shinfo(skb)->nr_frags - wnd_size; |
| 3454 | 3458 | int wnd_idx = 0; |
| @@ -2693,17 +2693,16 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp) · 2692 unmodified lines | ||
| 2693 | 2693 | req.ver_upd = DRV_VER_UPD; |
| 2694 | 2694 | |
| 2695 | 2695 | if (BNXT_PF(bp)) { |
| 2696 | − unsigned long vf_req_snif_bmap[4]; | |
| 2696 | + DECLARE_BITMAP(vf_req_snif_bmap, 256); | |
| 2697 | 2697 | u32 *data = (u32 *)vf_req_snif_bmap; |
| 2698 | 2698 | |
| 2699 | − memset(vf_req_snif_bmap, 0, 32); | |
| 2699 | + memset(vf_req_snif_bmap, 0, sizeof(vf_req_snif_bmap)); | |
| 2700 | 2700 | for (i = 0; i < ARRAY_SIZE(bnxt_vf_req_snif); i++) |
| 2701 | 2701 | __set_bit(bnxt_vf_req_snif[i], vf_req_snif_bmap); |
| 2702 | 2702 | |
| 2703 | − for (i = 0; i < 8; i++) { | |
| 2704 | − req.vf_req_fwd[i] = cpu_to_le32(*data); | |
| 2705 | − data++; | |
| 2706 | − } | |
| 2703 | + for (i = 0; i < 8; i++) | |
| 2704 | + req.vf_req_fwd[i] = cpu_to_le32(data[i]); | |
| 2705 | + | |
| 2707 | 2706 | req.enables |= |
| 2708 | 2707 | cpu_to_le32(FUNC_DRV_RGTR_REQ_ENABLES_VF_REQ_FWD); |
| 2709 | 2708 | } |
| @@ -4603,7 +4602,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) · 1893 unmodified lines | ||
| 4603 | 4602 | bp->nge_port_cnt = 1; |
| 4604 | 4603 | } |
| 4605 | 4604 | |
| 4606 | − bp->state = BNXT_STATE_OPEN; | |
| 4605 | + set_bit(BNXT_STATE_OPEN, &bp->state); | |
| 4607 | 4606 | bnxt_enable_int(bp); |
| 4608 | 4607 | /* Enable TX queues */ |
| 4609 | 4608 | bnxt_tx_enable(bp); |
| @@ -4679,8 +4678,10 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) · 69 unmodified lines | ||
| 4679 | 4678 | /* Change device state to avoid TX queue wake up's */ |
| 4680 | 4679 | bnxt_tx_disable(bp); |
| 4681 | 4680 | |
| 4682 | − bp->state = BNXT_STATE_CLOSED; | |
| 4683 | − cancel_work_sync(&bp->sp_task); | |
| 4681 | + clear_bit(BNXT_STATE_OPEN, &bp->state); | |
| 4682 | + smp_mb__after_atomic(); | |
| 4683 | + while (test_bit(BNXT_STATE_IN_SP_TASK, &bp->state)) | |
| 4684 | + msleep(20); | |
| 4684 | 4685 | |
| 4685 | 4686 | /* Flush rings before disabling interrupts */ |
| 4686 | 4687 | bnxt_shutdown_nic(bp, irq_re_init); |
| @@ -5030,8 +5031,10 @@ static void bnxt_dbg_dump_states(struct bnxt *bp) · 343 unmodified lines | ||
| 5030 | 5031 | static void bnxt_reset_task(struct bnxt *bp) |
| 5031 | 5032 | { |
| 5032 | 5033 | bnxt_dbg_dump_states(bp); |
| 5033 | − if (netif_running(bp->dev)) | |
| 5034 | − bnxt_tx_disable(bp); /* prevent tx timout again */ | |
| 5034 | + if (netif_running(bp->dev)) { | |
| 5035 | + bnxt_close_nic(bp, false, false); | |
| 5036 | + bnxt_open_nic(bp, false, false); | |
| 5037 | + } | |
| 5035 | 5038 | } |
| 5036 | 5039 | |
| 5037 | 5040 | static void bnxt_tx_timeout(struct net_device *dev) |
| @@ -5081,8 +5084,12 @@ static void bnxt_sp_task(struct work_struct *work) · 43 unmodified lines | ||
| 5081 | 5084 | struct bnxt *bp = container_of(work, struct bnxt, sp_task); |
| 5082 | 5085 | int rc; |
| 5083 | 5086 | |
| 5084 | − if (bp->state != BNXT_STATE_OPEN) | |
| 5087 | + set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); | |
| 5088 | + smp_mb__after_atomic(); | |
| 5089 | + if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { | |
| 5090 | + clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); | |
| 5085 | 5091 | return; |
| 5092 | + } | |
| 5086 | 5093 | |
| 5087 | 5094 | if (test_and_clear_bit(BNXT_RX_MASK_SP_EVENT, &bp->sp_event)) |
| 5088 | 5095 | bnxt_cfg_rx_mode(bp); |
| @@ -5106,8 +5113,19 @@ static void bnxt_sp_task(struct work_struct *work) · 17 unmodified lines | ||
| 5106 | 5113 | bnxt_hwrm_tunnel_dst_port_free( |
| 5107 | 5114 | bp, TUNNEL_DST_PORT_FREE_REQ_TUNNEL_TYPE_VXLAN); |
| 5108 | 5115 | } |
| 5109 | − if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) | |
| 5116 | + if (test_and_clear_bit(BNXT_RESET_TASK_SP_EVENT, &bp->sp_event)) { | |
| 5117 | + /* bnxt_reset_task() calls bnxt_close_nic() which waits | |
| 5118 | + * for BNXT_STATE_IN_SP_TASK to clear. | |
| 5119 | + */ | |
| 5120 | + clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); | |
| 5121 | + rtnl_lock(); | |
| 5110 | 5122 | bnxt_reset_task(bp); |
| 5123 | + set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); | |
| 5124 | + rtnl_unlock(); | |
| 5125 | + } | |
| 5126 | + | |
| 5127 | + smp_mb__before_atomic(); | |
| 5128 | + clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); | |
| 5111 | 5129 | } |
| 5112 | 5130 | |
| 5113 | 5131 | static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) |
| @@ -5186,7 +5204,7 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) · 72 unmodified lines | ||
| 5186 | 5204 | bp->timer.function = bnxt_timer; |
| 5187 | 5205 | bp->current_interval = BNXT_TIMER_INTERVAL; |
| 5188 | 5206 | |
| 5189 | − bp->state = BNXT_STATE_CLOSED; | |
| 5207 | + clear_bit(BNXT_STATE_OPEN, &bp->state); | |
| 5190 | 5208 | |
| 5191 | 5209 | return 0; |
| 5192 | 5210 | |
| @@ -925,9 +925,9 @@ struct bnxt { · 924 unmodified lines | ||
| 925 | 925 | |
| 926 | 926 | struct timer_list timer; |
| 927 | 927 | |
| 928 | − int state; | |
| 929 | −#define BNXT_STATE_CLOSED 0 | |
| 930 | −#define BNXT_STATE_OPEN 1 | |
| 928 | + unsigned long state; | |
| 929 | +#define BNXT_STATE_OPEN 0 | |
| 930 | +#define BNXT_STATE_IN_SP_TASK 1 | |
| 931 | 931 | |
| 932 | 932 | struct bnxt_irq *irq_tbl; |
| 933 | 933 | u8 mac_addr[ETH_ALEN]; |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #ifdef CONFIG_BNXT_SRIOV |
| 22 | 22 | static int bnxt_vf_ndo_prep(struct bnxt *bp, int vf_id) |
| 23 | 23 | { |
| 24 | − if (bp->state != BNXT_STATE_OPEN) { | |
| 24 | + if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { | |
| 25 | 25 | netdev_err(bp->dev, "vf ndo called though PF is down\n"); |
| 26 | 26 | return -EINVAL; |
| 27 | 27 | } |
| @@ -37,7 +37,6 @@ struct nicpf { · 36 unmodified lines | ||
| 37 | 37 | #define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF) |
| 38 | 38 | #define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF) |
| 39 | 39 | u8 vf_lmac_map[MAX_LMAC]; |
| 40 | − u8 lmac_cnt; | |
| 41 | 40 | struct delayed_work dwork; |
| 42 | 41 | struct workqueue_struct *check_link; |
| 43 | 42 | u8 link[MAX_LMAC]; |
| @@ -280,7 +279,6 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) · 236 unmodified lines | ||
| 280 | 279 | u64 lmac_credit; |
| 281 | 280 | |
| 282 | 281 | nic->num_vf_en = 0; |
| 283 | − nic->lmac_cnt = 0; | |
| 284 | 282 | |
| 285 | 283 | for (bgx = 0; bgx < NIC_MAX_BGX; bgx++) { |
| 286 | 284 | if (!(bgx_map & (1 << bgx))) |
| @@ -290,7 +288,6 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) · 3 unmodified lines | ||
| 290 | 288 | nic->vf_lmac_map[next_bgx_lmac++] = |
| 291 | 289 | NIC_SET_VF_LMAC_MAP(bgx, lmac); |
| 292 | 290 | nic->num_vf_en += lmac_cnt; |
| 293 | − nic->lmac_cnt += lmac_cnt; | |
| 294 | 291 | |
| 295 | 292 | /* Program LMAC credits */ |
| 296 | 293 | lmac_credit = (1ull << 1); /* channel credit enable */ |
| @@ -618,6 +615,21 @@ static int nic_config_loopback(struct nicpf *nic, struct set_loopback *lbk) · 321 unmodified lines | ||
| 618 | 615 | return 0; |
| 619 | 616 | } |
| 620 | 617 | |
| 618 | +static void nic_enable_vf(struct nicpf *nic, int vf, bool enable) | |
| 619 | +{ | |
| 620 | + int bgx, lmac; | |
| 621 | + | |
| 622 | + nic->vf_enabled[vf] = enable; | |
| 623 | + | |
| 624 | + if (vf >= nic->num_vf_en) | |
| 625 | + return; | |
| 626 | + | |
| 627 | + bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); | |
| 628 | + lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); | |
| 629 | + | |
| 630 | + bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, enable); | |
| 631 | +} | |
| 632 | + | |
| 621 | 633 | /* Interrupt handler to handle mailbox messages from VFs */ |
| 622 | 634 | static void nic_handle_mbx_intr(struct nicpf *nic, int vf) |
| 623 | 635 | { |
| @@ -717,29 +729,14 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf) · 93 unmodified lines | ||
| 717 | 729 | break; |
| 718 | 730 | case NIC_MBOX_MSG_CFG_DONE: |
| 719 | 731 | /* Last message of VF config msg sequence */ |
| 720 | − nic->vf_enabled[vf] = true; | |
| 721 | − if (vf >= nic->lmac_cnt) | |
| 722 | − goto unlock; | |
| 723 | − | |
| 724 | − bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); | |
| 725 | − lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); | |
| 726 | − | |
| 727 | − bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, true); | |
| 732 | + nic_enable_vf(nic, vf, true); | |
| 728 | 733 | goto unlock; |
| 729 | 734 | case NIC_MBOX_MSG_SHUTDOWN: |
| 730 | 735 | /* First msg in VF teardown sequence */ |
| 731 | − nic->vf_enabled[vf] = false; | |
| 732 | 736 | if (vf >= nic->num_vf_en) |
| 733 | 737 | nic->sqs_used[vf - nic->num_vf_en] = false; |
| 734 | 738 | nic->pqs_vf[vf] = 0; |
| 735 | − | |
| 736 | − if (vf >= nic->lmac_cnt) | |
| 737 | − break; | |
| 738 | − | |
| 739 | − bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); | |
| 740 | − lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); | |
| 741 | − | |
| 742 | − bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, false); | |
| 739 | + nic_enable_vf(nic, vf, false); | |
| 743 | 740 | break; |
| 744 | 741 | case NIC_MBOX_MSG_ALLOC_SQS: |
| 745 | 742 | nic_alloc_sqs(nic, &mbx.sqs_alloc); |
| @@ -958,7 +955,7 @@ static void nic_poll_for_link(struct work_struct *work) · 212 unmodified lines | ||
| 958 | 955 | |
| 959 | 956 | mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE; |
| 960 | 957 | |
| 961 | − for (vf = 0; vf < nic->lmac_cnt; vf++) { | |
| 958 | + for (vf = 0; vf < nic->num_vf_en; vf++) { | |
| 962 | 959 | /* Poll only if VF is UP */ |
| 963 | 960 | if (!nic->vf_enabled[vf]) |
| 964 | 961 | continue; |
| @@ -295,6 +295,10 @@ struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start, · 294 unmodified lines | ||
| 295 | 295 | INIT_LIST_HEAD(&ctbl->hash_list[i]); |
| 296 | 296 | |
| 297 | 297 | cl_list = t4_alloc_mem(clipt_size*sizeof(struct clip_entry)); |
| 298 | + if (!cl_list) { | |
| 299 | + t4_free_mem(ctbl); | |
| 300 | + return NULL; | |
| 301 | + } | |
| 298 | 302 | ctbl->cl_list = (void *)cl_list; |
| 299 | 303 | |
| 300 | 304 | for (i = 0; i < clipt_size; i++) { |
| @@ -848,8 +848,6 @@ void be_roce_dev_remove(struct be_adapter *); · 847 unmodified lines | ||
| 848 | 848 | /* |
| 849 | 849 | * internal function to open-close roce device during ifup-ifdown. |
| 850 | 850 | */ |
| 851 | −void be_roce_dev_open(struct be_adapter *); | |
| 852 | −void be_roce_dev_close(struct be_adapter *); | |
| 853 | 851 | void be_roce_dev_shutdown(struct be_adapter *); |
| 854 | 852 | |
| 855 | 853 | #endif /* BE_H */ |
| @@ -3299,8 +3299,10 @@ static int be_msix_register(struct be_adapter *adapter) · 3298 unmodified lines | ||
| 3299 | 3299 | |
| 3300 | 3300 | return 0; |
| 3301 | 3301 | err_msix: |
| 3302 | − for (i--, eqo = &adapter->eq_obj[i]; i >= 0; i--, eqo--) | |
| 3302 | + for (i--; i >= 0; i--) { | |
| 3303 | + eqo = &adapter->eq_obj[i]; | |
| 3303 | 3304 | free_irq(be_msix_vec_get(adapter, eqo), eqo); |
| 3305 | + } | |
| 3304 | 3306 | dev_warn(&adapter->pdev->dev, "MSIX Request IRQ failed - err %d\n", |
| 3305 | 3307 | status); |
| 3306 | 3308 | be_msix_disable(adapter); |
| @@ -3432,8 +3434,6 @@ static int be_close(struct net_device *netdev) · 125 unmodified lines | ||
| 3432 | 3434 | |
| 3433 | 3435 | be_disable_if_filters(adapter); |
| 3434 | 3436 | |
| 3435 | − be_roce_dev_close(adapter); | |
| 3436 | − | |
| 3437 | 3437 | if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { |
| 3438 | 3438 | for_all_evt_queues(adapter, eqo, i) { |
| 3439 | 3439 | napi_disable(&eqo->napi); |
| @@ -3601,8 +3601,6 @@ static int be_open(struct net_device *netdev) · 161 unmodified lines | ||
| 3601 | 3601 | be_link_status_update(adapter, link_status); |
| 3602 | 3602 | |
| 3603 | 3603 | netif_tx_start_all_queues(netdev); |
| 3604 | − be_roce_dev_open(adapter); | |
| 3605 | − | |
| 3606 | 3604 | #ifdef CONFIG_BE2NET_VXLAN |
| 3607 | 3605 | if (skyhawk_chip(adapter)) |
| 3608 | 3606 | vxlan_get_rx_port(netdev); |
| @@ -116,40 +116,6 @@ void be_roce_dev_remove(struct be_adapter *adapter) · 115 unmodified lines | ||
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | −static void _be_roce_dev_open(struct be_adapter *adapter) | |
| 120 | −{ | |
| 121 | − if (ocrdma_drv && adapter->ocrdma_dev && | |
| 122 | − ocrdma_drv->state_change_handler) | |
| 123 | − ocrdma_drv->state_change_handler(adapter->ocrdma_dev, | |
| 124 | − BE_DEV_UP); | |
| 125 | −} | |
| 126 | − | |
| 127 | −void be_roce_dev_open(struct be_adapter *adapter) | |
| 128 | −{ | |
| 129 | − if (be_roce_supported(adapter)) { | |
| 130 | − mutex_lock(&be_adapter_list_lock); | |
| 131 | − _be_roce_dev_open(adapter); | |
| 132 | − mutex_unlock(&be_adapter_list_lock); | |
| 133 | − } | |
| 134 | −} | |
| 135 | − | |
| 136 | −static void _be_roce_dev_close(struct be_adapter *adapter) | |
| 137 | −{ | |
| 138 | − if (ocrdma_drv && adapter->ocrdma_dev && | |
| 139 | − ocrdma_drv->state_change_handler) | |
| 140 | − ocrdma_drv->state_change_handler(adapter->ocrdma_dev, | |
| 141 | − BE_DEV_DOWN); | |
| 142 | −} | |
| 143 | − | |
| 144 | −void be_roce_dev_close(struct be_adapter *adapter) | |
| 145 | −{ | |
| 146 | − if (be_roce_supported(adapter)) { | |
| 147 | − mutex_lock(&be_adapter_list_lock); | |
| 148 | − _be_roce_dev_close(adapter); | |
| 149 | − mutex_unlock(&be_adapter_list_lock); | |
| 150 | − } | |
| 151 | −} | |
| 152 | − | |
| 153 | 119 | void be_roce_dev_shutdown(struct be_adapter *adapter) |
| 154 | 120 | { |
| 155 | 121 | if (be_roce_supported(adapter)) { |
| @@ -177,8 +143,6 @@ int be_roce_register_driver(struct ocrdma_driver *drv) · 21 unmodified lines | ||
| 177 | 143 | |
| 178 | 144 | _be_roce_dev_add(dev); |
| 179 | 145 | netdev = dev->netdev; |
| 180 | − if (netif_running(netdev) && netif_oper_up(netdev)) | |
| 181 | − _be_roce_dev_open(dev); | |
| 182 | 146 | } |
| 183 | 147 | mutex_unlock(&be_adapter_list_lock); |
| 184 | 148 | return 0; |
| @@ -60,9 +60,7 @@ struct ocrdma_driver { · 59 unmodified lines | ||
| 60 | 60 | void (*state_change_handler) (struct ocrdma_dev *, u32 new_state); |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | −enum { | |
| 64 | − BE_DEV_UP = 0, | |
| 65 | − BE_DEV_DOWN = 1, | |
| 63 | +enum be_roce_event { | |
| 66 | 64 | BE_DEV_SHUTDOWN = 2 |
| 67 | 65 | }; |
| 68 | 66 | |
| @@ -48,21 +48,15 @@ static void nps_enet_read_rx_fifo(struct net_device *ndev, · 47 unmodified lines | ||
| 48 | 48 | *reg = nps_enet_reg_get(priv, NPS_ENET_REG_RX_BUF); |
| 49 | 49 | else { /* !dst_is_aligned */ |
| 50 | 50 | for (i = 0; i < len; i++, reg++) { |
| 51 | − u32 buf = | |
| 52 | − nps_enet_reg_get(priv, NPS_ENET_REG_RX_BUF); | |
| 53 | − | |
| 54 | − /* to accommodate word-unaligned address of "reg" | |
| 55 | − * we have to do memcpy_toio() instead of simple "=". | |
| 56 | − */ | |
| 57 | − memcpy_toio((void __iomem *)reg, &buf, sizeof(buf)); | |
| 51 | + u32 buf = nps_enet_reg_get(priv, NPS_ENET_REG_RX_BUF); | |
| 52 | + put_unaligned(buf, reg); | |
| 58 | 53 | } |
| 59 | 54 | } |
| 60 | 55 | |
| 61 | 56 | /* copy last bytes (if any) */ |
| 62 | 57 | if (last) { |
| 63 | 58 | u32 buf = nps_enet_reg_get(priv, NPS_ENET_REG_RX_BUF); |
| 64 | − | |
| 65 | − memcpy_toio((void __iomem *)reg, &buf, last); | |
| 59 | + memcpy((u8*)reg, &buf, last); | |
| 66 | 60 | } |
| 67 | 61 | } |
| 68 | 62 | |
| @@ -367,7 +361,7 @@ static void nps_enet_send_frame(struct net_device *ndev, · 298 unmodified lines | ||
| 367 | 361 | struct nps_enet_tx_ctl tx_ctrl; |
| 368 | 362 | short length = skb->len; |
| 369 | 363 | u32 i, len = DIV_ROUND_UP(length, sizeof(u32)); |
| 370 | − u32 *src = (u32 *)virt_to_phys(skb->data); | |
| 364 | + u32 *src = (void *)skb->data; | |
| 371 | 365 | bool src_is_aligned = IS_ALIGNED((unsigned long)src, sizeof(u32)); |
| 372 | 366 | |
| 373 | 367 | tx_ctrl.value = 0; |
| @@ -375,17 +369,11 @@ static void nps_enet_send_frame(struct net_device *ndev, · 1 unmodified line | ||
| 375 | 369 | if (src_is_aligned) |
| 376 | 370 | for (i = 0; i < len; i++, src++) |
| 377 | 371 | nps_enet_reg_set(priv, NPS_ENET_REG_TX_BUF, *src); |
| 378 | − else { /* !src_is_aligned */ | |
| 379 | − for (i = 0; i < len; i++, src++) { | |
| 380 | − u32 buf; | |
| 381 | − | |
| 382 | − /* to accommodate word-unaligned address of "src" | |
| 383 | − * we have to do memcpy_fromio() instead of simple "=" | |
| 384 | − */ | |
| 385 | − memcpy_fromio(&buf, (void __iomem *)src, sizeof(buf)); | |
| 386 | − nps_enet_reg_set(priv, NPS_ENET_REG_TX_BUF, buf); | |
| 387 | − } | |
| 388 | − } | |
| 372 | + else /* !src_is_aligned */ | |
| 373 | + for (i = 0; i < len; i++, src++) | |
| 374 | + nps_enet_reg_set(priv, NPS_ENET_REG_TX_BUF, | |
| 375 | + get_unaligned(src)); | |
| 376 | + | |
| 389 | 377 | /* Write the length of the Frame */ |
| 390 | 378 | tx_ctrl.nt = length; |
| 391 | 379 | |
| @@ -552,7 +552,7 @@ static void tx_restart(struct net_device *dev) · 551 unmodified lines | ||
| 552 | 552 | cbd_t __iomem *prev_bd; |
| 553 | 553 | cbd_t __iomem *last_tx_bd; |
| 554 | 554 | |
| 555 | − last_tx_bd = fep->tx_bd_base + (fpi->tx_ring * sizeof(cbd_t)); | |
| 555 | + last_tx_bd = fep->tx_bd_base + ((fpi->tx_ring - 1) * sizeof(cbd_t)); | |
| 556 | 556 | |
| 557 | 557 | /* get the current bd held in TBPTR and scan back from this point */ |
| 558 | 558 | recheck_bd = curr_tbptr = (cbd_t __iomem *) |
| @@ -464,7 +464,7 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev) · 463 unmodified lines | ||
| 464 | 464 | * address). Print error message but continue anyway. |
| 465 | 465 | */ |
| 466 | 466 | if ((void *)tbipa > priv->map + resource_size(&res) - 4) |
| 467 | − dev_err(&pdev->dev, "invalid register map (should be at least 0x%04x to contain TBI address)\n", | |
| 467 | + dev_err(&pdev->dev, "invalid register map (should be at least 0x%04zx to contain TBI address)\n", | |
| 468 | 468 | ((void *)tbipa - priv->map) + 4); |
| 469 | 469 | |
| 470 | 470 | iowrite32be(be32_to_cpup(prop), tbipa); |
| @@ -894,7 +894,8 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · 893 unmodified lines | ||
| 894 | 894 | FSL_GIANFAR_DEV_HAS_VLAN | |
| 895 | 895 | FSL_GIANFAR_DEV_HAS_MAGIC_PACKET | |
| 896 | 896 | FSL_GIANFAR_DEV_HAS_EXTENDED_HASH | |
| 897 | − FSL_GIANFAR_DEV_HAS_TIMER; | |
| 897 | + FSL_GIANFAR_DEV_HAS_TIMER | | |
| 898 | + FSL_GIANFAR_DEV_HAS_RX_FILER; | |
| 898 | 899 | |
| 899 | 900 | err = of_property_read_string(np, "phy-connection-type", &ctype); |
| 900 | 901 | |
| @@ -1396,8 +1397,9 @@ static int gfar_probe(struct platform_device *ofdev) · 495 unmodified lines | ||
| 1396 | 1397 | priv->rx_queue[i]->rxic = DEFAULT_RXIC; |
| 1397 | 1398 | } |
| 1398 | 1399 | |
| 1399 | − /* always enable rx filer */ | |
| 1400 | − priv->rx_filer_enable = 1; | |
| 1400 | + /* Always enable rx filer if available */ | |
| 1401 | + priv->rx_filer_enable = | |
| 1402 | + (priv->device_flags & FSL_GIANFAR_DEV_HAS_RX_FILER) ? 1 : 0; | |
| 1401 | 1403 | /* Enable most messages by default */ |
| 1402 | 1404 | priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1; |
| 1403 | 1405 | /* use pritority h/w tx queue scheduling for single queue devices */ |
| @@ -923,6 +923,7 @@ struct gfar { · 922 unmodified lines | ||
| 923 | 923 | #define FSL_GIANFAR_DEV_HAS_BUF_STASHING 0x00000400 |
| 924 | 924 | #define FSL_GIANFAR_DEV_HAS_TIMER 0x00000800 |
| 925 | 925 | #define FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER 0x00001000 |
| 926 | +#define FSL_GIANFAR_DEV_HAS_RX_FILER 0x00002000 | |
| 926 | 927 | |
| 927 | 928 | #if (MAXGROUPS == 2) |
| 928 | 929 | #define DEFAULT_MAPPING 0xAA |
| @@ -1259,12 +1259,8 @@ int hns_dsaf_set_mac_uc_entry( · 1258 unmodified lines | ||
| 1259 | 1259 | if (MAC_IS_ALL_ZEROS(mac_entry->addr) || |
| 1260 | 1260 | MAC_IS_BROADCAST(mac_entry->addr) || |
| 1261 | 1261 | MAC_IS_MULTICAST(mac_entry->addr)) { |
| 1262 | − dev_err(dsaf_dev->dev, | |
| 1263 | − "set_uc %s Mac %02x:%02x:%02x:%02x:%02x:%02x err!\n", | |
| 1264 | − dsaf_dev->ae_dev.name, mac_entry->addr[0], | |
| 1265 | − mac_entry->addr[1], mac_entry->addr[2], | |
| 1266 | − mac_entry->addr[3], mac_entry->addr[4], | |
| 1267 | − mac_entry->addr[5]); | |
| 1262 | + dev_err(dsaf_dev->dev, "set_uc %s Mac %pM err!\n", | |
| 1263 | + dsaf_dev->ae_dev.name, mac_entry->addr); | |
| 1268 | 1264 | return -EINVAL; |
| 1269 | 1265 | } |
| 1270 | 1266 | |
| @@ -1331,12 +1327,8 @@ int hns_dsaf_set_mac_mc_entry( · 60 unmodified lines | ||
| 1331 | 1327 | |
| 1332 | 1328 | /* mac addr check */ |
| 1333 | 1329 | if (MAC_IS_ALL_ZEROS(mac_entry->addr)) { |
| 1334 | − dev_err(dsaf_dev->dev, | |
| 1335 | − "set uc %s Mac %02x:%02x:%02x:%02x:%02x:%02x err!\n", | |
| 1336 | − dsaf_dev->ae_dev.name, mac_entry->addr[0], | |
| 1337 | − mac_entry->addr[1], mac_entry->addr[2], | |
| 1338 | − mac_entry->addr[3], | |
| 1339 | − mac_entry->addr[4], mac_entry->addr[5]); | |
| 1330 | + dev_err(dsaf_dev->dev, "set uc %s Mac %pM err!\n", | |
| 1331 | + dsaf_dev->ae_dev.name, mac_entry->addr); | |
| 1340 | 1332 | return -EINVAL; |
| 1341 | 1333 | } |
| 1342 | 1334 | |
| @@ -1410,11 +1402,8 @@ int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev, · 67 unmodified lines | ||
| 1410 | 1402 | |
| 1411 | 1403 | /*chechk mac addr */ |
| 1412 | 1404 | if (MAC_IS_ALL_ZEROS(mac_entry->addr)) { |
| 1413 | − dev_err(dsaf_dev->dev, | |
| 1414 | − "set_entry failed,addr %02x:%02x:%02x:%02x:%02x:%02x!\n", | |
| 1415 | − mac_entry->addr[0], mac_entry->addr[1], | |
| 1416 | − mac_entry->addr[2], mac_entry->addr[3], | |
| 1417 | − mac_entry->addr[4], mac_entry->addr[5]); | |
| 1405 | + dev_err(dsaf_dev->dev, "set_entry failed,addr %pM!\n", | |
| 1406 | + mac_entry->addr); | |
| 1418 | 1407 | return -EINVAL; |
| 1419 | 1408 | } |
| 1420 | 1409 | |
| @@ -1497,9 +1486,8 @@ int hns_dsaf_del_mac_entry(struct dsaf_device *dsaf_dev, u16 vlan_id, · 76 unmodified lines | ||
| 1497 | 1486 | |
| 1498 | 1487 | /*check mac addr */ |
| 1499 | 1488 | if (MAC_IS_ALL_ZEROS(addr) || MAC_IS_BROADCAST(addr)) { |
| 1500 | − dev_err(dsaf_dev->dev, | |
| 1501 | − "del_entry failed,addr %02x:%02x:%02x:%02x:%02x:%02x!\n", | |
| 1502 | − addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); | |
| 1489 | + dev_err(dsaf_dev->dev, "del_entry failed,addr %pM!\n", | |
| 1490 | + addr); | |
| 1503 | 1491 | return -EINVAL; |
| 1504 | 1492 | } |
| 1505 | 1493 | |
| @@ -1563,11 +1551,8 @@ int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev, · 57 unmodified lines | ||
| 1563 | 1551 | |
| 1564 | 1552 | /*check mac addr */ |
| 1565 | 1553 | if (MAC_IS_ALL_ZEROS(mac_entry->addr)) { |
| 1566 | − dev_err(dsaf_dev->dev, | |
| 1567 | − "del_port failed, addr %02x:%02x:%02x:%02x:%02x:%02x!\n", | |
| 1568 | − mac_entry->addr[0], mac_entry->addr[1], | |
| 1569 | − mac_entry->addr[2], mac_entry->addr[3], | |
| 1570 | − mac_entry->addr[4], mac_entry->addr[5]); | |
| 1554 | + dev_err(dsaf_dev->dev, "del_port failed, addr %pM!\n", | |
| 1555 | + mac_entry->addr); | |
| 1571 | 1556 | return -EINVAL; |
| 1572 | 1557 | } |
| 1573 | 1558 | |
| @@ -1644,11 +1629,8 @@ int hns_dsaf_get_mac_uc_entry(struct dsaf_device *dsaf_dev, · 70 unmodified lines | ||
| 1644 | 1629 | /* check macaddr */ |
| 1645 | 1630 | if (MAC_IS_ALL_ZEROS(mac_entry->addr) || |
| 1646 | 1631 | MAC_IS_BROADCAST(mac_entry->addr)) { |
| 1647 | − dev_err(dsaf_dev->dev, | |
| 1648 | − "get_entry failed,addr %02x:%02x:%02x:%02x:%02x:%02x\n", | |
| 1649 | − mac_entry->addr[0], mac_entry->addr[1], | |
| 1650 | − mac_entry->addr[2], mac_entry->addr[3], | |
| 1651 | − mac_entry->addr[4], mac_entry->addr[5]); | |
| 1632 | + dev_err(dsaf_dev->dev, "get_entry failed,addr %pM\n", | |
| 1633 | + mac_entry->addr); | |
| 1652 | 1634 | return -EINVAL; |
| 1653 | 1635 | } |
| 1654 | 1636 | |
| @@ -1695,11 +1677,8 @@ int hns_dsaf_get_mac_mc_entry(struct dsaf_device *dsaf_dev, · 40 unmodified lines | ||
| 1695 | 1677 | /*check mac addr */ |
| 1696 | 1678 | if (MAC_IS_ALL_ZEROS(mac_entry->addr) || |
| 1697 | 1679 | MAC_IS_BROADCAST(mac_entry->addr)) { |
| 1698 | − dev_err(dsaf_dev->dev, | |
| 1699 | − "get_entry failed,addr %02x:%02x:%02x:%02x:%02x:%02x\n", | |
| 1700 | − mac_entry->addr[0], mac_entry->addr[1], | |
| 1701 | − mac_entry->addr[2], mac_entry->addr[3], | |
| 1702 | − mac_entry->addr[4], mac_entry->addr[5]); | |
| 1680 | + dev_err(dsaf_dev->dev, "get_entry failed,addr %pM\n", | |
| 1681 | + mac_entry->addr); | |
| 1703 | 1682 | return -EINVAL; |
| 1704 | 1683 | } |
| 1705 | 1684 | |
| @@ -898,7 +898,7 @@ · 897 unmodified lines | ||
| 898 | 898 | #define XGMAC_PAUSE_CTL_RSP_MODE_B 2 |
| 899 | 899 | #define XGMAC_PAUSE_CTL_TX_XOFF_B 3 |
| 900 | 900 | |
| 901 | −static inline void dsaf_write_reg(void *base, u32 reg, u32 value) | |
| 901 | +static inline void dsaf_write_reg(void __iomem *base, u32 reg, u32 value) | |
| 902 | 902 | { |
| 903 | 903 | u8 __iomem *reg_addr = ACCESS_ONCE(base); |
| 904 | 904 | |
| @@ -908,7 +908,7 @@ static inline void dsaf_write_reg(void *base, u32 reg, u32 value) · 3 unmodified lines | ||
| 908 | 908 | #define dsaf_write_dev(a, reg, value) \ |
| 909 | 909 | dsaf_write_reg((a)->io_base, (reg), (value)) |
| 910 | 910 | |
| 911 | −static inline u32 dsaf_read_reg(u8 *base, u32 reg) | |
| 911 | +static inline u32 dsaf_read_reg(u8 __iomem *base, u32 reg) | |
| 912 | 912 | { |
| 913 | 913 | u8 __iomem *reg_addr = ACCESS_ONCE(base); |
| 914 | 914 | |
| @@ -927,8 +927,8 @@ static inline u32 dsaf_read_reg(u8 *base, u32 reg) · 12 unmodified lines | ||
| 927 | 927 | #define dsaf_set_bit(origin, shift, val) \ |
| 928 | 928 | dsaf_set_field((origin), (1ull << (shift)), (shift), (val)) |
| 929 | 929 | |
| 930 | −static inline void dsaf_set_reg_field(void *base, u32 reg, u32 mask, u32 shift, | |
| 931 | − u32 val) | |
| 930 | +static inline void dsaf_set_reg_field(void __iomem *base, u32 reg, u32 mask, | |
| 931 | + u32 shift, u32 val) | |
| 932 | 932 | { |
| 933 | 933 | u32 origin = dsaf_read_reg(base, reg); |
| 934 | 934 | |
| @@ -947,7 +947,8 @@ static inline void dsaf_set_reg_field(void *base, u32 reg, u32 mask, u32 shift, · 12 unmodified lines | ||
| 947 | 947 | #define dsaf_get_bit(origin, shift) \ |
| 948 | 948 | dsaf_get_field((origin), (1ull << (shift)), (shift)) |
| 949 | 949 | |
| 950 | −static inline u32 dsaf_get_reg_field(void *base, u32 reg, u32 mask, u32 shift) | |
| 950 | +static inline u32 dsaf_get_reg_field(void __iomem *base, u32 reg, u32 mask, | |
| 951 | + u32 shift) | |
| 951 | 952 | { |
| 952 | 953 | u32 origin; |
| 953 | 954 | |
| @@ -567,10 +567,6 @@ i40e_status i40e_init_adminq(struct i40e_hw *hw) · 566 unmodified lines | ||
| 567 | 567 | goto init_adminq_exit; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | − /* initialize locks */ | |
| 571 | − mutex_init(&hw->aq.asq_mutex); | |
| 572 | − mutex_init(&hw->aq.arq_mutex); | |
| 573 | − | |
| 574 | 570 | /* Set up register offsets */ |
| 575 | 571 | i40e_adminq_init_regs(hw); |
| 576 | 572 | |
| @@ -664,8 +660,6 @@ i40e_status i40e_shutdown_adminq(struct i40e_hw *hw) · 87 unmodified lines | ||
| 664 | 660 | i40e_shutdown_asq(hw); |
| 665 | 661 | i40e_shutdown_arq(hw); |
| 666 | 662 | |
| 667 | − /* destroy the locks */ | |
| 668 | − | |
| 669 | 663 | if (hw->nvm_buff.va) |
| 670 | 664 | i40e_free_virt_mem(hw, &hw->nvm_buff); |
| 671 | 665 | |
| @@ -10295,6 +10295,12 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 10294 unmodified lines | ||
| 10295 | 10295 | /* set up a default setting for link flow control */ |
| 10296 | 10296 | pf->hw.fc.requested_mode = I40E_FC_NONE; |
| 10297 | 10297 | |
| 10298 | + /* set up the locks for the AQ, do this only once in probe | |
| 10299 | + * and destroy them only once in remove | |
| 10300 | + */ | |
| 10301 | + mutex_init(&hw->aq.asq_mutex); | |
| 10302 | + mutex_init(&hw->aq.arq_mutex); | |
| 10303 | + | |
| 10298 | 10304 | err = i40e_init_adminq(hw); |
| 10299 | 10305 | |
| 10300 | 10306 | /* provide nvm, fw, api versions */ |
| @@ -10697,7 +10703,6 @@ static void i40e_remove(struct pci_dev *pdev) · 396 unmodified lines | ||
| 10697 | 10703 | set_bit(__I40E_DOWN, &pf->state); |
| 10698 | 10704 | del_timer_sync(&pf->service_timer); |
| 10699 | 10705 | cancel_work_sync(&pf->service_task); |
| 10700 | − i40e_fdir_teardown(pf); | |
| 10701 | 10706 | |
| 10702 | 10707 | if (pf->flags & I40E_FLAG_SRIOV_ENABLED) { |
| 10703 | 10708 | i40e_free_vfs(pf); |
| @@ -10740,6 +10745,10 @@ static void i40e_remove(struct pci_dev *pdev) · 36 unmodified lines | ||
| 10740 | 10745 | "Failed to destroy the Admin Queue resources: %d\n", |
| 10741 | 10746 | ret_code); |
| 10742 | 10747 | |
| 10748 | + /* destroy the locks only once, here */ | |
| 10749 | + mutex_destroy(&hw->aq.arq_mutex); | |
| 10750 | + mutex_destroy(&hw->aq.asq_mutex); | |
| 10751 | + | |
| 10743 | 10752 | /* Clear all dynamic memory lists of rings, q_vectors, and VSIs */ |
| 10744 | 10753 | i40e_clear_interrupt_scheme(pf); |
| 10745 | 10754 | for (i = 0; i < pf->num_alloc_vsi; i++) { |
| @@ -551,10 +551,6 @@ i40e_status i40evf_init_adminq(struct i40e_hw *hw) · 550 unmodified lines | ||
| 551 | 551 | goto init_adminq_exit; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | − /* initialize locks */ | |
| 555 | − mutex_init(&hw->aq.asq_mutex); | |
| 556 | − mutex_init(&hw->aq.arq_mutex); | |
| 557 | − | |
| 558 | 554 | /* Set up register offsets */ |
| 559 | 555 | i40e_adminq_init_regs(hw); |
| 560 | 556 | |
| @@ -596,8 +592,6 @@ i40e_status i40evf_shutdown_adminq(struct i40e_hw *hw) · 35 unmodified lines | ||
| 596 | 592 | i40e_shutdown_asq(hw); |
| 597 | 593 | i40e_shutdown_arq(hw); |
| 598 | 594 | |
| 599 | − /* destroy the locks */ | |
| 600 | − | |
| 601 | 595 | if (hw->nvm_buff.va) |
| 602 | 596 | i40e_free_virt_mem(hw, &hw->nvm_buff); |
| 603 | 597 | |
| @@ -2476,6 +2476,12 @@ static int i40evf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 2475 unmodified lines | ||
| 2476 | 2476 | hw->bus.device = PCI_SLOT(pdev->devfn); |
| 2477 | 2477 | hw->bus.func = PCI_FUNC(pdev->devfn); |
| 2478 | 2478 | |
| 2479 | + /* set up the locks for the AQ, do this only once in probe | |
| 2480 | + * and destroy them only once in remove | |
| 2481 | + */ | |
| 2482 | + mutex_init(&hw->aq.asq_mutex); | |
| 2483 | + mutex_init(&hw->aq.arq_mutex); | |
| 2484 | + | |
| 2479 | 2485 | INIT_LIST_HEAD(&adapter->mac_filter_list); |
| 2480 | 2486 | INIT_LIST_HEAD(&adapter->vlan_filter_list); |
| 2481 | 2487 | |
| @@ -2629,6 +2635,10 @@ static void i40evf_remove(struct pci_dev *pdev) · 147 unmodified lines | ||
| 2629 | 2635 | if (hw->aq.asq.count) |
| 2630 | 2636 | i40evf_shutdown_adminq(hw); |
| 2631 | 2637 | |
| 2638 | + /* destroy the locks only once, here */ | |
| 2639 | + mutex_destroy(&hw->aq.arq_mutex); | |
| 2640 | + mutex_destroy(&hw->aq.asq_mutex); | |
| 2641 | + | |
| 2632 | 2642 | iounmap(hw->hw_addr); |
| 2633 | 2643 | pci_release_regions(pdev); |
| 2634 | 2644 | |
| @@ -7920,6 +7920,9 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc) · 7919 unmodified lines | ||
| 7920 | 7920 | */ |
| 7921 | 7921 | if (netif_running(dev)) |
| 7922 | 7922 | ixgbe_close(dev); |
| 7923 | + else | |
| 7924 | + ixgbe_reset(adapter); | |
| 7925 | + | |
| 7923 | 7926 | ixgbe_clear_interrupt_scheme(adapter); |
| 7924 | 7927 | |
| 7925 | 7928 | #ifdef CONFIG_IXGBE_DCB |
| @@ -3413,16 +3413,23 @@ static void mvpp2_bm_pool_bufsize_set(struct mvpp2 *priv, · 3412 unmodified lines | ||
| 3413 | 3413 | } |
| 3414 | 3414 | |
| 3415 | 3415 | /* Free all buffers from the pool */ |
| 3416 | −static void mvpp2_bm_bufs_free(struct mvpp2 *priv, struct mvpp2_bm_pool *bm_pool) | |
| 3416 | +static void mvpp2_bm_bufs_free(struct device *dev, struct mvpp2 *priv, | |
| 3417 | + struct mvpp2_bm_pool *bm_pool) | |
| 3417 | 3418 | { |
| 3418 | 3419 | int i; |
| 3419 | 3420 | |
| 3420 | 3421 | for (i = 0; i < bm_pool->buf_num; i++) { |
| 3422 | + dma_addr_t buf_phys_addr; | |
| 3421 | 3423 | u32 vaddr; |
| 3422 | 3424 | |
| 3423 | 3425 | /* Get buffer virtual address (indirect access) */ |
| 3424 | − mvpp2_read(priv, MVPP2_BM_PHY_ALLOC_REG(bm_pool->id)); | |
| 3426 | + buf_phys_addr = mvpp2_read(priv, | |
| 3427 | + MVPP2_BM_PHY_ALLOC_REG(bm_pool->id)); | |
| 3425 | 3428 | vaddr = mvpp2_read(priv, MVPP2_BM_VIRT_ALLOC_REG); |
| 3429 | + | |
| 3430 | + dma_unmap_single(dev, buf_phys_addr, | |
| 3431 | + bm_pool->buf_size, DMA_FROM_DEVICE); | |
| 3432 | + | |
| 3426 | 3433 | if (!vaddr) |
| 3427 | 3434 | break; |
| 3428 | 3435 | dev_kfree_skb_any((struct sk_buff *)vaddr); |
| @@ -3439,7 +3446,7 @@ static int mvpp2_bm_pool_destroy(struct platform_device *pdev, · 10 unmodified lines | ||
| 3439 | 3446 | { |
| 3440 | 3447 | u32 val; |
| 3441 | 3448 | |
| 3442 | − mvpp2_bm_bufs_free(priv, bm_pool); | |
| 3449 | + mvpp2_bm_bufs_free(&pdev->dev, priv, bm_pool); | |
| 3443 | 3450 | if (bm_pool->buf_num) { |
| 3444 | 3451 | WARN(1, "cannot free all buffers in pool %d\n", bm_pool->id); |
| 3445 | 3452 | return 0; |
| @@ -3692,7 +3699,8 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, · 246 unmodified lines | ||
| 3692 | 3699 | MVPP2_BM_LONG_BUF_NUM : |
| 3693 | 3700 | MVPP2_BM_SHORT_BUF_NUM; |
| 3694 | 3701 | else |
| 3695 | − mvpp2_bm_bufs_free(port->priv, new_pool); | |
| 3702 | + mvpp2_bm_bufs_free(port->dev->dev.parent, | |
| 3703 | + port->priv, new_pool); | |
| 3696 | 3704 | |
| 3697 | 3705 | new_pool->pkt_size = pkt_size; |
| 3698 | 3706 | |
| @@ -3756,7 +3764,7 @@ static int mvpp2_bm_update_mtu(struct net_device *dev, int mtu) · 57 unmodified lines | ||
| 3756 | 3764 | int pkt_size = MVPP2_RX_PKT_SIZE(mtu); |
| 3757 | 3765 | |
| 3758 | 3766 | /* Update BM pool with new buffer size */ |
| 3759 | − mvpp2_bm_bufs_free(port->priv, port_pool); | |
| 3767 | + mvpp2_bm_bufs_free(dev->dev.parent, port->priv, port_pool); | |
| 3760 | 3768 | if (port_pool->buf_num) { |
| 3761 | 3769 | WARN(1, "cannot free all buffers in pool %d\n", port_pool->id); |
| 3762 | 3770 | return -EIO; |
| @@ -4401,11 +4409,10 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port, · 638 unmodified lines | ||
| 4401 | 4409 | |
| 4402 | 4410 | mvpp2_txq_inc_get(txq_pcpu); |
| 4403 | 4411 | |
| 4404 | − if (!skb) | |
| 4405 | − continue; | |
| 4406 | − | |
| 4407 | 4412 | dma_unmap_single(port->dev->dev.parent, buf_phys_addr, |
| 4408 | 4413 | skb_headlen(skb), DMA_TO_DEVICE); |
| 4414 | + if (!skb) | |
| 4415 | + continue; | |
| 4409 | 4416 | dev_kfree_skb_any(skb); |
| 4410 | 4417 | } |
| 4411 | 4418 | } |
| @@ -5092,7 +5099,8 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 680 unmodified lines | ||
| 5092 | 5099 | struct mvpp2_rx_queue *rxq) |
| 5093 | 5100 | { |
| 5094 | 5101 | struct net_device *dev = port->dev; |
| 5095 | − int rx_received, rx_filled, i; | |
| 5102 | + int rx_received; | |
| 5103 | + int rx_done = 0; | |
| 5096 | 5104 | u32 rcvd_pkts = 0; |
| 5097 | 5105 | u32 rcvd_bytes = 0; |
| 5098 | 5106 | |
| @@ -5101,17 +5109,18 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 2 unmodified lines | ||
| 5101 | 5109 | if (rx_todo > rx_received) |
| 5102 | 5110 | rx_todo = rx_received; |
| 5103 | 5111 | |
| 5104 | − rx_filled = 0; | |
| 5105 | − for (i = 0; i < rx_todo; i++) { | |
| 5112 | + while (rx_done < rx_todo) { | |
| 5106 | 5113 | struct mvpp2_rx_desc *rx_desc = mvpp2_rxq_next_desc_get(rxq); |
| 5107 | 5114 | struct mvpp2_bm_pool *bm_pool; |
| 5108 | 5115 | struct sk_buff *skb; |
| 5116 | + dma_addr_t phys_addr; | |
| 5109 | 5117 | u32 bm, rx_status; |
| 5110 | 5118 | int pool, rx_bytes, err; |
| 5111 | 5119 | |
| 5112 | − rx_filled++; | |
| 5120 | + rx_done++; | |
| 5113 | 5121 | rx_status = rx_desc->status; |
| 5114 | 5122 | rx_bytes = rx_desc->data_size - MVPP2_MH_SIZE; |
| 5123 | + phys_addr = rx_desc->buf_phys_addr; | |
| 5115 | 5124 | |
| 5116 | 5125 | bm = mvpp2_bm_cookie_build(rx_desc); |
| 5117 | 5126 | pool = mvpp2_bm_cookie_pool_get(bm); |
| @@ -5128,8 +5137,10 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 10 unmodified lines | ||
| 5128 | 5137 | * comprised by the RX descriptor. |
| 5129 | 5138 | */ |
| 5130 | 5139 | if (rx_status & MVPP2_RXD_ERR_SUMMARY) { |
| 5140 | + err_drop_frame: | |
| 5131 | 5141 | dev->stats.rx_errors++; |
| 5132 | 5142 | mvpp2_rx_error(port, rx_desc); |
| 5143 | + /* Return the buffer to the pool */ | |
| 5133 | 5144 | mvpp2_pool_refill(port, bm, rx_desc->buf_phys_addr, |
| 5134 | 5145 | rx_desc->buf_cookie); |
| 5135 | 5146 | continue; |
| @@ -5137,6 +5148,15 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 1 unmodified line | ||
| 5137 | 5148 | |
| 5138 | 5149 | skb = (struct sk_buff *)rx_desc->buf_cookie; |
| 5139 | 5150 | |
| 5151 | + err = mvpp2_rx_refill(port, bm_pool, bm, 0); | |
| 5152 | + if (err) { | |
| 5153 | + netdev_err(port->dev, "failed to refill BM pools\n"); | |
| 5154 | + goto err_drop_frame; | |
| 5155 | + } | |
| 5156 | + | |
| 5157 | + dma_unmap_single(dev->dev.parent, phys_addr, | |
| 5158 | + bm_pool->buf_size, DMA_FROM_DEVICE); | |
| 5159 | + | |
| 5140 | 5160 | rcvd_pkts++; |
| 5141 | 5161 | rcvd_bytes += rx_bytes; |
| 5142 | 5162 | atomic_inc(&bm_pool->in_use); |
| @@ -5147,12 +5167,6 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 4 unmodified lines | ||
| 5147 | 5167 | mvpp2_rx_csum(port, rx_status, skb); |
| 5148 | 5168 | |
| 5149 | 5169 | napi_gro_receive(&port->napi, skb); |
| 5150 | − | |
| 5151 | − err = mvpp2_rx_refill(port, bm_pool, bm, 0); | |
| 5152 | − if (err) { | |
| 5153 | − netdev_err(port->dev, "failed to refill BM pools\n"); | |
| 5154 | − rx_filled--; | |
| 5155 | − } | |
| 5156 | 5170 | } |
| 5157 | 5171 | |
| 5158 | 5172 | if (rcvd_pkts) { |
| @@ -5166,7 +5180,7 @@ static int mvpp2_rx(struct mvpp2_port *port, int rx_todo, · 7 unmodified lines | ||
| 5166 | 5180 | |
| 5167 | 5181 | /* Update Rx queue management counters */ |
| 5168 | 5182 | wmb(); |
| 5169 | − mvpp2_rxq_status_update(port, rxq->id, rx_todo, rx_filled); | |
| 5183 | + mvpp2_rxq_status_update(port, rxq->id, rx_done, rx_done); | |
| 5170 | 5184 | |
| 5171 | 5185 | return rx_todo; |
| 5172 | 5186 | } |
| @@ -242,6 +242,13 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev) · 241 unmodified lines | ||
| 242 | 242 | unsigned long flags; |
| 243 | 243 | u64 ns, zero = 0; |
| 244 | 244 | |
| 245 | + /* mlx4_en_init_timestamp is called for each netdev. | |
| 246 | + * mdev->ptp_clock is common for all ports, skip initialization if | |
| 247 | + * was done for other port. | |
| 248 | + */ | |
| 249 | + if (mdev->ptp_clock) | |
| 250 | + return; | |
| 251 | + | |
| 245 | 252 | rwlock_init(&mdev->clock_lock); |
| 246 | 253 | |
| 247 | 254 | memset(&mdev->cycles, 0, sizeof(mdev->cycles)); |
| @@ -232,9 +232,6 @@ static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr) · 231 unmodified lines | ||
| 232 | 232 | if (mdev->pndev[i]) |
| 233 | 233 | mlx4_en_destroy_netdev(mdev->pndev[i]); |
| 234 | 234 | |
| 235 | − if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) | |
| 236 | − mlx4_en_remove_timestamp(mdev); | |
| 237 | − | |
| 238 | 235 | flush_workqueue(mdev->workqueue); |
| 239 | 236 | destroy_workqueue(mdev->workqueue); |
| 240 | 237 | (void) mlx4_mr_free(dev, &mdev->mr); |
| @@ -320,10 +317,6 @@ static void *mlx4_en_add(struct mlx4_dev *dev) · 79 unmodified lines | ||
| 320 | 317 | mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_ETH) |
| 321 | 318 | mdev->port_cnt++; |
| 322 | 319 | |
| 323 | − /* Initialize time stamp mechanism */ | |
| 324 | − if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) | |
| 325 | − mlx4_en_init_timestamp(mdev); | |
| 326 | − | |
| 327 | 320 | /* Set default number of RX rings*/ |
| 328 | 321 | mlx4_en_set_num_rx_rings(mdev); |
| 329 | 322 | |
| @@ -2072,6 +2072,9 @@ void mlx4_en_destroy_netdev(struct net_device *dev) · 2071 unmodified lines | ||
| 2072 | 2072 | /* flush any pending task for this netdev */ |
| 2073 | 2073 | flush_workqueue(mdev->workqueue); |
| 2074 | 2074 | |
| 2075 | + if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) | |
| 2076 | + mlx4_en_remove_timestamp(mdev); | |
| 2077 | + | |
| 2075 | 2078 | /* Detach the netdev so tasks would not attempt to access it */ |
| 2076 | 2079 | mutex_lock(&mdev->state_lock); |
| 2077 | 2080 | mdev->pndev[priv->port] = NULL; |
| @@ -3058,9 +3061,12 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, · 980 unmodified lines | ||
| 3058 | 3061 | } |
| 3059 | 3062 | queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY); |
| 3060 | 3063 | |
| 3064 | + /* Initialize time stamp mechanism */ | |
| 3061 | 3065 | if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS) |
| 3062 | − queue_delayed_work(mdev->workqueue, &priv->service_task, | |
| 3063 | − SERVICE_TASK_DELAY); | |
| 3066 | + mlx4_en_init_timestamp(mdev); | |
| 3067 | + | |
| 3068 | + queue_delayed_work(mdev->workqueue, &priv->service_task, | |
| 3069 | + SERVICE_TASK_DELAY); | |
| 3064 | 3070 | |
| 3065 | 3071 | mlx4_en_set_stats_bitmap(mdev->dev, &priv->stats_bitmap, |
| 3066 | 3072 | mdev->profile.prof[priv->port].rx_ppp, |
| @@ -4306,9 +4306,10 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, · 4305 unmodified lines | ||
| 4306 | 4306 | return -EOPNOTSUPP; |
| 4307 | 4307 | |
| 4308 | 4308 | ctrl = (struct mlx4_net_trans_rule_hw_ctrl *)inbox->buf; |
| 4309 | − ctrl->port = mlx4_slave_convert_port(dev, slave, ctrl->port); | |
| 4310 | − if (ctrl->port <= 0) | |
| 4309 | + err = mlx4_slave_convert_port(dev, slave, ctrl->port); | |
| 4310 | + if (err <= 0) | |
| 4311 | 4311 | return -EINVAL; |
| 4312 | + ctrl->port = err; | |
| 4312 | 4313 | qpn = be32_to_cpu(ctrl->qpn) & 0xffffff; |
| 4313 | 4314 | err = get_res(dev, slave, qpn, RES_QP, &rqp); |
| 4314 | 4315 | if (err) { |
| @@ -1937,6 +1937,12 @@ static void refill_rx(struct net_device *dev) · 1936 unmodified lines | ||
| 1937 | 1937 | break; /* Better luck next round. */ |
| 1938 | 1938 | np->rx_dma[entry] = pci_map_single(np->pci_dev, |
| 1939 | 1939 | skb->data, buflen, PCI_DMA_FROMDEVICE); |
| 1940 | + if (pci_dma_mapping_error(np->pci_dev, | |
| 1941 | + np->rx_dma[entry])) { | |
| 1942 | + dev_kfree_skb_any(skb); | |
| 1943 | + np->rx_skbuff[entry] = NULL; | |
| 1944 | + break; /* Better luck next round. */ | |
| 1945 | + } | |
| 1940 | 1946 | np->rx_ring[entry].addr = cpu_to_le32(np->rx_dma[entry]); |
| 1941 | 1947 | } |
| 1942 | 1948 | np->rx_ring[entry].cmd_status = cpu_to_le32(np->rx_buf_sz); |
| @@ -2093,6 +2099,12 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev) · 150 unmodified lines | ||
| 2093 | 2099 | np->tx_skbuff[entry] = skb; |
| 2094 | 2100 | np->tx_dma[entry] = pci_map_single(np->pci_dev, |
| 2095 | 2101 | skb->data,skb->len, PCI_DMA_TODEVICE); |
| 2102 | + if (pci_dma_mapping_error(np->pci_dev, np->tx_dma[entry])) { | |
| 2103 | + np->tx_skbuff[entry] = NULL; | |
| 2104 | + dev_kfree_skb_irq(skb); | |
| 2105 | + dev->stats.tx_dropped++; | |
| 2106 | + return NETDEV_TX_OK; | |
| 2107 | + } | |
| 2096 | 2108 | |
| 2097 | 2109 | np->tx_ring[entry].addr = cpu_to_le32(np->tx_dma[entry]); |
| 2098 | 2110 | |
| @@ -299,6 +299,7 @@ struct qed_hwfn { · 298 unmodified lines | ||
| 299 | 299 | |
| 300 | 300 | /* Flag indicating whether interrupts are enabled or not*/ |
| 301 | 301 | bool b_int_enabled; |
| 302 | + bool b_int_requested; | |
| 302 | 303 | |
| 303 | 304 | struct qed_mcp_info *mcp_info; |
| 304 | 305 | |
| @@ -491,6 +492,8 @@ u32 qed_unzip_data(struct qed_hwfn *p_hwfn, · 186 unmodified lines | ||
| 491 | 492 | u32 input_len, u8 *input_buf, |
| 492 | 493 | u32 max_size, u8 *unzip_buf); |
| 493 | 494 | |
| 495 | +int qed_slowpath_irq_req(struct qed_hwfn *hwfn); | |
| 496 | + | |
| 494 | 497 | #define QED_ETH_INTERFACE_VERSION 300 |
| 495 | 498 | |
| 496 | 499 | #endif /* _QED_H */ |
| @@ -1385,52 +1385,63 @@ err0: · 1384 unmodified lines | ||
| 1385 | 1385 | return rc; |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | −static u32 qed_hw_bar_size(struct qed_dev *cdev, | |
| 1389 | − u8 bar_id) | |
| 1388 | +static u32 qed_hw_bar_size(struct qed_hwfn *p_hwfn, | |
| 1389 | + u8 bar_id) | |
| 1390 | 1390 | { |
| 1391 | − u32 size = pci_resource_len(cdev->pdev, (bar_id > 0) ? 2 : 0); | |
| 1391 | + u32 bar_reg = (bar_id == 0 ? PGLUE_B_REG_PF_BAR0_SIZE | |
| 1392 | + : PGLUE_B_REG_PF_BAR1_SIZE); | |
| 1393 | + u32 val = qed_rd(p_hwfn, p_hwfn->p_main_ptt, bar_reg); | |
| 1392 | 1394 | |
| 1393 | − return size / cdev->num_hwfns; | |
| 1395 | + /* Get the BAR size(in KB) from hardware given val */ | |
| 1396 | + return 1 << (val + 15); | |
| 1394 | 1397 | } |
| 1395 | 1398 | |
| 1396 | 1399 | int qed_hw_prepare(struct qed_dev *cdev, |
| 1397 | 1400 | int personality) |
| 1398 | 1401 | { |
| 1399 | − int rc, i; | |
| 1402 | + struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); | |
| 1403 | + int rc; | |
| 1400 | 1404 | |
| 1401 | 1405 | /* Store the precompiled init data ptrs */ |
| 1402 | 1406 | qed_init_iro_array(cdev); |
| 1403 | 1407 | |
| 1404 | 1408 | /* Initialize the first hwfn - will learn number of hwfns */ |
| 1405 | − rc = qed_hw_prepare_single(&cdev->hwfns[0], cdev->regview, | |
| 1409 | + rc = qed_hw_prepare_single(p_hwfn, | |
| 1410 | + cdev->regview, | |
| 1406 | 1411 | cdev->doorbells, personality); |
| 1407 | 1412 | if (rc) |
| 1408 | 1413 | return rc; |
| 1409 | 1414 | |
| 1410 | − personality = cdev->hwfns[0].hw_info.personality; | |
| 1415 | + personality = p_hwfn->hw_info.personality; | |
| 1411 | 1416 | |
| 1412 | 1417 | /* Initialize the rest of the hwfns */ |
| 1413 | − for (i = 1; i < cdev->num_hwfns; i++) { | |
| 1418 | + if (cdev->num_hwfns > 1) { | |
| 1414 | 1419 | void __iomem *p_regview, *p_doorbell; |
| 1420 | + u8 __iomem *addr; | |
| 1421 | + | |
| 1422 | + /* adjust bar offset for second engine */ | |
| 1423 | + addr = cdev->regview + qed_hw_bar_size(p_hwfn, 0) / 2; | |
| 1424 | + p_regview = addr; | |
| 1415 | 1425 | |
| 1416 | − p_regview = cdev->regview + | |
| 1417 | − i * qed_hw_bar_size(cdev, 0); | |
| 1418 | − p_doorbell = cdev->doorbells + | |
| 1419 | − i * qed_hw_bar_size(cdev, 1); | |
| 1420 | − rc = qed_hw_prepare_single(&cdev->hwfns[i], p_regview, | |
| 1426 | + /* adjust doorbell bar offset for second engine */ | |
| 1427 | + addr = cdev->doorbells + qed_hw_bar_size(p_hwfn, 1) / 2; | |
| 1428 | + p_doorbell = addr; | |
| 1429 | + | |
| 1430 | + /* prepare second hw function */ | |
| 1431 | + rc = qed_hw_prepare_single(&cdev->hwfns[1], p_regview, | |
| 1421 | 1432 | p_doorbell, personality); |
| 1433 | + | |
| 1434 | + /* in case of error, need to free the previously | |
| 1435 | + * initiliazed hwfn 0. | |
| 1436 | + */ | |
| 1422 | 1437 | if (rc) { |
| 1423 | − /* Cleanup previously initialized hwfns */ | |
| 1424 | − while (--i >= 0) { | |
| 1425 | − qed_init_free(&cdev->hwfns[i]); | |
| 1426 | − qed_mcp_free(&cdev->hwfns[i]); | |
| 1427 | − qed_hw_hwfn_free(&cdev->hwfns[i]); | |
| 1428 | − } | |
| 1429 | − return rc; | |
| 1438 | + qed_init_free(p_hwfn); | |
| 1439 | + qed_mcp_free(p_hwfn); | |
| 1440 | + qed_hw_hwfn_free(p_hwfn); | |
| 1430 | 1441 | } |
| 1431 | 1442 | } |
| 1432 | 1443 | |
| 1433 | − return 0; | |
| 1444 | + return rc; | |
| 1434 | 1445 | } |
| 1435 | 1446 | |
| 1436 | 1447 | void qed_hw_remove(struct qed_dev *cdev) |
| @@ -783,22 +783,16 @@ void qed_int_igu_enable_int(struct qed_hwfn *p_hwfn, · 782 unmodified lines | ||
| 783 | 783 | qed_wr(p_hwfn, p_ptt, IGU_REG_PF_CONFIGURATION, igu_pf_conf); |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | −void qed_int_igu_enable(struct qed_hwfn *p_hwfn, | |
| 787 | − struct qed_ptt *p_ptt, | |
| 788 | − enum qed_int_mode int_mode) | |
| 786 | +int qed_int_igu_enable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, | |
| 787 | + enum qed_int_mode int_mode) | |
| 789 | 788 | { |
| 790 | − int i; | |
| 791 | − | |
| 792 | − p_hwfn->b_int_enabled = 1; | |
| 789 | + int rc, i; | |
| 793 | 790 | |
| 794 | 791 | /* Mask non-link attentions */ |
| 795 | 792 | for (i = 0; i < 9; i++) |
| 796 | 793 | qed_wr(p_hwfn, p_ptt, |
| 797 | 794 | MISC_REG_AEU_ENABLE1_IGU_OUT_0 + (i << 2), 0); |
| 798 | 795 | |
| 799 | − /* Enable interrupt Generation */ | |
| 800 | − qed_int_igu_enable_int(p_hwfn, p_ptt, int_mode); | |
| 801 | − | |
| 802 | 796 | /* Configure AEU signal change to produce attentions for link */ |
| 803 | 797 | qed_wr(p_hwfn, p_ptt, IGU_REG_LEADING_EDGE_LATCH, 0xfff); |
| 804 | 798 | qed_wr(p_hwfn, p_ptt, IGU_REG_TRAILING_EDGE_LATCH, 0xfff); |
| @@ -808,6 +802,19 @@ void qed_int_igu_enable(struct qed_hwfn *p_hwfn, · 3 unmodified lines | ||
| 808 | 802 | |
| 809 | 803 | /* Unmask AEU signals toward IGU */ |
| 810 | 804 | qed_wr(p_hwfn, p_ptt, MISC_REG_AEU_MASK_ATTN_IGU, 0xff); |
| 805 | + if ((int_mode != QED_INT_MODE_INTA) || IS_LEAD_HWFN(p_hwfn)) { | |
| 806 | + rc = qed_slowpath_irq_req(p_hwfn); | |
| 807 | + if (rc != 0) { | |
| 808 | + DP_NOTICE(p_hwfn, "Slowpath IRQ request failed\n"); | |
| 809 | + return -EINVAL; | |
| 810 | + } | |
| 811 | + p_hwfn->b_int_requested = true; | |
| 812 | + } | |
| 813 | + /* Enable interrupt Generation */ | |
| 814 | + qed_int_igu_enable_int(p_hwfn, p_ptt, int_mode); | |
| 815 | + p_hwfn->b_int_enabled = 1; | |
| 816 | + | |
| 817 | + return rc; | |
| 811 | 818 | } |
| 812 | 819 | |
| 813 | 820 | void qed_int_igu_disable_int(struct qed_hwfn *p_hwfn, |
| @@ -1127,3 +1134,11 @@ int qed_int_get_num_sbs(struct qed_hwfn *p_hwfn, · 313 unmodified lines | ||
| 1127 | 1134 | |
| 1128 | 1135 | return info->igu_sb_cnt; |
| 1129 | 1136 | } |
| 1137 | + | |
| 1138 | +void qed_int_disable_post_isr_release(struct qed_dev *cdev) | |
| 1139 | +{ | |
| 1140 | + int i; | |
| 1141 | + | |
| 1142 | + for_each_hwfn(cdev, i) | |
| 1143 | + cdev->hwfns[i].b_int_requested = false; | |
| 1144 | +} | |
| @@ -169,10 +169,14 @@ int qed_int_get_num_sbs(struct qed_hwfn *p_hwfn, · 168 unmodified lines | ||
| 169 | 169 | int *p_iov_blks); |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | − * @file | |
| 172 | + * @brief qed_int_disable_post_isr_release - performs the cleanup post ISR | |
| 173 | + * release. The API need to be called after releasing all slowpath IRQs | |
| 174 | + * of the device. | |
| 175 | + * | |
| 176 | + * @param cdev | |
| 173 | 177 | * |
| 174 | − * @brief Interrupt handler | |
| 175 | 178 | */ |
| 179 | +void qed_int_disable_post_isr_release(struct qed_dev *cdev); | |
| 176 | 180 | |
| 177 | 181 | #define QED_CAU_DEF_RX_TIMER_RES 0 |
| 178 | 182 | #define QED_CAU_DEF_TX_TIMER_RES 0 |
| @@ -366,10 +370,11 @@ void qed_int_setup(struct qed_hwfn *p_hwfn, · 187 unmodified lines | ||
| 366 | 370 | * @param p_hwfn |
| 367 | 371 | * @param p_ptt |
| 368 | 372 | * @param int_mode |
| 373 | + * | |
| 374 | + * @return int | |
| 369 | 375 | */ |
| 370 | −void qed_int_igu_enable(struct qed_hwfn *p_hwfn, | |
| 371 | − struct qed_ptt *p_ptt, | |
| 372 | − enum qed_int_mode int_mode); | |
| 376 | +int qed_int_igu_enable(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, | |
| 377 | + enum qed_int_mode int_mode); | |
| 373 | 378 | |
| 374 | 379 | /** |
| 375 | 380 | * @brief - Initialize CAU status block entry |
| @@ -476,41 +476,22 @@ static irqreturn_t qed_single_int(int irq, void *dev_instance) · 475 unmodified lines | ||
| 476 | 476 | return rc; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | −static int qed_slowpath_irq_req(struct qed_dev *cdev) | |
| 479 | +int qed_slowpath_irq_req(struct qed_hwfn *hwfn) | |
| 480 | 480 | { |
| 481 | − int i = 0, rc = 0; | |
| 481 | + struct qed_dev *cdev = hwfn->cdev; | |
| 482 | + int rc = 0; | |
| 483 | + u8 id; | |
| 482 | 484 | |
| 483 | 485 | if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) { |
| 484 | − /* Request all the slowpath MSI-X vectors */ | |
| 485 | − for (i = 0; i < cdev->num_hwfns; i++) { | |
| 486 | − snprintf(cdev->hwfns[i].name, NAME_SIZE, | |
| 487 | − "sp-%d-%02x:%02x.%02x", | |
| 488 | − i, cdev->pdev->bus->number, | |
| 489 | − PCI_SLOT(cdev->pdev->devfn), | |
| 490 | − cdev->hwfns[i].abs_pf_id); | |
| 491 | − | |
| 492 | − rc = request_irq(cdev->int_params.msix_table[i].vector, | |
| 493 | − qed_msix_sp_int, 0, | |
| 494 | − cdev->hwfns[i].name, | |
| 495 | − cdev->hwfns[i].sp_dpc); | |
| 496 | − if (rc) | |
| 497 | − break; | |
| 498 | − | |
| 499 | − DP_VERBOSE(&cdev->hwfns[i], | |
| 500 | − (NETIF_MSG_INTR | QED_MSG_SP), | |
| 486 | + id = hwfn->my_id; | |
| 487 | + snprintf(hwfn->name, NAME_SIZE, "sp-%d-%02x:%02x.%02x", | |
| 488 | + id, cdev->pdev->bus->number, | |
| 489 | + PCI_SLOT(cdev->pdev->devfn), hwfn->abs_pf_id); | |
| 490 | + rc = request_irq(cdev->int_params.msix_table[id].vector, | |
| 491 | + qed_msix_sp_int, 0, hwfn->name, hwfn->sp_dpc); | |
| 492 | + if (!rc) | |
| 493 | + DP_VERBOSE(hwfn, (NETIF_MSG_INTR | QED_MSG_SP), | |
| 501 | 494 | "Requested slowpath MSI-X\n"); |
| 502 | − } | |
| 503 | − | |
| 504 | − if (i != cdev->num_hwfns) { | |
| 505 | − /* Free already request MSI-X vectors */ | |
| 506 | − for (i--; i >= 0; i--) { | |
| 507 | − unsigned int vec = | |
| 508 | − cdev->int_params.msix_table[i].vector; | |
| 509 | − synchronize_irq(vec); | |
| 510 | − free_irq(cdev->int_params.msix_table[i].vector, | |
| 511 | − cdev->hwfns[i].sp_dpc); | |
| 512 | − } | |
| 513 | − } | |
| 514 | 495 | } else { |
| 515 | 496 | unsigned long flags = 0; |
| 516 | 497 | |
| @@ -534,13 +515,17 @@ static void qed_slowpath_irq_free(struct qed_dev *cdev) · 17 unmodified lines | ||
| 534 | 515 | |
| 535 | 516 | if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) { |
| 536 | 517 | for_each_hwfn(cdev, i) { |
| 518 | + if (!cdev->hwfns[i].b_int_requested) | |
| 519 | + break; | |
| 537 | 520 | synchronize_irq(cdev->int_params.msix_table[i].vector); |
| 538 | 521 | free_irq(cdev->int_params.msix_table[i].vector, |
| 539 | 522 | cdev->hwfns[i].sp_dpc); |
| 540 | 523 | } |
| 541 | 524 | } else { |
| 542 | − free_irq(cdev->pdev->irq, cdev); | |
| 525 | + if (QED_LEADING_HWFN(cdev)->b_int_requested) | |
| 526 | + free_irq(cdev->pdev->irq, cdev); | |
| 543 | 527 | } |
| 528 | + qed_int_disable_post_isr_release(cdev); | |
| 544 | 529 | } |
| 545 | 530 | |
| 546 | 531 | static int qed_nic_stop(struct qed_dev *cdev) |
| @@ -765,16 +750,11 @@ static int qed_slowpath_start(struct qed_dev *cdev, · 218 unmodified lines | ||
| 765 | 750 | if (rc) |
| 766 | 751 | goto err1; |
| 767 | 752 | |
| 768 | − /* Request the slowpath IRQ */ | |
| 769 | − rc = qed_slowpath_irq_req(cdev); | |
| 770 | − if (rc) | |
| 771 | − goto err2; | |
| 772 | − | |
| 773 | 753 | /* Allocate stream for unzipping */ |
| 774 | 754 | rc = qed_alloc_stream_mem(cdev); |
| 775 | 755 | if (rc) { |
| 776 | 756 | DP_NOTICE(cdev, "Failed to allocate stream memory\n"); |
| 777 | − goto err3; | |
| 757 | + goto err2; | |
| 778 | 758 | } |
| 779 | 759 | |
| 780 | 760 | /* Start the slowpath */ |
| @@ -363,4 +363,8 @@ · 362 unmodified lines | ||
| 363 | 363 | 0x7 << 0) |
| 364 | 364 | #define MCP_REG_NVM_CFG4_FLASH_SIZE_SHIFT \ |
| 365 | 365 | 0 |
| 366 | +#define PGLUE_B_REG_PF_BAR0_SIZE \ | |
| 367 | + 0x2aae60UL | |
| 368 | +#define PGLUE_B_REG_PF_BAR1_SIZE \ | |
| 369 | + 0x2aae64UL | |
| 366 | 370 | #endif |
| @@ -124,8 +124,12 @@ struct qed_spq { · 123 unmodified lines | ||
| 124 | 124 | dma_addr_t p_phys; |
| 125 | 125 | struct qed_spq_entry *p_virt; |
| 126 | 126 | |
| 127 | − /* Used as index for completions (returns on EQ by FW) */ | |
| 128 | − u16 echo_idx; | |
| 127 | +#define SPQ_RING_SIZE \ | |
| 128 | + (CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element)) | |
| 129 | + | |
| 130 | + /* Bitmap for handling out-of-order completions */ | |
| 131 | + DECLARE_BITMAP(p_comp_bitmap, SPQ_RING_SIZE); | |
| 132 | + u8 comp_bitmap_idx; | |
| 129 | 133 | |
| 130 | 134 | /* Statistics */ |
| 131 | 135 | u32 unlimited_pending_count; |
| @@ -112,8 +112,6 @@ static int · 111 unmodified lines | ||
| 112 | 112 | qed_spq_fill_entry(struct qed_hwfn *p_hwfn, |
| 113 | 113 | struct qed_spq_entry *p_ent) |
| 114 | 114 | { |
| 115 | − p_ent->elem.hdr.echo = 0; | |
| 116 | − p_hwfn->p_spq->echo_idx++; | |
| 117 | 115 | p_ent->flags = 0; |
| 118 | 116 | |
| 119 | 117 | switch (p_ent->comp_mode) { |
| @@ -195,10 +193,12 @@ static int qed_spq_hw_post(struct qed_hwfn *p_hwfn, · 75 unmodified lines | ||
| 195 | 193 | struct qed_spq *p_spq, |
| 196 | 194 | struct qed_spq_entry *p_ent) |
| 197 | 195 | { |
| 198 | − struct qed_chain *p_chain = &p_hwfn->p_spq->chain; | |
| 196 | + struct qed_chain *p_chain = &p_hwfn->p_spq->chain; | |
| 197 | + u16 echo = qed_chain_get_prod_idx(p_chain); | |
| 199 | 198 | struct slow_path_element *elem; |
| 200 | 199 | struct core_db_data db; |
| 201 | 200 | |
| 201 | + p_ent->elem.hdr.echo = cpu_to_le16(echo); | |
| 202 | 202 | elem = qed_chain_produce(p_chain); |
| 203 | 203 | if (!elem) { |
| 204 | 204 | DP_NOTICE(p_hwfn, "Failed to produce from SPQ chain\n"); |
| @@ -437,7 +437,9 @@ void qed_spq_setup(struct qed_hwfn *p_hwfn) · 232 unmodified lines | ||
| 437 | 437 | p_spq->comp_count = 0; |
| 438 | 438 | p_spq->comp_sent_count = 0; |
| 439 | 439 | p_spq->unlimited_pending_count = 0; |
| 440 | − p_spq->echo_idx = 0; | |
| 440 | + | |
| 441 | + bitmap_zero(p_spq->p_comp_bitmap, SPQ_RING_SIZE); | |
| 442 | + p_spq->comp_bitmap_idx = 0; | |
| 441 | 443 | |
| 442 | 444 | /* SPQ cid, cannot fail */ |
| 443 | 445 | qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_CORE, &p_spq->cid); |
| @@ -582,26 +584,32 @@ qed_spq_add_entry(struct qed_hwfn *p_hwfn, · 138 unmodified lines | ||
| 582 | 584 | struct qed_spq *p_spq = p_hwfn->p_spq; |
| 583 | 585 | |
| 584 | 586 | if (p_ent->queue == &p_spq->unlimited_pending) { |
| 585 | − struct qed_spq_entry *p_en2; | |
| 586 | 587 | |
| 587 | 588 | if (list_empty(&p_spq->free_pool)) { |
| 588 | 589 | list_add_tail(&p_ent->list, &p_spq->unlimited_pending); |
| 589 | 590 | p_spq->unlimited_pending_count++; |
| 590 | 591 | |
| 591 | 592 | return 0; |
| 592 | − } | |
| 593 | + } else { | |
| 594 | + struct qed_spq_entry *p_en2; | |
| 593 | 595 | |
| 594 | − p_en2 = list_first_entry(&p_spq->free_pool, | |
| 595 | − struct qed_spq_entry, | |
| 596 | − list); | |
| 597 | − list_del(&p_en2->list); | |
| 596 | + p_en2 = list_first_entry(&p_spq->free_pool, | |
| 597 | + struct qed_spq_entry, | |
| 598 | + list); | |
| 599 | + list_del(&p_en2->list); | |
| 600 | + | |
| 601 | + /* Copy the ring element physical pointer to the new | |
| 602 | + * entry, since we are about to override the entire ring | |
| 603 | + * entry and don't want to lose the pointer. | |
| 604 | + */ | |
| 605 | + p_ent->elem.data_ptr = p_en2->elem.data_ptr; | |
| 598 | 606 | |
| 599 | − /* Strcut assignment */ | |
| 600 | − *p_en2 = *p_ent; | |
| 607 | + *p_en2 = *p_ent; | |
| 601 | 608 | |
| 602 | − kfree(p_ent); | |
| 609 | + kfree(p_ent); | |
| 603 | 610 | |
| 604 | − p_ent = p_en2; | |
| 611 | + p_ent = p_en2; | |
| 612 | + } | |
| 605 | 613 | } |
| 606 | 614 | |
| 607 | 615 | /* entry is to be placed in 'pending' queue */ |
| @@ -777,13 +785,38 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn, · 169 unmodified lines | ||
| 777 | 785 | list_for_each_entry_safe(p_ent, tmp, &p_spq->completion_pending, |
| 778 | 786 | list) { |
| 779 | 787 | if (p_ent->elem.hdr.echo == echo) { |
| 788 | + u16 pos = le16_to_cpu(echo) % SPQ_RING_SIZE; | |
| 789 | + | |
| 780 | 790 | list_del(&p_ent->list); |
| 781 | 791 | |
| 782 | − qed_chain_return_produced(&p_spq->chain); | |
| 792 | + /* Avoid overriding of SPQ entries when getting | |
| 793 | + * out-of-order completions, by marking the completions | |
| 794 | + * in a bitmap and increasing the chain consumer only | |
| 795 | + * for the first successive completed entries. | |
| 796 | + */ | |
| 797 | + bitmap_set(p_spq->p_comp_bitmap, pos, SPQ_RING_SIZE); | |
| 798 | + | |
| 799 | + while (test_bit(p_spq->comp_bitmap_idx, | |
| 800 | + p_spq->p_comp_bitmap)) { | |
| 801 | + bitmap_clear(p_spq->p_comp_bitmap, | |
| 802 | + p_spq->comp_bitmap_idx, | |
| 803 | + SPQ_RING_SIZE); | |
| 804 | + p_spq->comp_bitmap_idx++; | |
| 805 | + qed_chain_return_produced(&p_spq->chain); | |
| 806 | + } | |
| 807 | + | |
| 783 | 808 | p_spq->comp_count++; |
| 784 | 809 | found = p_ent; |
| 785 | 810 | break; |
| 786 | 811 | } |
| 812 | + | |
| 813 | + /* This is relatively uncommon - depends on scenarios | |
| 814 | + * which have mutliple per-PF sent ramrods. | |
| 815 | + */ | |
| 816 | + DP_VERBOSE(p_hwfn, QED_MSG_SPQ, | |
| 817 | + "Got completion for echo %04x - doesn't match echo %04x in completion pending list\n", | |
| 818 | + le16_to_cpu(echo), | |
| 819 | + le16_to_cpu(p_ent->elem.hdr.echo)); | |
| 787 | 820 | } |
| 788 | 821 | |
| 789 | 822 | /* Release lock before callback, as callback may post |
| @@ -246,12 +246,13 @@ int qlcnic_83xx_check_vnic_state(struct qlcnic_adapter *adapter) · 245 unmodified lines | ||
| 246 | 246 | u32 state; |
| 247 | 247 | |
| 248 | 248 | state = QLCRDX(ahw, QLC_83XX_VNIC_STATE); |
| 249 | − while (state != QLCNIC_DEV_NPAR_OPER && idc->vnic_wait_limit--) { | |
| 249 | + while (state != QLCNIC_DEV_NPAR_OPER && idc->vnic_wait_limit) { | |
| 250 | + idc->vnic_wait_limit--; | |
| 250 | 251 | msleep(1000); |
| 251 | 252 | state = QLCRDX(ahw, QLC_83XX_VNIC_STATE); |
| 252 | 253 | } |
| 253 | 254 | |
| 254 | − if (!idc->vnic_wait_limit) { | |
| 255 | + if (state != QLCNIC_DEV_NPAR_OPER) { | |
| 255 | 256 | dev_err(&adapter->pdev->dev, |
| 256 | 257 | "vNIC mode not operational, state check timed out.\n"); |
| 257 | 258 | return -EIO; |
| @@ -772,8 +772,10 @@ int qlcnic_82xx_config_intrpt(struct qlcnic_adapter *adapter, u8 op_type) · 771 unmodified lines | ||
| 772 | 772 | int i, err = 0; |
| 773 | 773 | |
| 774 | 774 | for (i = 0; i < ahw->num_msix; i++) { |
| 775 | − qlcnic_alloc_mbx_args(&cmd, adapter, | |
| 776 | − QLCNIC_CMD_MQ_TX_CONFIG_INTR); | |
| 775 | + err = qlcnic_alloc_mbx_args(&cmd, adapter, | |
| 776 | + QLCNIC_CMD_MQ_TX_CONFIG_INTR); | |
| 777 | + if (err) | |
| 778 | + return err; | |
| 777 | 779 | type = op_type ? QLCNIC_INTRPT_ADD : QLCNIC_INTRPT_DEL; |
| 778 | 780 | val = type | (ahw->intr_tbl[i].type << 4); |
| 779 | 781 | if (ahw->intr_tbl[i].type == QLCNIC_INTRPT_MSIX) |
| @@ -4211,8 +4211,9 @@ static int ql_change_rx_buffers(struct ql_adapter *qdev) · 4210 unmodified lines | ||
| 4211 | 4211 | |
| 4212 | 4212 | /* Wait for an outstanding reset to complete. */ |
| 4213 | 4213 | if (!test_bit(QL_ADAPTER_UP, &qdev->flags)) { |
| 4214 | − int i = 3; | |
| 4215 | − while (i-- && !test_bit(QL_ADAPTER_UP, &qdev->flags)) { | |
| 4214 | + int i = 4; | |
| 4215 | + | |
| 4216 | + while (--i && !test_bit(QL_ADAPTER_UP, &qdev->flags)) { | |
| 4216 | 4217 | netif_err(qdev, ifup, qdev->ndev, |
| 4217 | 4218 | "Waiting for adapter UP...\n"); |
| 4218 | 4219 | ssleep(1); |
| @@ -736,9 +736,8 @@ qcaspi_netdev_tx_timeout(struct net_device *dev) · 735 unmodified lines | ||
| 736 | 736 | netdev_info(qca->net_dev, "Transmit timeout at %ld, latency %ld\n", |
| 737 | 737 | jiffies, jiffies - dev->trans_start); |
| 738 | 738 | qca->net_dev->stats.tx_errors++; |
| 739 | − /* wake the queue if there is room */ | |
| 740 | − if (qcaspi_tx_ring_has_space(&qca->txr)) | |
| 741 | − netif_wake_queue(dev); | |
| 739 | + /* Trigger tx queue flush and QCA7000 reset */ | |
| 740 | + qca->sync = QCASPI_SYNC_UNKNOWN; | |
| 742 | 741 | } |
| 743 | 742 | |
| 744 | 743 | static int |
| @@ -905,6 +905,9 @@ static int ravb_phy_init(struct net_device *ndev) · 904 unmodified lines | ||
| 905 | 905 | netdev_info(ndev, "limited PHY to 100Mbit/s\n"); |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | + /* 10BASE is not supported */ | |
| 909 | + phydev->supported &= ~PHY_10BT_FEATURES; | |
| 910 | + | |
| 908 | 911 | netdev_info(ndev, "attached PHY %d (IRQ %d) to driver %s\n", |
| 909 | 912 | phydev->addr, phydev->irq, phydev->drv->name); |
| 910 | 913 | |
| @@ -1037,7 +1040,7 @@ static const char ravb_gstrings_stats[][ETH_GSTRING_LEN] = { · 126 unmodified lines | ||
| 1037 | 1040 | "rx_queue_1_mcast_packets", |
| 1038 | 1041 | "rx_queue_1_errors", |
| 1039 | 1042 | "rx_queue_1_crc_errors", |
| 1040 | − "rx_queue_1_frame_errors_", | |
| 1043 | + "rx_queue_1_frame_errors", | |
| 1041 | 1044 | "rx_queue_1_length_errors", |
| 1042 | 1045 | "rx_queue_1_missed_errors", |
| 1043 | 1046 | "rx_queue_1_over_errors", |
| @@ -52,6 +52,8 @@ · 51 unmodified lines | ||
| 52 | 52 | NETIF_MSG_RX_ERR| \ |
| 53 | 53 | NETIF_MSG_TX_ERR) |
| 54 | 54 | |
| 55 | +#define SH_ETH_OFFSET_INVALID ((u16)~0) | |
| 56 | + | |
| 55 | 57 | #define SH_ETH_OFFSET_DEFAULTS \ |
| 56 | 58 | [0 ... SH_ETH_MAX_REGISTER_OFFSET - 1] = SH_ETH_OFFSET_INVALID |
| 57 | 59 | |
| @@ -404,6 +406,28 @@ static const u16 sh_eth_offset_fast_sh3_sh2[SH_ETH_MAX_REGISTER_OFFSET] = { · 346 unmodified lines | ||
| 404 | 406 | static void sh_eth_rcv_snd_disable(struct net_device *ndev); |
| 405 | 407 | static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev); |
| 406 | 408 | |
| 409 | +static void sh_eth_write(struct net_device *ndev, u32 data, int enum_index) | |
| 410 | +{ | |
| 411 | + struct sh_eth_private *mdp = netdev_priv(ndev); | |
| 412 | + u16 offset = mdp->reg_offset[enum_index]; | |
| 413 | + | |
| 414 | + if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) | |
| 415 | + return; | |
| 416 | + | |
| 417 | + iowrite32(data, mdp->addr + offset); | |
| 418 | +} | |
| 419 | + | |
| 420 | +static u32 sh_eth_read(struct net_device *ndev, int enum_index) | |
| 421 | +{ | |
| 422 | + struct sh_eth_private *mdp = netdev_priv(ndev); | |
| 423 | + u16 offset = mdp->reg_offset[enum_index]; | |
| 424 | + | |
| 425 | + if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) | |
| 426 | + return ~0U; | |
| 427 | + | |
| 428 | + return ioread32(mdp->addr + offset); | |
| 429 | +} | |
| 430 | + | |
| 407 | 431 | static bool sh_eth_is_gether(struct sh_eth_private *mdp) |
| 408 | 432 | { |
| 409 | 433 | return mdp->reg_offset == sh_eth_offset_gigabit; |
| @@ -1143,6 +1167,7 @@ static void sh_eth_ring_format(struct net_device *ndev) · 733 unmodified lines | ||
| 1143 | 1167 | int tx_ringsize = sizeof(*txdesc) * mdp->num_tx_ring; |
| 1144 | 1168 | int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1; |
| 1145 | 1169 | dma_addr_t dma_addr; |
| 1170 | + u32 buf_len; | |
| 1146 | 1171 | |
| 1147 | 1172 | mdp->cur_rx = 0; |
| 1148 | 1173 | mdp->cur_tx = 0; |
| @@ -1163,16 +1188,16 @@ static void sh_eth_ring_format(struct net_device *ndev) · 14 unmodified lines | ||
| 1163 | 1188 | /* RX descriptor */ |
| 1164 | 1189 | rxdesc = &mdp->rx_ring[i]; |
| 1165 | 1190 | /* The size of the buffer is a multiple of 32 bytes. */ |
| 1166 | − rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32); | |
| 1167 | − dma_addr = dma_map_single(&ndev->dev, skb->data, | |
| 1168 | − rxdesc->buffer_length, | |
| 1191 | + buf_len = ALIGN(mdp->rx_buf_sz, 32); | |
| 1192 | + rxdesc->len = cpu_to_edmac(mdp, buf_len << 16); | |
| 1193 | + dma_addr = dma_map_single(&ndev->dev, skb->data, buf_len, | |
| 1169 | 1194 | DMA_FROM_DEVICE); |
| 1170 | 1195 | if (dma_mapping_error(&ndev->dev, dma_addr)) { |
| 1171 | 1196 | kfree_skb(skb); |
| 1172 | 1197 | break; |
| 1173 | 1198 | } |
| 1174 | 1199 | mdp->rx_skbuff[i] = skb; |
| 1175 | − rxdesc->addr = dma_addr; | |
| 1200 | + rxdesc->addr = cpu_to_edmac(mdp, dma_addr); | |
| 1176 | 1201 | rxdesc->status = cpu_to_edmac(mdp, RD_RACT | RD_RFP); |
| 1177 | 1202 | |
| 1178 | 1203 | /* Rx descriptor address set */ |
| @@ -1196,7 +1221,7 @@ static void sh_eth_ring_format(struct net_device *ndev) · 17 unmodified lines | ||
| 1196 | 1221 | mdp->tx_skbuff[i] = NULL; |
| 1197 | 1222 | txdesc = &mdp->tx_ring[i]; |
| 1198 | 1223 | txdesc->status = cpu_to_edmac(mdp, TD_TFP); |
| 1199 | − txdesc->buffer_length = 0; | |
| 1224 | + txdesc->len = cpu_to_edmac(mdp, 0); | |
| 1200 | 1225 | if (i == 0) { |
| 1201 | 1226 | /* Tx descriptor address set */ |
| 1202 | 1227 | sh_eth_write(ndev, mdp->tx_desc_dma, TDLAR); |
| @@ -1403,8 +1428,10 @@ static int sh_eth_txfree(struct net_device *ndev) · 200 unmodified lines | ||
| 1403 | 1428 | entry, edmac_to_cpu(mdp, txdesc->status)); |
| 1404 | 1429 | /* Free the original skb. */ |
| 1405 | 1430 | if (mdp->tx_skbuff[entry]) { |
| 1406 | − dma_unmap_single(&ndev->dev, txdesc->addr, | |
| 1407 | − txdesc->buffer_length, DMA_TO_DEVICE); | |
| 1431 | + dma_unmap_single(&ndev->dev, | |
| 1432 | + edmac_to_cpu(mdp, txdesc->addr), | |
| 1433 | + edmac_to_cpu(mdp, txdesc->len) >> 16, | |
| 1434 | + DMA_TO_DEVICE); | |
| 1408 | 1435 | dev_kfree_skb_irq(mdp->tx_skbuff[entry]); |
| 1409 | 1436 | mdp->tx_skbuff[entry] = NULL; |
| 1410 | 1437 | free_num++; |
| @@ -1414,7 +1441,7 @@ static int sh_eth_txfree(struct net_device *ndev) · 3 unmodified lines | ||
| 1414 | 1441 | txdesc->status |= cpu_to_edmac(mdp, TD_TDLE); |
| 1415 | 1442 | |
| 1416 | 1443 | ndev->stats.tx_packets++; |
| 1417 | − ndev->stats.tx_bytes += txdesc->buffer_length; | |
| 1444 | + ndev->stats.tx_bytes += edmac_to_cpu(mdp, txdesc->len) >> 16; | |
| 1418 | 1445 | } |
| 1419 | 1446 | return free_num; |
| 1420 | 1447 | } |
| @@ -1433,6 +1460,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) · 12 unmodified lines | ||
| 1433 | 1460 | u32 desc_status; |
| 1434 | 1461 | int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1; |
| 1435 | 1462 | dma_addr_t dma_addr; |
| 1463 | + u32 buf_len; | |
| 1436 | 1464 | |
| 1437 | 1465 | boguscnt = min(boguscnt, *quota); |
| 1438 | 1466 | limit = boguscnt; |
| @@ -1441,7 +1469,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) · 2 unmodified lines | ||
| 1441 | 1469 | /* RACT bit must be checked before all the following reads */ |
| 1442 | 1470 | dma_rmb(); |
| 1443 | 1471 | desc_status = edmac_to_cpu(mdp, rxdesc->status); |
| 1444 | − pkt_len = rxdesc->frame_length; | |
| 1472 | + pkt_len = edmac_to_cpu(mdp, rxdesc->len) & RD_RFL; | |
| 1445 | 1473 | |
| 1446 | 1474 | if (--boguscnt < 0) |
| 1447 | 1475 | break; |
| @@ -1462,6 +1490,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) · 14 unmodified lines | ||
| 1462 | 1490 | if (mdp->cd->shift_rd0) |
| 1463 | 1491 | desc_status >>= 16; |
| 1464 | 1492 | |
| 1493 | + skb = mdp->rx_skbuff[entry]; | |
| 1465 | 1494 | if (desc_status & (RD_RFS1 | RD_RFS2 | RD_RFS3 | RD_RFS4 | |
| 1466 | 1495 | RD_RFS5 | RD_RFS6 | RD_RFS10)) { |
| 1467 | 1496 | ndev->stats.rx_errors++; |
| @@ -1477,16 +1506,16 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) · 9 unmodified lines | ||
| 1477 | 1506 | ndev->stats.rx_missed_errors++; |
| 1478 | 1507 | if (desc_status & RD_RFS10) |
| 1479 | 1508 | ndev->stats.rx_over_errors++; |
| 1480 | − } else { | |
| 1509 | + } else if (skb) { | |
| 1510 | + dma_addr = edmac_to_cpu(mdp, rxdesc->addr); | |
| 1481 | 1511 | if (!mdp->cd->hw_swap) |
| 1482 | 1512 | sh_eth_soft_swap( |
| 1483 | − phys_to_virt(ALIGN(rxdesc->addr, 4)), | |
| 1513 | + phys_to_virt(ALIGN(dma_addr, 4)), | |
| 1484 | 1514 | pkt_len + 2); |
| 1485 | − skb = mdp->rx_skbuff[entry]; | |
| 1486 | 1515 | mdp->rx_skbuff[entry] = NULL; |
| 1487 | 1516 | if (mdp->cd->rpadir) |
| 1488 | 1517 | skb_reserve(skb, NET_IP_ALIGN); |
| 1489 | − dma_unmap_single(&ndev->dev, rxdesc->addr, | |
| 1518 | + dma_unmap_single(&ndev->dev, dma_addr, | |
| 1490 | 1519 | ALIGN(mdp->rx_buf_sz, 32), |
| 1491 | 1520 | DMA_FROM_DEVICE); |
| 1492 | 1521 | skb_put(skb, pkt_len); |
| @@ -1506,7 +1535,8 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) · 13 unmodified lines | ||
| 1506 | 1535 | entry = mdp->dirty_rx % mdp->num_rx_ring; |
| 1507 | 1536 | rxdesc = &mdp->rx_ring[entry]; |
| 1508 | 1537 | /* The size of the buffer is 32 byte boundary. */ |
| 1509 | − rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32); | |
| 1538 | + buf_len = ALIGN(mdp->rx_buf_sz, 32); | |
| 1539 | + rxdesc->len = cpu_to_edmac(mdp, buf_len << 16); | |
| 1510 | 1540 | |
| 1511 | 1541 | if (mdp->rx_skbuff[entry] == NULL) { |
| 1512 | 1542 | skb = netdev_alloc_skb(ndev, skbuff_size); |
| @@ -1514,8 +1544,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) · 1 unmodified line | ||
| 1514 | 1544 | break; /* Better luck next round. */ |
| 1515 | 1545 | sh_eth_set_receive_align(skb); |
| 1516 | 1546 | dma_addr = dma_map_single(&ndev->dev, skb->data, |
| 1517 | − rxdesc->buffer_length, | |
| 1518 | − DMA_FROM_DEVICE); | |
| 1547 | + buf_len, DMA_FROM_DEVICE); | |
| 1519 | 1548 | if (dma_mapping_error(&ndev->dev, dma_addr)) { |
| 1520 | 1549 | kfree_skb(skb); |
| 1521 | 1550 | break; |
| @@ -1523,7 +1552,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota) · 1 unmodified line | ||
| 1523 | 1552 | mdp->rx_skbuff[entry] = skb; |
| 1524 | 1553 | |
| 1525 | 1554 | skb_checksum_none_assert(skb); |
| 1526 | − rxdesc->addr = dma_addr; | |
| 1555 | + rxdesc->addr = cpu_to_edmac(mdp, dma_addr); | |
| 1527 | 1556 | } |
| 1528 | 1557 | dma_wmb(); /* RACT bit must be set after all the above writes */ |
| 1529 | 1558 | if (entry >= mdp->num_rx_ring - 1) |
| @@ -2331,8 +2360,8 @@ static void sh_eth_tx_timeout(struct net_device *ndev) · 801 unmodified lines | ||
| 2331 | 2360 | /* Free all the skbuffs in the Rx queue. */ |
| 2332 | 2361 | for (i = 0; i < mdp->num_rx_ring; i++) { |
| 2333 | 2362 | rxdesc = &mdp->rx_ring[i]; |
| 2334 | − rxdesc->status = 0; | |
| 2335 | − rxdesc->addr = 0xBADF00D0; | |
| 2363 | + rxdesc->status = cpu_to_edmac(mdp, 0); | |
| 2364 | + rxdesc->addr = cpu_to_edmac(mdp, 0xBADF00D0); | |
| 2336 | 2365 | dev_kfree_skb(mdp->rx_skbuff[i]); |
| 2337 | 2366 | mdp->rx_skbuff[i] = NULL; |
| 2338 | 2367 | } |
| @@ -2350,6 +2379,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) · 11 unmodified lines | ||
| 2350 | 2379 | { |
| 2351 | 2380 | struct sh_eth_private *mdp = netdev_priv(ndev); |
| 2352 | 2381 | struct sh_eth_txdesc *txdesc; |
| 2382 | + dma_addr_t dma_addr; | |
| 2353 | 2383 | u32 entry; |
| 2354 | 2384 | unsigned long flags; |
| 2355 | 2385 | |
| @@ -2372,15 +2402,15 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) · 16 unmodified lines | ||
| 2372 | 2402 | txdesc = &mdp->tx_ring[entry]; |
| 2373 | 2403 | /* soft swap. */ |
| 2374 | 2404 | if (!mdp->cd->hw_swap) |
| 2375 | − sh_eth_soft_swap(phys_to_virt(ALIGN(txdesc->addr, 4)), | |
| 2376 | − skb->len + 2); | |
| 2377 | − txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len, | |
| 2378 | − DMA_TO_DEVICE); | |
| 2379 | − if (dma_mapping_error(&ndev->dev, txdesc->addr)) { | |
| 2405 | + sh_eth_soft_swap(PTR_ALIGN(skb->data, 4), skb->len + 2); | |
| 2406 | + dma_addr = dma_map_single(&ndev->dev, skb->data, skb->len, | |
| 2407 | + DMA_TO_DEVICE); | |
| 2408 | + if (dma_mapping_error(&ndev->dev, dma_addr)) { | |
| 2380 | 2409 | kfree_skb(skb); |
| 2381 | 2410 | return NETDEV_TX_OK; |
| 2382 | 2411 | } |
| 2383 | − txdesc->buffer_length = skb->len; | |
| 2412 | + txdesc->addr = cpu_to_edmac(mdp, dma_addr); | |
| 2413 | + txdesc->len = cpu_to_edmac(mdp, skb->len << 16); | |
| 2384 | 2414 | |
| 2385 | 2415 | dma_wmb(); /* TACT bit must be set after all the above writes */ |
| 2386 | 2416 | if (entry >= mdp->num_tx_ring - 1) |
| @@ -283,7 +283,7 @@ enum DMAC_IM_BIT { · 282 unmodified lines | ||
| 283 | 283 | DMAC_M_RINT1 = 0x00000001, |
| 284 | 284 | }; |
| 285 | 285 | |
| 286 | −/* Receive descriptor bit */ | |
| 286 | +/* Receive descriptor 0 bits */ | |
| 287 | 287 | enum RD_STS_BIT { |
| 288 | 288 | RD_RACT = 0x80000000, RD_RDLE = 0x40000000, |
| 289 | 289 | RD_RFP1 = 0x20000000, RD_RFP0 = 0x10000000, |
| @@ -298,6 +298,12 @@ enum RD_STS_BIT { · 8 unmodified lines | ||
| 298 | 298 | #define RDFEND RD_RFP0 |
| 299 | 299 | #define RD_RFP (RD_RFP1|RD_RFP0) |
| 300 | 300 | |
| 301 | +/* Receive descriptor 1 bits */ | |
| 302 | +enum RD_LEN_BIT { | |
| 303 | + RD_RFL = 0x0000ffff, /* receive frame length */ | |
| 304 | + RD_RBL = 0xffff0000, /* receive buffer length */ | |
| 305 | +}; | |
| 306 | + | |
| 301 | 307 | /* FCFTR */ |
| 302 | 308 | enum FCFTR_BIT { |
| 303 | 309 | FCFTR_RFF2 = 0x00040000, FCFTR_RFF1 = 0x00020000, |
| @@ -307,7 +313,7 @@ enum FCFTR_BIT { · 3 unmodified lines | ||
| 307 | 313 | #define DEFAULT_FIFO_F_D_RFF (FCFTR_RFF2 | FCFTR_RFF1 | FCFTR_RFF0) |
| 308 | 314 | #define DEFAULT_FIFO_F_D_RFD (FCFTR_RFD2 | FCFTR_RFD1 | FCFTR_RFD0) |
| 309 | 315 | |
| 310 | −/* Transmit descriptor bit */ | |
| 316 | +/* Transmit descriptor 0 bits */ | |
| 311 | 317 | enum TD_STS_BIT { |
| 312 | 318 | TD_TACT = 0x80000000, TD_TDLE = 0x40000000, |
| 313 | 319 | TD_TFP1 = 0x20000000, TD_TFP0 = 0x10000000, |
| @@ -317,6 +323,11 @@ enum TD_STS_BIT { · 3 unmodified lines | ||
| 317 | 323 | #define TDFEND TD_TFP0 |
| 318 | 324 | #define TD_TFP (TD_TFP1|TD_TFP0) |
| 319 | 325 | |
| 326 | +/* Transmit descriptor 1 bits */ | |
| 327 | +enum TD_LEN_BIT { | |
| 328 | + TD_TBL = 0xffff0000, /* transmit buffer length */ | |
| 329 | +}; | |
| 330 | + | |
| 320 | 331 | /* RMCR */ |
| 321 | 332 | enum RMCR_BIT { |
| 322 | 333 | RMCR_RNC = 0x00000001, |
| @@ -425,15 +436,9 @@ enum TSU_FWSLC_BIT { · 102 unmodified lines | ||
| 425 | 436 | */ |
| 426 | 437 | struct sh_eth_txdesc { |
| 427 | 438 | u32 status; /* TD0 */ |
| 428 | −#if defined(__LITTLE_ENDIAN) | |
| 429 | − u16 pad0; /* TD1 */ | |
| 430 | − u16 buffer_length; /* TD1 */ | |
| 431 | −#else | |
| 432 | − u16 buffer_length; /* TD1 */ | |
| 433 | − u16 pad0; /* TD1 */ | |
| 434 | −#endif | |
| 439 | + u32 len; /* TD1 */ | |
| 435 | 440 | u32 addr; /* TD2 */ |
| 436 | − u32 pad1; /* padding data */ | |
| 441 | + u32 pad0; /* padding data */ | |
| 437 | 442 | } __aligned(2) __packed; |
| 438 | 443 | |
| 439 | 444 | /* The sh ether Rx buffer descriptors. |
| @@ -441,13 +446,7 @@ struct sh_eth_txdesc { · 1 unmodified line | ||
| 441 | 446 | */ |
| 442 | 447 | struct sh_eth_rxdesc { |
| 443 | 448 | u32 status; /* RD0 */ |
| 444 | −#if defined(__LITTLE_ENDIAN) | |
| 445 | − u16 frame_length; /* RD1 */ | |
| 446 | − u16 buffer_length; /* RD1 */ | |
| 447 | −#else | |
| 448 | − u16 buffer_length; /* RD1 */ | |
| 449 | − u16 frame_length; /* RD1 */ | |
| 450 | −#endif | |
| 449 | + u32 len; /* RD1 */ | |
| 451 | 450 | u32 addr; /* RD2 */ |
| 452 | 451 | u32 pad0; /* padding data */ |
| 453 | 452 | } __aligned(2) __packed; |
| @@ -546,31 +545,6 @@ static inline void sh_eth_soft_swap(char *src, int len) · 92 unmodified lines | ||
| 546 | 545 | #endif |
| 547 | 546 | } |
| 548 | 547 | |
| 549 | −#define SH_ETH_OFFSET_INVALID ((u16) ~0) | |
| 550 | − | |
| 551 | −static inline void sh_eth_write(struct net_device *ndev, u32 data, | |
| 552 | − int enum_index) | |
| 553 | −{ | |
| 554 | − struct sh_eth_private *mdp = netdev_priv(ndev); | |
| 555 | − u16 offset = mdp->reg_offset[enum_index]; | |
| 556 | − | |
| 557 | − if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) | |
| 558 | − return; | |
| 559 | − | |
| 560 | − iowrite32(data, mdp->addr + offset); | |
| 561 | −} | |
| 562 | − | |
| 563 | −static inline u32 sh_eth_read(struct net_device *ndev, int enum_index) | |
| 564 | −{ | |
| 565 | − struct sh_eth_private *mdp = netdev_priv(ndev); | |
| 566 | − u16 offset = mdp->reg_offset[enum_index]; | |
| 567 | − | |
| 568 | − if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) | |
| 569 | − return ~0U; | |
| 570 | − | |
| 571 | − return ioread32(mdp->addr + offset); | |
| 572 | −} | |
| 573 | − | |
| 574 | 548 | static inline void *sh_eth_tsu_get_offset(struct sh_eth_private *mdp, |
| 575 | 549 | int enum_index) |
| 576 | 550 | { |
| @@ -3299,7 +3299,8 @@ static int efx_ef10_filter_remove_internal(struct efx_nic *efx, · 3298 unmodified lines | ||
| 3299 | 3299 | |
| 3300 | 3300 | new_spec.priority = EFX_FILTER_PRI_AUTO; |
| 3301 | 3301 | new_spec.flags = (EFX_FILTER_FLAG_RX | |
| 3302 | − EFX_FILTER_FLAG_RX_RSS); | |
| 3302 | + (efx_rss_enabled(efx) ? | |
| 3303 | + EFX_FILTER_FLAG_RX_RSS : 0)); | |
| 3303 | 3304 | new_spec.dmaq_id = 0; |
| 3304 | 3305 | new_spec.rss_context = EFX_FILTER_RSS_CONTEXT_DEFAULT; |
| 3305 | 3306 | rc = efx_ef10_filter_push(efx, &new_spec, |
| @@ -3921,6 +3922,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx, · 615 unmodified lines | ||
| 3921 | 3922 | { |
| 3922 | 3923 | struct efx_ef10_filter_table *table = efx->filter_state; |
| 3923 | 3924 | struct efx_ef10_dev_addr *addr_list; |
| 3925 | + enum efx_filter_flags filter_flags; | |
| 3924 | 3926 | struct efx_filter_spec spec; |
| 3925 | 3927 | u8 baddr[ETH_ALEN]; |
| 3926 | 3928 | unsigned int i, j; |
| @@ -3935,11 +3937,11 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx, · 8 unmodified lines | ||
| 3935 | 3937 | addr_count = table->dev_uc_count; |
| 3936 | 3938 | } |
| 3937 | 3939 | |
| 3940 | + filter_flags = efx_rss_enabled(efx) ? EFX_FILTER_FLAG_RX_RSS : 0; | |
| 3941 | + | |
| 3938 | 3942 | /* Insert/renew filters */ |
| 3939 | 3943 | for (i = 0; i < addr_count; i++) { |
| 3940 | − efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, | |
| 3941 | − EFX_FILTER_FLAG_RX_RSS, | |
| 3942 | − 0); | |
| 3944 | + efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0); | |
| 3943 | 3945 | efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, |
| 3944 | 3946 | addr_list[i].addr); |
| 3945 | 3947 | rc = efx_ef10_filter_insert(efx, &spec, true); |
| @@ -3968,9 +3970,7 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx, · 22 unmodified lines | ||
| 3968 | 3970 | |
| 3969 | 3971 | if (multicast && rollback) { |
| 3970 | 3972 | /* Also need an Ethernet broadcast filter */ |
| 3971 | − efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, | |
| 3972 | − EFX_FILTER_FLAG_RX_RSS, | |
| 3973 | − 0); | |
| 3973 | + efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0); | |
| 3974 | 3974 | eth_broadcast_addr(baddr); |
| 3975 | 3975 | efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, baddr); |
| 3976 | 3976 | rc = efx_ef10_filter_insert(efx, &spec, true); |
| @@ -4000,13 +4000,14 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast, · 23 unmodified lines | ||
| 4000 | 4000 | { |
| 4001 | 4001 | struct efx_ef10_filter_table *table = efx->filter_state; |
| 4002 | 4002 | struct efx_ef10_nic_data *nic_data = efx->nic_data; |
| 4003 | + enum efx_filter_flags filter_flags; | |
| 4003 | 4004 | struct efx_filter_spec spec; |
| 4004 | 4005 | u8 baddr[ETH_ALEN]; |
| 4005 | 4006 | int rc; |
| 4006 | 4007 | |
| 4007 | − efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, | |
| 4008 | − EFX_FILTER_FLAG_RX_RSS, | |
| 4009 | − 0); | |
| 4008 | + filter_flags = efx_rss_enabled(efx) ? EFX_FILTER_FLAG_RX_RSS : 0; | |
| 4009 | + | |
| 4010 | + efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, filter_flags, 0); | |
| 4010 | 4011 | |
| 4011 | 4012 | if (multicast) |
| 4012 | 4013 | efx_filter_set_mc_def(&spec); |
| @@ -4023,8 +4024,7 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast, · 10 unmodified lines | ||
| 4023 | 4024 | if (!nic_data->workaround_26807) { |
| 4024 | 4025 | /* Also need an Ethernet broadcast filter */ |
| 4025 | 4026 | efx_filter_init_rx(&spec, EFX_FILTER_PRI_AUTO, |
| 4026 | − EFX_FILTER_FLAG_RX_RSS, | |
| 4027 | − 0); | |
| 4027 | + filter_flags, 0); | |
| 4028 | 4028 | eth_broadcast_addr(baddr); |
| 4029 | 4029 | efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, |
| 4030 | 4030 | baddr); |
| @@ -76,6 +76,11 @@ void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue); · 75 unmodified lines | ||
| 76 | 76 | #define EFX_TXQ_MAX_ENT(efx) (EFX_WORKAROUND_35388(efx) ? \ |
| 77 | 77 | EFX_MAX_DMAQ_SIZE / 2 : EFX_MAX_DMAQ_SIZE) |
| 78 | 78 | |
| 79 | +static inline bool efx_rss_enabled(struct efx_nic *efx) | |
| 80 | +{ | |
| 81 | + return efx->rss_spread > 1; | |
| 82 | +} | |
| 83 | + | |
| 79 | 84 | /* Filters */ |
| 80 | 85 | |
| 81 | 86 | void efx_mac_reconfigure(struct efx_nic *efx); |
| @@ -2242,7 +2242,7 @@ efx_farch_filter_init_rx_auto(struct efx_nic *efx, · 2241 unmodified lines | ||
| 2242 | 2242 | */ |
| 2243 | 2243 | spec->priority = EFX_FILTER_PRI_AUTO; |
| 2244 | 2244 | spec->flags = (EFX_FILTER_FLAG_RX | |
| 2245 | − (efx->n_rx_channels > 1 ? EFX_FILTER_FLAG_RX_RSS : 0) | | |
| 2245 | + (efx_rss_enabled(efx) ? EFX_FILTER_FLAG_RX_RSS : 0) | | |
| 2246 | 2246 | (efx->rx_scatter ? EFX_FILTER_FLAG_RX_SCATTER : 0)); |
| 2247 | 2247 | spec->dmaq_id = 0; |
| 2248 | 2248 | } |
| @@ -418,7 +418,7 @@ static void txc_reset_logic_mmd(struct efx_nic *efx, int mmd) · 417 unmodified lines | ||
| 418 | 418 | |
| 419 | 419 | val |= (1 << TXC_GLCMD_LMTSWRST_LBN); |
| 420 | 420 | efx_mdio_write(efx, mmd, TXC_GLRGS_GLCMD, val); |
| 421 | − while (tries--) { | |
| 421 | + while (--tries) { | |
| 422 | 422 | val = efx_mdio_read(efx, mmd, TXC_GLRGS_GLCMD); |
| 423 | 423 | if (!(val & (1 << TXC_GLCMD_LMTSWRST_LBN))) |
| 424 | 424 | break; |
| @@ -153,7 +153,11 @@ static int sun7i_gmac_probe(struct platform_device *pdev) · 152 unmodified lines | ||
| 153 | 153 | if (ret) |
| 154 | 154 | return ret; |
| 155 | 155 | |
| 156 | − return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 156 | + ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); | |
| 157 | + if (ret) | |
| 158 | + sun7i_gmac_exit(pdev, plat_dat->bsp_priv); | |
| 159 | + | |
| 160 | + return ret; | |
| 157 | 161 | } |
| 158 | 162 | |
| 159 | 163 | static const struct of_device_id sun7i_dwmac_match[] = { |
| @@ -3046,8 +3046,6 @@ int stmmac_suspend(struct net_device *ndev) · 3045 unmodified lines | ||
| 3046 | 3046 | priv->hw->dma->stop_tx(priv->ioaddr); |
| 3047 | 3047 | priv->hw->dma->stop_rx(priv->ioaddr); |
| 3048 | 3048 | |
| 3049 | − stmmac_clear_descriptors(priv); | |
| 3050 | − | |
| 3051 | 3049 | /* Enable Power down mode by programming the PMT regs */ |
| 3052 | 3050 | if (device_may_wakeup(priv->device)) { |
| 3053 | 3051 | priv->hw->mac->pmt(priv->hw, priv->wolopts); |
| @@ -3105,7 +3103,12 @@ int stmmac_resume(struct net_device *ndev) · 51 unmodified lines | ||
| 3105 | 3103 | |
| 3106 | 3104 | netif_device_attach(ndev); |
| 3107 | 3105 | |
| 3108 | − init_dma_desc_rings(ndev, GFP_ATOMIC); | |
| 3106 | + priv->cur_rx = 0; | |
| 3107 | + priv->dirty_rx = 0; | |
| 3108 | + priv->dirty_tx = 0; | |
| 3109 | + priv->cur_tx = 0; | |
| 3110 | + stmmac_clear_descriptors(priv); | |
| 3111 | + | |
| 3109 | 3112 | stmmac_hw_setup(ndev, false); |
| 3110 | 3113 | stmmac_init_tx_coalesce(priv); |
| 3111 | 3114 | stmmac_set_rx_mode(ndev); |
| @@ -2026,45 +2026,54 @@ static int cpsw_probe_dt(struct cpsw_priv *priv, · 2025 unmodified lines | ||
| 2026 | 2026 | for_each_child_of_node(node, slave_node) { |
| 2027 | 2027 | struct cpsw_slave_data *slave_data = data->slave_data + i; |
| 2028 | 2028 | const void *mac_addr = NULL; |
| 2029 | − u32 phyid; | |
| 2030 | 2029 | int lenp; |
| 2031 | 2030 | const __be32 *parp; |
| 2032 | − struct device_node *mdio_node; | |
| 2033 | − struct platform_device *mdio; | |
| 2034 | 2031 | |
| 2035 | 2032 | /* This is no slave child node, continue */ |
| 2036 | 2033 | if (strcmp(slave_node->name, "slave")) |
| 2037 | 2034 | continue; |
| 2038 | 2035 | |
| 2039 | 2036 | priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0); |
| 2037 | + parp = of_get_property(slave_node, "phy_id", &lenp); | |
| 2040 | 2038 | if (of_phy_is_fixed_link(slave_node)) { |
| 2041 | − struct phy_device *pd; | |
| 2039 | + struct device_node *phy_node; | |
| 2040 | + struct phy_device *phy_dev; | |
| 2042 | 2041 | |
| 2042 | + /* In the case of a fixed PHY, the DT node associated | |
| 2043 | + * to the PHY is the Ethernet MAC DT node. | |
| 2044 | + */ | |
| 2043 | 2045 | ret = of_phy_register_fixed_link(slave_node); |
| 2044 | 2046 | if (ret) |
| 2045 | 2047 | return ret; |
| 2046 | − pd = of_phy_find_device(slave_node); | |
| 2047 | − if (!pd) | |
| 2048 | + phy_node = of_node_get(slave_node); | |
| 2049 | + phy_dev = of_phy_find_device(phy_node); | |
| 2050 | + if (!phy_dev) | |
| 2048 | 2051 | return -ENODEV; |
| 2049 | 2052 | snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), |
| 2050 | − PHY_ID_FMT, pd->bus->id, pd->phy_id); | |
| 2051 | − goto no_phy_slave; | |
| 2052 | − } | |
| 2053 | − parp = of_get_property(slave_node, "phy_id", &lenp); | |
| 2054 | − if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { | |
| 2055 | − dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i); | |
| 2053 | + PHY_ID_FMT, phy_dev->bus->id, phy_dev->addr); | |
| 2054 | + } else if (parp) { | |
| 2055 | + u32 phyid; | |
| 2056 | + struct device_node *mdio_node; | |
| 2057 | + struct platform_device *mdio; | |
| 2058 | + | |
| 2059 | + if (lenp != (sizeof(__be32) * 2)) { | |
| 2060 | + dev_err(&pdev->dev, "Invalid slave[%d] phy_id property\n", i); | |
| 2061 | + goto no_phy_slave; | |
| 2062 | + } | |
| 2063 | + mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); | |
| 2064 | + phyid = be32_to_cpup(parp+1); | |
| 2065 | + mdio = of_find_device_by_node(mdio_node); | |
| 2066 | + of_node_put(mdio_node); | |
| 2067 | + if (!mdio) { | |
| 2068 | + dev_err(&pdev->dev, "Missing mdio platform device\n"); | |
| 2069 | + return -EINVAL; | |
| 2070 | + } | |
| 2071 | + snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), | |
| 2072 | + PHY_ID_FMT, mdio->name, phyid); | |
| 2073 | + } else { | |
| 2074 | + dev_err(&pdev->dev, "No slave[%d] phy_id or fixed-link property\n", i); | |
| 2056 | 2075 | goto no_phy_slave; |
| 2057 | 2076 | } |
| 2058 | − mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); | |
| 2059 | − phyid = be32_to_cpup(parp+1); | |
| 2060 | − mdio = of_find_device_by_node(mdio_node); | |
| 2061 | − of_node_put(mdio_node); | |
| 2062 | − if (!mdio) { | |
| 2063 | − dev_err(&pdev->dev, "Missing mdio platform device\n"); | |
| 2064 | − return -EINVAL; | |
| 2065 | − } | |
| 2066 | − snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), | |
| 2067 | − PHY_ID_FMT, mdio->name, phyid); | |
| 2068 | 2077 | slave_data->phy_if = of_get_phy_mode(slave_node); |
| 2069 | 2078 | if (slave_data->phy_if < 0) { |
| 2070 | 2079 | dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n", |
| @@ -2418,7 +2427,7 @@ static int cpsw_probe(struct platform_device *pdev) · 347 unmodified lines | ||
| 2418 | 2427 | ndev->irq = platform_get_irq(pdev, 1); |
| 2419 | 2428 | if (ndev->irq < 0) { |
| 2420 | 2429 | dev_err(priv->dev, "error getting irq resource\n"); |
| 2421 | − ret = -ENOENT; | |
| 2430 | + ret = ndev->irq; | |
| 2422 | 2431 | goto clean_ale_ret; |
| 2423 | 2432 | } |
| 2424 | 2433 | |
| @@ -2439,8 +2448,10 @@ static int cpsw_probe(struct platform_device *pdev) · 14 unmodified lines | ||
| 2439 | 2448 | |
| 2440 | 2449 | /* RX IRQ */ |
| 2441 | 2450 | irq = platform_get_irq(pdev, 1); |
| 2442 | − if (irq < 0) | |
| 2451 | + if (irq < 0) { | |
| 2452 | + ret = irq; | |
| 2443 | 2453 | goto clean_ale_ret; |
| 2454 | + } | |
| 2444 | 2455 | |
| 2445 | 2456 | priv->irqs_table[0] = irq; |
| 2446 | 2457 | ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt, |
| @@ -2452,8 +2463,10 @@ static int cpsw_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 2452 | 2463 | |
| 2453 | 2464 | /* TX IRQ */ |
| 2454 | 2465 | irq = platform_get_irq(pdev, 2); |
| 2455 | − if (irq < 0) | |
| 2466 | + if (irq < 0) { | |
| 2467 | + ret = irq; | |
| 2456 | 2468 | goto clean_ale_ret; |
| 2469 | + } | |
| 2457 | 2470 | |
| 2458 | 2471 | priv->irqs_table[1] = irq; |
| 2459 | 2472 | ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt, |
| @@ -967,8 +967,6 @@ static netdev_tx_t geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, · 966 unmodified lines | ||
| 967 | 967 | err = udp_tunnel6_xmit_skb(dst, gs6->sock->sk, skb, dev, |
| 968 | 968 | &fl6.saddr, &fl6.daddr, prio, ttl, |
| 969 | 969 | sport, geneve->dst_port, !udp_csum); |
| 970 | − | |
| 971 | − iptunnel_xmit_stats(err, &dev->stats, dev->tstats); | |
| 972 | 970 | return NETDEV_TX_OK; |
| 973 | 971 | |
| 974 | 972 | tx_error: |
| @@ -1157,7 +1155,7 @@ static int geneve_configure(struct net *net, struct net_device *dev, · 182 unmodified lines | ||
| 1157 | 1155 | struct geneve_net *gn = net_generic(net, geneve_net_id); |
| 1158 | 1156 | struct geneve_dev *t, *geneve = netdev_priv(dev); |
| 1159 | 1157 | bool tun_collect_md, tun_on_same_port; |
| 1160 | − int err; | |
| 1158 | + int err, encap_len; | |
| 1161 | 1159 | |
| 1162 | 1160 | if (!remote) |
| 1163 | 1161 | return -EINVAL; |
| @@ -1189,6 +1187,14 @@ static int geneve_configure(struct net *net, struct net_device *dev, · 25 unmodified lines | ||
| 1189 | 1187 | if (t) |
| 1190 | 1188 | return -EBUSY; |
| 1191 | 1189 | |
| 1190 | + /* make enough headroom for basic scenario */ | |
| 1191 | + encap_len = GENEVE_BASE_HLEN + ETH_HLEN; | |
| 1192 | + if (remote->sa.sa_family == AF_INET) | |
| 1193 | + encap_len += sizeof(struct iphdr); | |
| 1194 | + else | |
| 1195 | + encap_len += sizeof(struct ipv6hdr); | |
| 1196 | + dev->needed_headroom = encap_len + ETH_HLEN; | |
| 1197 | + | |
| 1192 | 1198 | if (metadata) { |
| 1193 | 1199 | if (tun_on_same_port) |
| 1194 | 1200 | return -EPERM; |
| @@ -683,14 +683,20 @@ static void sixpack_close(struct tty_struct *tty) · 682 unmodified lines | ||
| 683 | 683 | if (!atomic_dec_and_test(&sp->refcnt)) |
| 684 | 684 | down(&sp->dead_sem); |
| 685 | 685 | |
| 686 | − unregister_netdev(sp->dev); | |
| 686 | + /* We must stop the queue to avoid potentially scribbling | |
| 687 | + * on the free buffers. The sp->dead_sem is not sufficient | |
| 688 | + * to protect us from sp->xbuff access. | |
| 689 | + */ | |
| 690 | + netif_stop_queue(sp->dev); | |
| 687 | 691 | |
| 688 | − del_timer(&sp->tx_t); | |
| 689 | − del_timer(&sp->resync_t); | |
| 692 | + del_timer_sync(&sp->tx_t); | |
| 693 | + del_timer_sync(&sp->resync_t); | |
| 690 | 694 | |
| 691 | 695 | /* Free all 6pack frame buffers. */ |
| 692 | 696 | kfree(sp->rbuff); |
| 693 | 697 | kfree(sp->xbuff); |
| 698 | + | |
| 699 | + unregister_netdev(sp->dev); | |
| 694 | 700 | } |
| 695 | 701 | |
| 696 | 702 | /* Perform I/O control on an active 6pack channel. */ |
| @@ -797,14 +797,19 @@ static void mkiss_close(struct tty_struct *tty) · 796 unmodified lines | ||
| 797 | 797 | */ |
| 798 | 798 | if (!atomic_dec_and_test(&ax->refcnt)) |
| 799 | 799 | down(&ax->dead_sem); |
| 800 | − | |
| 801 | − unregister_netdev(ax->dev); | |
| 800 | + /* | |
| 801 | + * Halt the transmit queue so that a new transmit cannot scribble | |
| 802 | + * on our buffers | |
| 803 | + */ | |
| 804 | + netif_stop_queue(ax->dev); | |
| 802 | 805 | |
| 803 | 806 | /* Free all AX25 frame buffers. */ |
| 804 | 807 | kfree(ax->rbuff); |
| 805 | 808 | kfree(ax->xbuff); |
| 806 | 809 | |
| 807 | 810 | ax->tty = NULL; |
| 811 | + | |
| 812 | + unregister_netdev(ax->dev); | |
| 808 | 813 | } |
| 809 | 814 | |
| 810 | 815 | /* Perform I/O control on an active ax25 channel. */ |
| @@ -149,9 +149,14 @@ int mdio_mux_init(struct device *dev, · 148 unmodified lines | ||
| 149 | 149 | } |
| 150 | 150 | cb->bus_number = v; |
| 151 | 151 | cb->parent = pb; |
| 152 | + | |
| 152 | 153 | cb->mii_bus = mdiobus_alloc(); |
| 154 | + if (!cb->mii_bus) { | |
| 155 | + ret_val = -ENOMEM; | |
| 156 | + of_node_put(child_bus_node); | |
| 157 | + break; | |
| 158 | + } | |
| 153 | 159 | cb->mii_bus->priv = cb; |
| 154 | − | |
| 155 | 160 | cb->mii_bus->irq = cb->phy_irq; |
| 156 | 161 | cb->mii_bus->name = "mdio_mux"; |
| 157 | 162 | snprintf(cb->mii_bus->id, MII_BUS_ID_SIZE, "%x.%x", |
| @@ -339,9 +339,18 @@ static int ksz9021_config_init(struct phy_device *phydev) · 338 unmodified lines | ||
| 339 | 339 | { |
| 340 | 340 | const struct device *dev = &phydev->dev; |
| 341 | 341 | const struct device_node *of_node = dev->of_node; |
| 342 | + const struct device *dev_walker; | |
| 342 | 343 | |
| 343 | − if (!of_node && dev->parent->of_node) | |
| 344 | − of_node = dev->parent->of_node; | |
| 344 | + /* The Micrel driver has a deprecated option to place phy OF | |
| 345 | + * properties in the MAC node. Walk up the tree of devices to | |
| 346 | + * find a device with an OF node. | |
| 347 | + */ | |
| 348 | + dev_walker = &phydev->dev; | |
| 349 | + do { | |
| 350 | + of_node = dev_walker->of_node; | |
| 351 | + dev_walker = dev_walker->parent; | |
| 352 | + | |
| 353 | + } while (!of_node && dev_walker); | |
| 345 | 354 | |
| 346 | 355 | if (of_node) { |
| 347 | 356 | ksz9021_load_values_from_of(phydev, of_node, |
| @@ -568,6 +568,9 @@ static int pppoe_create(struct net *net, struct socket *sock, int kern) · 567 unmodified lines | ||
| 568 | 568 | sk->sk_family = PF_PPPOX; |
| 569 | 569 | sk->sk_protocol = PX_PROTO_OE; |
| 570 | 570 | |
| 571 | + INIT_WORK(&pppox_sk(sk)->proto.pppoe.padt_work, | |
| 572 | + pppoe_unbind_sock_work); | |
| 573 | + | |
| 571 | 574 | return 0; |
| 572 | 575 | } |
| 573 | 576 | |
| @@ -632,8 +635,6 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, · 58 unmodified lines | ||
| 632 | 635 | |
| 633 | 636 | lock_sock(sk); |
| 634 | 637 | |
| 635 | − INIT_WORK(&po->proto.pppoe.padt_work, pppoe_unbind_sock_work); | |
| 636 | − | |
| 637 | 638 | error = -EINVAL; |
| 638 | 639 | if (sp->sa_protocol != PX_PROTO_OE) |
| 639 | 640 | goto end; |
| @@ -663,8 +664,13 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, · 23 unmodified lines | ||
| 663 | 664 | po->pppoe_dev = NULL; |
| 664 | 665 | } |
| 665 | 666 | |
| 666 | − memset(sk_pppox(po) + 1, 0, | |
| 667 | − sizeof(struct pppox_sock) - sizeof(struct sock)); | |
| 667 | + po->pppoe_ifindex = 0; | |
| 668 | + memset(&po->pppoe_pa, 0, sizeof(po->pppoe_pa)); | |
| 669 | + memset(&po->pppoe_relay, 0, sizeof(po->pppoe_relay)); | |
| 670 | + memset(&po->chan, 0, sizeof(po->chan)); | |
| 671 | + po->next = NULL; | |
| 672 | + po->num = 0; | |
| 673 | + | |
| 668 | 674 | sk->sk_state = PPPOX_NONE; |
| 669 | 675 | } |
| 670 | 676 | |
| @@ -419,6 +419,9 @@ static int pptp_bind(struct socket *sock, struct sockaddr *uservaddr, · 418 unmodified lines | ||
| 419 | 419 | struct pptp_opt *opt = &po->proto.pptp; |
| 420 | 420 | int error = 0; |
| 421 | 421 | |
| 422 | + if (sockaddr_len < sizeof(struct sockaddr_pppox)) | |
| 423 | + return -EINVAL; | |
| 424 | + | |
| 422 | 425 | lock_sock(sk); |
| 423 | 426 | |
| 424 | 427 | opt->src_addr = sp->sa_addr.pptp; |
| @@ -440,6 +443,9 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr, · 15 unmodified lines | ||
| 440 | 443 | struct flowi4 fl4; |
| 441 | 444 | int error = 0; |
| 442 | 445 | |
| 446 | + if (sockaddr_len < sizeof(struct sockaddr_pppox)) | |
| 447 | + return -EINVAL; | |
| 448 | + | |
| 443 | 449 | if (sp->sa_protocol != PX_PROTO_PPTP) |
| 444 | 450 | return -EINVAL; |
| 445 | 451 | |
| @@ -100,7 +100,7 @@ static const struct net_device_ops cdc_mbim_netdev_ops = { · 99 unmodified lines | ||
| 100 | 100 | .ndo_stop = usbnet_stop, |
| 101 | 101 | .ndo_start_xmit = usbnet_start_xmit, |
| 102 | 102 | .ndo_tx_timeout = usbnet_tx_timeout, |
| 103 | − .ndo_change_mtu = usbnet_change_mtu, | |
| 103 | + .ndo_change_mtu = cdc_ncm_change_mtu, | |
| 104 | 104 | .ndo_set_mac_address = eth_mac_addr, |
| 105 | 105 | .ndo_validate_addr = eth_validate_addr, |
| 106 | 106 | .ndo_vlan_rx_add_vid = cdc_mbim_rx_add_vid, |
| @@ -158,7 +158,7 @@ static int cdc_mbim_bind(struct usbnet *dev, struct usb_interface *intf) · 51 unmodified lines | ||
| 158 | 158 | if (!cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting)) |
| 159 | 159 | goto err; |
| 160 | 160 | |
| 161 | − ret = cdc_ncm_bind_common(dev, intf, data_altsetting, 0); | |
| 161 | + ret = cdc_ncm_bind_common(dev, intf, data_altsetting, dev->driver_info->data); | |
| 162 | 162 | if (ret) |
| 163 | 163 | goto err; |
| 164 | 164 | |
| @@ -582,6 +582,26 @@ static const struct driver_info cdc_mbim_info_zlp = { · 417 unmodified lines | ||
| 582 | 582 | .tx_fixup = cdc_mbim_tx_fixup, |
| 583 | 583 | }; |
| 584 | 584 | |
| 585 | +/* The spefication explicitly allows NDPs to be placed anywhere in the | |
| 586 | + * frame, but some devices fail unless the NDP is placed after the IP | |
| 587 | + * packets. Using the CDC_NCM_FLAG_NDP_TO_END flags to force this | |
| 588 | + * behaviour. | |
| 589 | + * | |
| 590 | + * Note: The current implementation of this feature restricts each NTB | |
| 591 | + * to a single NDP, implying that multiplexed sessions cannot share an | |
| 592 | + * NTB. This might affect performace for multiplexed sessions. | |
| 593 | + */ | |
| 594 | +static const struct driver_info cdc_mbim_info_ndp_to_end = { | |
| 595 | + .description = "CDC MBIM", | |
| 596 | + .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN, | |
| 597 | + .bind = cdc_mbim_bind, | |
| 598 | + .unbind = cdc_mbim_unbind, | |
| 599 | + .manage_power = cdc_mbim_manage_power, | |
| 600 | + .rx_fixup = cdc_mbim_rx_fixup, | |
| 601 | + .tx_fixup = cdc_mbim_tx_fixup, | |
| 602 | + .data = CDC_NCM_FLAG_NDP_TO_END, | |
| 603 | +}; | |
| 604 | + | |
| 585 | 605 | static const struct usb_device_id mbim_devs[] = { |
| 586 | 606 | /* This duplicate NCM entry is intentional. MBIM devices can |
| 587 | 607 | * be disguised as NCM by default, and this is necessary to |
| @@ -597,6 +617,10 @@ static const struct usb_device_id mbim_devs[] = { · 9 unmodified lines | ||
| 597 | 617 | { USB_VENDOR_AND_INTERFACE_INFO(0x0bdb, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), |
| 598 | 618 | .driver_info = (unsigned long)&cdc_mbim_info, |
| 599 | 619 | }, |
| 620 | + /* Huawei E3372 fails unless NDP comes after the IP packets */ | |
| 621 | + { USB_DEVICE_AND_INTERFACE_INFO(0x12d1, 0x157d, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), | |
| 622 | + .driver_info = (unsigned long)&cdc_mbim_info_ndp_to_end, | |
| 623 | + }, | |
| 600 | 624 | /* default entry */ |
| 601 | 625 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE), |
| 602 | 626 | .driver_info = (unsigned long)&cdc_mbim_info_zlp, |
| @@ -41,6 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #include <linux/module.h> |
| 42 | 42 | #include <linux/netdevice.h> |
| 43 | 43 | #include <linux/ctype.h> |
| 44 | +#include <linux/etherdevice.h> | |
| 44 | 45 | #include <linux/ethtool.h> |
| 45 | 46 | #include <linux/workqueue.h> |
| 46 | 47 | #include <linux/mii.h> |
| @@ -689,6 +690,33 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) · 642 unmodified lines | ||
| 689 | 690 | kfree(ctx); |
| 690 | 691 | } |
| 691 | 692 | |
| 693 | +/* we need to override the usbnet change_mtu ndo for two reasons: | |
| 694 | + * - respect the negotiated maximum datagram size | |
| 695 | + * - avoid unwanted changes to rx and tx buffers | |
| 696 | + */ | |
| 697 | +int cdc_ncm_change_mtu(struct net_device *net, int new_mtu) | |
| 698 | +{ | |
| 699 | + struct usbnet *dev = netdev_priv(net); | |
| 700 | + struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; | |
| 701 | + int maxmtu = ctx->max_datagram_size - cdc_ncm_eth_hlen(dev); | |
| 702 | + | |
| 703 | + if (new_mtu <= 0 || new_mtu > maxmtu) | |
| 704 | + return -EINVAL; | |
| 705 | + net->mtu = new_mtu; | |
| 706 | + return 0; | |
| 707 | +} | |
| 708 | +EXPORT_SYMBOL_GPL(cdc_ncm_change_mtu); | |
| 709 | + | |
| 710 | +static const struct net_device_ops cdc_ncm_netdev_ops = { | |
| 711 | + .ndo_open = usbnet_open, | |
| 712 | + .ndo_stop = usbnet_stop, | |
| 713 | + .ndo_start_xmit = usbnet_start_xmit, | |
| 714 | + .ndo_tx_timeout = usbnet_tx_timeout, | |
| 715 | + .ndo_change_mtu = cdc_ncm_change_mtu, | |
| 716 | + .ndo_set_mac_address = eth_mac_addr, | |
| 717 | + .ndo_validate_addr = eth_validate_addr, | |
| 718 | +}; | |
| 719 | + | |
| 692 | 720 | int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags) |
| 693 | 721 | { |
| 694 | 722 | struct cdc_ncm_ctx *ctx; |
| @@ -823,6 +851,9 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ · 128 unmodified lines | ||
| 823 | 851 | /* add our sysfs attrs */ |
| 824 | 852 | dev->net->sysfs_groups[0] = &cdc_ncm_sysfs_attr_group; |
| 825 | 853 | |
| 854 | + /* must handle MTU changes */ | |
| 855 | + dev->net->netdev_ops = &cdc_ncm_netdev_ops; | |
| 856 | + | |
| 826 | 857 | return 0; |
| 827 | 858 | |
| 828 | 859 | error2: |
| @@ -955,10 +986,18 @@ static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_ · 126 unmodified lines | ||
| 955 | 986 | * NTH16 header as we would normally do. NDP isn't written to the SKB yet, and |
| 956 | 987 | * the wNdpIndex field in the header is actually not consistent with reality. It will be later. |
| 957 | 988 | */ |
| 958 | − if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) | |
| 989 | + if (ctx->drvflags & CDC_NCM_FLAG_NDP_TO_END) { | |
| 959 | 990 | if (ctx->delayed_ndp16->dwSignature == sign) |
| 960 | 991 | return ctx->delayed_ndp16; |
| 961 | 992 | |
| 993 | + /* We can only push a single NDP to the end. Return | |
| 994 | + * NULL to send what we've already got and queue this | |
| 995 | + * skb for later. | |
| 996 | + */ | |
| 997 | + else if (ctx->delayed_ndp16->dwSignature) | |
| 998 | + return NULL; | |
| 999 | + } | |
| 1000 | + | |
| 962 | 1001 | /* follow the chain of NDPs, looking for a match */ |
| 963 | 1002 | while (ndpoffset) { |
| 964 | 1003 | ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + ndpoffset); |
| @@ -1550,6 +1589,24 @@ static const struct usb_device_id cdc_devs[] = { · 585 unmodified lines | ||
| 1550 | 1589 | .driver_info = (unsigned long) &wwan_info, |
| 1551 | 1590 | }, |
| 1552 | 1591 | |
| 1592 | + /* DW5812 LTE Verizon Mobile Broadband Card | |
| 1593 | + * Unlike DW5550 this device requires FLAG_NOARP | |
| 1594 | + */ | |
| 1595 | + { USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x81bb, | |
| 1596 | + USB_CLASS_COMM, | |
| 1597 | + USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), | |
| 1598 | + .driver_info = (unsigned long)&wwan_noarp_info, | |
| 1599 | + }, | |
| 1600 | + | |
| 1601 | + /* DW5813 LTE AT&T Mobile Broadband Card | |
| 1602 | + * Unlike DW5550 this device requires FLAG_NOARP | |
| 1603 | + */ | |
| 1604 | + { USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x81bc, | |
| 1605 | + USB_CLASS_COMM, | |
| 1606 | + USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), | |
| 1607 | + .driver_info = (unsigned long)&wwan_noarp_info, | |
| 1608 | + }, | |
| 1609 | + | |
| 1553 | 1610 | /* Dell branded MBM devices like DW5550 */ |
| 1554 | 1611 | { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 1555 | 1612 | | USB_DEVICE_ID_MATCH_VENDOR, |
| @@ -742,6 +742,7 @@ static const struct usb_device_id products[] = { · 741 unmodified lines | ||
| 742 | 742 | {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ |
| 743 | 743 | {QMI_FIXED_INTF(0x413c, 0x81b1, 8)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ |
| 744 | 744 | {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)}, /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */ |
| 745 | + {QMI_FIXED_INTF(0x22de, 0x9061, 3)}, /* WeTelecom WPD-600N */ | |
| 745 | 746 | |
| 746 | 747 | /* 4. Gobi 1000 devices */ |
| 747 | 748 | {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ |
| @@ -3067,17 +3067,6 @@ static int rtl8152_open(struct net_device *netdev) · 3066 unmodified lines | ||
| 3067 | 3067 | |
| 3068 | 3068 | mutex_lock(&tp->control); |
| 3069 | 3069 | |
| 3070 | − /* The WORK_ENABLE may be set when autoresume occurs */ | |
| 3071 | − if (test_bit(WORK_ENABLE, &tp->flags)) { | |
| 3072 | − clear_bit(WORK_ENABLE, &tp->flags); | |
| 3073 | − usb_kill_urb(tp->intr_urb); | |
| 3074 | − cancel_delayed_work_sync(&tp->schedule); | |
| 3075 | − | |
| 3076 | − /* disable the tx/rx, if the workqueue has enabled them. */ | |
| 3077 | − if (netif_carrier_ok(netdev)) | |
| 3078 | − tp->rtl_ops.disable(tp); | |
| 3079 | − } | |
| 3080 | − | |
| 3081 | 3070 | tp->rtl_ops.up(tp); |
| 3082 | 3071 | |
| 3083 | 3072 | rtl8152_set_speed(tp, AUTONEG_ENABLE, |
| @@ -3124,12 +3113,6 @@ static int rtl8152_close(struct net_device *netdev) · 40 unmodified lines | ||
| 3124 | 3113 | } else { |
| 3125 | 3114 | mutex_lock(&tp->control); |
| 3126 | 3115 | |
| 3127 | − /* The autosuspend may have been enabled and wouldn't | |
| 3128 | − * be disable when autoresume occurs, because the | |
| 3129 | − * netif_running() would be false. | |
| 3130 | − */ | |
| 3131 | − rtl_runtime_suspend_enable(tp, false); | |
| 3132 | − | |
| 3133 | 3116 | tp->rtl_ops.down(tp); |
| 3134 | 3117 | |
| 3135 | 3118 | mutex_unlock(&tp->control); |
| @@ -3512,7 +3495,7 @@ static int rtl8152_resume(struct usb_interface *intf) · 376 unmodified lines | ||
| 3512 | 3495 | netif_device_attach(tp->netdev); |
| 3513 | 3496 | } |
| 3514 | 3497 | |
| 3515 | − if (netif_running(tp->netdev)) { | |
| 3498 | + if (netif_running(tp->netdev) && tp->netdev->flags & IFF_UP) { | |
| 3516 | 3499 | if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { |
| 3517 | 3500 | rtl_runtime_suspend_enable(tp, false); |
| 3518 | 3501 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); |
| @@ -3532,6 +3515,8 @@ static int rtl8152_resume(struct usb_interface *intf) · 13 unmodified lines | ||
| 3532 | 3515 | } |
| 3533 | 3516 | usb_submit_urb(tp->intr_urb, GFP_KERNEL); |
| 3534 | 3517 | } else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { |
| 3518 | + if (tp->netdev->flags & IFF_UP) | |
| 3519 | + rtl_runtime_suspend_enable(tp, false); | |
| 3535 | 3520 | clear_bit(SELECTIVE_SUSPEND, &tp->flags); |
| 3536 | 3521 | } |
| 3537 | 3522 | |
| @@ -3540,6 +3525,14 @@ static int rtl8152_resume(struct usb_interface *intf) · 2 unmodified lines | ||
| 3540 | 3525 | return 0; |
| 3541 | 3526 | } |
| 3542 | 3527 | |
| 3528 | +static int rtl8152_reset_resume(struct usb_interface *intf) | |
| 3529 | +{ | |
| 3530 | + struct r8152 *tp = usb_get_intfdata(intf); | |
| 3531 | + | |
| 3532 | + clear_bit(SELECTIVE_SUSPEND, &tp->flags); | |
| 3533 | + return rtl8152_resume(intf); | |
| 3534 | +} | |
| 3535 | + | |
| 3543 | 3536 | static void rtl8152_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
| 3544 | 3537 | { |
| 3545 | 3538 | struct r8152 *tp = netdev_priv(dev); |
| @@ -4291,7 +4284,7 @@ static struct usb_driver rtl8152_driver = { · 745 unmodified lines | ||
| 4291 | 4284 | .disconnect = rtl8152_disconnect, |
| 4292 | 4285 | .suspend = rtl8152_suspend, |
| 4293 | 4286 | .resume = rtl8152_resume, |
| 4294 | − .reset_resume = rtl8152_resume, | |
| 4287 | + .reset_resume = rtl8152_reset_resume, | |
| 4295 | 4288 | .pre_reset = rtl8152_pre_reset, |
| 4296 | 4289 | .post_reset = rtl8152_post_reset, |
| 4297 | 4290 | .supports_autosuspend = 1, |
| @@ -117,12 +117,6 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) · 116 unmodified lines | ||
| 117 | 117 | kfree_skb(skb); |
| 118 | 118 | goto drop; |
| 119 | 119 | } |
| 120 | − /* don't change ip_summed == CHECKSUM_PARTIAL, as that | |
| 121 | − * will cause bad checksum on forwarded packets | |
| 122 | − */ | |
| 123 | − if (skb->ip_summed == CHECKSUM_NONE && | |
| 124 | − rcv->features & NETIF_F_RXCSUM) | |
| 125 | − skb->ip_summed = CHECKSUM_UNNECESSARY; | |
| 126 | 120 | |
| 127 | 121 | if (likely(dev_forward_skb(rcv, skb) == NET_RX_SUCCESS)) { |
| 128 | 122 | struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats); |
| @@ -1380,10 +1380,10 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, · 1379 unmodified lines | ||
| 1380 | 1380 | skip_page_frags = true; |
| 1381 | 1381 | goto rcd_done; |
| 1382 | 1382 | } |
| 1383 | − new_dma_addr = dma_map_page(&adapter->pdev->dev | |
| 1384 | − , rbi->page, | |
| 1385 | − 0, PAGE_SIZE, | |
| 1386 | − PCI_DMA_FROMDEVICE); | |
| 1383 | + new_dma_addr = dma_map_page(&adapter->pdev->dev, | |
| 1384 | + new_page, | |
| 1385 | + 0, PAGE_SIZE, | |
| 1386 | + PCI_DMA_FROMDEVICE); | |
| 1387 | 1387 | if (dma_mapping_error(&adapter->pdev->dev, |
| 1388 | 1388 | new_dma_addr)) { |
| 1389 | 1389 | put_page(new_page); |
| @@ -69,10 +69,10 @@ · 68 unmodified lines | ||
| 69 | 69 | /* |
| 70 | 70 | * Version numbers |
| 71 | 71 | */ |
| 72 | −#define VMXNET3_DRIVER_VERSION_STRING "1.4.4.0-k" | |
| 72 | +#define VMXNET3_DRIVER_VERSION_STRING "1.4.5.0-k" | |
| 73 | 73 | |
| 74 | 74 | /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ |
| 75 | −#define VMXNET3_DRIVER_VERSION_NUM 0x01040400 | |
| 75 | +#define VMXNET3_DRIVER_VERSION_NUM 0x01040500 | |
| 76 | 76 | |
| 77 | 77 | #if defined(CONFIG_PCI_MSI) |
| 78 | 78 | /* RSS only makes sense if MSI-X is supported. */ |
| @@ -800,7 +800,7 @@ static struct rtable *vrf_get_rtable(const struct net_device *dev, · 799 unmodified lines | ||
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | /* called under rcu_read_lock */ |
| 803 | −static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) | |
| 803 | +static int vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) | |
| 804 | 804 | { |
| 805 | 805 | struct fib_result res = { .tclassid = 0 }; |
| 806 | 806 | struct net *net = dev_net(dev); |
| @@ -808,9 +808,10 @@ static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) · 1 unmodified line | ||
| 808 | 808 | u8 flags = fl4->flowi4_flags; |
| 809 | 809 | u8 scope = fl4->flowi4_scope; |
| 810 | 810 | u8 tos = RT_FL_TOS(fl4); |
| 811 | + int rc; | |
| 811 | 812 | |
| 812 | 813 | if (unlikely(!fl4->daddr)) |
| 813 | − return; | |
| 814 | + return 0; | |
| 814 | 815 | |
| 815 | 816 | fl4->flowi4_flags |= FLOWI_FLAG_SKIP_NH_OIF; |
| 816 | 817 | fl4->flowi4_iif = LOOPBACK_IFINDEX; |
| @@ -818,7 +819,8 @@ static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) · 1 unmodified line | ||
| 818 | 819 | fl4->flowi4_scope = ((tos & RTO_ONLINK) ? |
| 819 | 820 | RT_SCOPE_LINK : RT_SCOPE_UNIVERSE); |
| 820 | 821 | |
| 821 | − if (!fib_lookup(net, fl4, &res, 0)) { | |
| 822 | + rc = fib_lookup(net, fl4, &res, 0); | |
| 823 | + if (!rc) { | |
| 822 | 824 | if (res.type == RTN_LOCAL) |
| 823 | 825 | fl4->saddr = res.fi->fib_prefsrc ? : fl4->daddr; |
| 824 | 826 | else |
| @@ -828,6 +830,8 @@ static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) · 3 unmodified lines | ||
| 828 | 830 | fl4->flowi4_flags = flags; |
| 829 | 831 | fl4->flowi4_tos = orig_tos; |
| 830 | 832 | fl4->flowi4_scope = scope; |
| 833 | + | |
| 834 | + return rc; | |
| 831 | 835 | } |
| 832 | 836 | |
| 833 | 837 | #if IS_ENABLED(CONFIG_IPV6) |
| @@ -1158,7 +1158,6 @@ static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb, · 1157 unmodified lines | ||
| 1158 | 1158 | struct pcpu_sw_netstats *stats; |
| 1159 | 1159 | union vxlan_addr saddr; |
| 1160 | 1160 | int err = 0; |
| 1161 | − union vxlan_addr *remote_ip; | |
| 1162 | 1161 | |
| 1163 | 1162 | /* For flow based devices, map all packets to VNI 0 */ |
| 1164 | 1163 | if (vs->flags & VXLAN_F_COLLECT_METADATA) |
| @@ -1169,7 +1168,6 @@ static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb, · 4 unmodified lines | ||
| 1169 | 1168 | if (!vxlan) |
| 1170 | 1169 | goto drop; |
| 1171 | 1170 | |
| 1172 | − remote_ip = &vxlan->default_dst.remote_ip; | |
| 1173 | 1171 | skb_reset_mac_header(skb); |
| 1174 | 1172 | skb_scrub_packet(skb, !net_eq(vxlan->net, dev_net(vxlan->dev))); |
| 1175 | 1173 | skb->protocol = eth_type_trans(skb, vxlan->dev); |
| @@ -1179,8 +1177,8 @@ static void vxlan_rcv(struct vxlan_sock *vs, struct sk_buff *skb, · 3 unmodified lines | ||
| 1179 | 1177 | if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr)) |
| 1180 | 1178 | goto drop; |
| 1181 | 1179 | |
| 1182 | − /* Re-examine inner Ethernet packet */ | |
| 1183 | − if (remote_ip->sa.sa_family == AF_INET) { | |
| 1180 | + /* Get data from the outer IP header */ | |
| 1181 | + if (vxlan_get_sk_family(vs) == AF_INET) { | |
| 1184 | 1182 | oip = ip_hdr(skb); |
| 1185 | 1183 | saddr.sin.sin_addr.s_addr = oip->saddr; |
| 1186 | 1184 | saddr.sa.sa_family = AF_INET; |
| @@ -1848,6 +1846,34 @@ static int vxlan_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *sk · 661 unmodified lines | ||
| 1848 | 1846 | !(vxflags & VXLAN_F_UDP_CSUM)); |
| 1849 | 1847 | } |
| 1850 | 1848 | |
| 1849 | +#if IS_ENABLED(CONFIG_IPV6) | |
| 1850 | +static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, | |
| 1851 | + struct sk_buff *skb, int oif, | |
| 1852 | + const struct in6_addr *daddr, | |
| 1853 | + struct in6_addr *saddr) | |
| 1854 | +{ | |
| 1855 | + struct dst_entry *ndst; | |
| 1856 | + struct flowi6 fl6; | |
| 1857 | + int err; | |
| 1858 | + | |
| 1859 | + memset(&fl6, 0, sizeof(fl6)); | |
| 1860 | + fl6.flowi6_oif = oif; | |
| 1861 | + fl6.daddr = *daddr; | |
| 1862 | + fl6.saddr = vxlan->cfg.saddr.sin6.sin6_addr; | |
| 1863 | + fl6.flowi6_mark = skb->mark; | |
| 1864 | + fl6.flowi6_proto = IPPROTO_UDP; | |
| 1865 | + | |
| 1866 | + err = ipv6_stub->ipv6_dst_lookup(vxlan->net, | |
| 1867 | + vxlan->vn6_sock->sock->sk, | |
| 1868 | + &ndst, &fl6); | |
| 1869 | + if (err < 0) | |
| 1870 | + return ERR_PTR(err); | |
| 1871 | + | |
| 1872 | + *saddr = fl6.saddr; | |
| 1873 | + return ndst; | |
| 1874 | +} | |
| 1875 | +#endif | |
| 1876 | + | |
| 1851 | 1877 | /* Bypass encapsulation if the destination is local */ |
| 1852 | 1878 | static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, |
| 1853 | 1879 | struct vxlan_dev *dst_vxlan) |
| @@ -2035,21 +2061,17 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, · 181 unmodified lines | ||
| 2035 | 2061 | #if IS_ENABLED(CONFIG_IPV6) |
| 2036 | 2062 | } else { |
| 2037 | 2063 | struct dst_entry *ndst; |
| 2038 | − struct flowi6 fl6; | |
| 2064 | + struct in6_addr saddr; | |
| 2039 | 2065 | u32 rt6i_flags; |
| 2040 | 2066 | |
| 2041 | 2067 | if (!vxlan->vn6_sock) |
| 2042 | 2068 | goto drop; |
| 2043 | 2069 | sk = vxlan->vn6_sock->sock->sk; |
| 2044 | 2070 | |
| 2045 | − memset(&fl6, 0, sizeof(fl6)); | |
| 2046 | − fl6.flowi6_oif = rdst ? rdst->remote_ifindex : 0; | |
| 2047 | − fl6.daddr = dst->sin6.sin6_addr; | |
| 2048 | − fl6.saddr = vxlan->cfg.saddr.sin6.sin6_addr; | |
| 2049 | − fl6.flowi6_mark = skb->mark; | |
| 2050 | − fl6.flowi6_proto = IPPROTO_UDP; | |
| 2051 | − | |
| 2052 | − if (ipv6_stub->ipv6_dst_lookup(vxlan->net, sk, &ndst, &fl6)) { | |
| 2071 | + ndst = vxlan6_get_route(vxlan, skb, | |
| 2072 | + rdst ? rdst->remote_ifindex : 0, | |
| 2073 | + &dst->sin6.sin6_addr, &saddr); | |
| 2074 | + if (IS_ERR(ndst)) { | |
| 2053 | 2075 | netdev_dbg(dev, "no route to %pI6\n", |
| 2054 | 2076 | &dst->sin6.sin6_addr); |
| 2055 | 2077 | dev->stats.tx_carrier_errors++; |
| @@ -2081,7 +2103,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, · 25 unmodified lines | ||
| 2081 | 2103 | } |
| 2082 | 2104 | |
| 2083 | 2105 | ttl = ttl ? : ip6_dst_hoplimit(ndst); |
| 2084 | − err = vxlan6_xmit_skb(ndst, sk, skb, dev, &fl6.saddr, &fl6.daddr, | |
| 2106 | + err = vxlan6_xmit_skb(ndst, sk, skb, dev, &saddr, &dst->sin6.sin6_addr, | |
| 2085 | 2107 | 0, ttl, src_port, dst_port, htonl(vni << 8), md, |
| 2086 | 2108 | !net_eq(vxlan->net, dev_net(vxlan->dev)), |
| 2087 | 2109 | flags); |
| @@ -2395,9 +2417,30 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) · 307 unmodified lines | ||
| 2395 | 2417 | vxlan->cfg.port_max, true); |
| 2396 | 2418 | dport = info->key.tp_dst ? : vxlan->cfg.dst_port; |
| 2397 | 2419 | |
| 2398 | − if (ip_tunnel_info_af(info) == AF_INET) | |
| 2420 | + if (ip_tunnel_info_af(info) == AF_INET) { | |
| 2421 | + if (!vxlan->vn4_sock) | |
| 2422 | + return -EINVAL; | |
| 2399 | 2423 | return egress_ipv4_tun_info(dev, skb, info, sport, dport); |
| 2400 | − return -EINVAL; | |
| 2424 | + } else { | |
| 2425 | +#if IS_ENABLED(CONFIG_IPV6) | |
| 2426 | + struct dst_entry *ndst; | |
| 2427 | + | |
| 2428 | + if (!vxlan->vn6_sock) | |
| 2429 | + return -EINVAL; | |
| 2430 | + ndst = vxlan6_get_route(vxlan, skb, 0, | |
| 2431 | + &info->key.u.ipv6.dst, | |
| 2432 | + &info->key.u.ipv6.src); | |
| 2433 | + if (IS_ERR(ndst)) | |
| 2434 | + return PTR_ERR(ndst); | |
| 2435 | + dst_release(ndst); | |
| 2436 | + | |
| 2437 | + info->key.tp_src = sport; | |
| 2438 | + info->key.tp_dst = dport; | |
| 2439 | +#else /* !CONFIG_IPV6 */ | |
| 2440 | + return -EPFNOSUPPORT; | |
| 2441 | +#endif | |
| 2442 | + } | |
| 2443 | + return 0; | |
| 2401 | 2444 | } |
| 2402 | 2445 | |
| 2403 | 2446 | static const struct net_device_ops vxlan_netdev_ops = { |
| @@ -69,13 +69,19 @@ · 68 unmodified lines | ||
| 69 | 69 | #include "iwl-agn-hw.h" |
| 70 | 70 | |
| 71 | 71 | /* Highest firmware API version supported */ |
| 72 | −#define IWL7260_UCODE_API_MAX 19 | |
| 72 | +#define IWL7260_UCODE_API_MAX 17 | |
| 73 | +#define IWL7265_UCODE_API_MAX 19 | |
| 74 | +#define IWL7265D_UCODE_API_MAX 19 | |
| 73 | 75 | |
| 74 | 76 | /* Oldest version we won't warn about */ |
| 75 | 77 | #define IWL7260_UCODE_API_OK 13 |
| 78 | +#define IWL7265_UCODE_API_OK 13 | |
| 79 | +#define IWL7265D_UCODE_API_OK 13 | |
| 76 | 80 | |
| 77 | 81 | /* Lowest firmware API version supported */ |
| 78 | 82 | #define IWL7260_UCODE_API_MIN 13 |
| 83 | +#define IWL7265_UCODE_API_MIN 13 | |
| 84 | +#define IWL7265D_UCODE_API_MIN 13 | |
| 79 | 85 | |
| 80 | 86 | /* NVM versions */ |
| 81 | 87 | #define IWL7260_NVM_VERSION 0x0a1d |
| @@ -149,10 +155,7 @@ static const struct iwl_ht_params iwl7000_ht_params = { · 67 unmodified lines | ||
| 149 | 155 | .ht40_bands = BIT(IEEE80211_BAND_2GHZ) | BIT(IEEE80211_BAND_5GHZ), |
| 150 | 156 | }; |
| 151 | 157 | |
| 152 | −#define IWL_DEVICE_7000 \ | |
| 153 | − .ucode_api_max = IWL7260_UCODE_API_MAX, \ | |
| 154 | − .ucode_api_ok = IWL7260_UCODE_API_OK, \ | |
| 155 | − .ucode_api_min = IWL7260_UCODE_API_MIN, \ | |
| 158 | +#define IWL_DEVICE_7000_COMMON \ | |
| 156 | 159 | .device_family = IWL_DEVICE_FAMILY_7000, \ |
| 157 | 160 | .max_inst_size = IWL60_RTC_INST_SIZE, \ |
| 158 | 161 | .max_data_size = IWL60_RTC_DATA_SIZE, \ |
| @@ -163,6 +166,24 @@ static const struct iwl_ht_params iwl7000_ht_params = { · 4 unmodified lines | ||
| 163 | 166 | .max_ht_ampdu_exponent = IEEE80211_HT_MAX_AMPDU_64K, \ |
| 164 | 167 | .dccm_offset = IWL7000_DCCM_OFFSET |
| 165 | 168 | |
| 169 | +#define IWL_DEVICE_7000 \ | |
| 170 | + IWL_DEVICE_7000_COMMON, \ | |
| 171 | + .ucode_api_max = IWL7260_UCODE_API_MAX, \ | |
| 172 | + .ucode_api_ok = IWL7260_UCODE_API_OK, \ | |
| 173 | + .ucode_api_min = IWL7260_UCODE_API_MIN | |
| 174 | + | |
| 175 | +#define IWL_DEVICE_7005 \ | |
| 176 | + IWL_DEVICE_7000_COMMON, \ | |
| 177 | + .ucode_api_max = IWL7265_UCODE_API_MAX, \ | |
| 178 | + .ucode_api_ok = IWL7265_UCODE_API_OK, \ | |
| 179 | + .ucode_api_min = IWL7265_UCODE_API_MIN | |
| 180 | + | |
| 181 | +#define IWL_DEVICE_7005D \ | |
| 182 | + IWL_DEVICE_7000_COMMON, \ | |
| 183 | + .ucode_api_max = IWL7265D_UCODE_API_MAX, \ | |
| 184 | + .ucode_api_ok = IWL7265D_UCODE_API_OK, \ | |
| 185 | + .ucode_api_min = IWL7265D_UCODE_API_MIN | |
| 186 | + | |
| 166 | 187 | const struct iwl_cfg iwl7260_2ac_cfg = { |
| 167 | 188 | .name = "Intel(R) Dual Band Wireless AC 7260", |
| 168 | 189 | .fw_name_pre = IWL7260_FW_PRE, |
| @@ -266,7 +287,7 @@ static const struct iwl_ht_params iwl7265_ht_params = { · 97 unmodified lines | ||
| 266 | 287 | const struct iwl_cfg iwl3165_2ac_cfg = { |
| 267 | 288 | .name = "Intel(R) Dual Band Wireless AC 3165", |
| 268 | 289 | .fw_name_pre = IWL7265D_FW_PRE, |
| 269 | − IWL_DEVICE_7000, | |
| 290 | + IWL_DEVICE_7005D, | |
| 270 | 291 | .ht_params = &iwl7000_ht_params, |
| 271 | 292 | .nvm_ver = IWL3165_NVM_VERSION, |
| 272 | 293 | .nvm_calib_ver = IWL3165_TX_POWER_VERSION, |
| @@ -277,7 +298,7 @@ const struct iwl_cfg iwl3165_2ac_cfg = { · 4 unmodified lines | ||
| 277 | 298 | const struct iwl_cfg iwl7265_2ac_cfg = { |
| 278 | 299 | .name = "Intel(R) Dual Band Wireless AC 7265", |
| 279 | 300 | .fw_name_pre = IWL7265_FW_PRE, |
| 280 | − IWL_DEVICE_7000, | |
| 301 | + IWL_DEVICE_7005, | |
| 281 | 302 | .ht_params = &iwl7265_ht_params, |
| 282 | 303 | .nvm_ver = IWL7265_NVM_VERSION, |
| 283 | 304 | .nvm_calib_ver = IWL7265_TX_POWER_VERSION, |
| @@ -288,7 +309,7 @@ const struct iwl_cfg iwl7265_2ac_cfg = { · 4 unmodified lines | ||
| 288 | 309 | const struct iwl_cfg iwl7265_2n_cfg = { |
| 289 | 310 | .name = "Intel(R) Dual Band Wireless N 7265", |
| 290 | 311 | .fw_name_pre = IWL7265_FW_PRE, |
| 291 | − IWL_DEVICE_7000, | |
| 312 | + IWL_DEVICE_7005, | |
| 292 | 313 | .ht_params = &iwl7265_ht_params, |
| 293 | 314 | .nvm_ver = IWL7265_NVM_VERSION, |
| 294 | 315 | .nvm_calib_ver = IWL7265_TX_POWER_VERSION, |
| @@ -299,7 +320,7 @@ const struct iwl_cfg iwl7265_2n_cfg = { · 4 unmodified lines | ||
| 299 | 320 | const struct iwl_cfg iwl7265_n_cfg = { |
| 300 | 321 | .name = "Intel(R) Wireless N 7265", |
| 301 | 322 | .fw_name_pre = IWL7265_FW_PRE, |
| 302 | − IWL_DEVICE_7000, | |
| 323 | + IWL_DEVICE_7005, | |
| 303 | 324 | .ht_params = &iwl7265_ht_params, |
| 304 | 325 | .nvm_ver = IWL7265_NVM_VERSION, |
| 305 | 326 | .nvm_calib_ver = IWL7265_TX_POWER_VERSION, |
| @@ -310,7 +331,7 @@ const struct iwl_cfg iwl7265_n_cfg = { · 4 unmodified lines | ||
| 310 | 331 | const struct iwl_cfg iwl7265d_2ac_cfg = { |
| 311 | 332 | .name = "Intel(R) Dual Band Wireless AC 7265", |
| 312 | 333 | .fw_name_pre = IWL7265D_FW_PRE, |
| 313 | − IWL_DEVICE_7000, | |
| 334 | + IWL_DEVICE_7005D, | |
| 314 | 335 | .ht_params = &iwl7265_ht_params, |
| 315 | 336 | .nvm_ver = IWL7265D_NVM_VERSION, |
| 316 | 337 | .nvm_calib_ver = IWL7265_TX_POWER_VERSION, |
| @@ -321,7 +342,7 @@ const struct iwl_cfg iwl7265d_2ac_cfg = { · 4 unmodified lines | ||
| 321 | 342 | const struct iwl_cfg iwl7265d_2n_cfg = { |
| 322 | 343 | .name = "Intel(R) Dual Band Wireless N 7265", |
| 323 | 344 | .fw_name_pre = IWL7265D_FW_PRE, |
| 324 | − IWL_DEVICE_7000, | |
| 345 | + IWL_DEVICE_7005D, | |
| 325 | 346 | .ht_params = &iwl7265_ht_params, |
| 326 | 347 | .nvm_ver = IWL7265D_NVM_VERSION, |
| 327 | 348 | .nvm_calib_ver = IWL7265_TX_POWER_VERSION, |
| @@ -332,7 +353,7 @@ const struct iwl_cfg iwl7265d_2n_cfg = { · 4 unmodified lines | ||
| 332 | 353 | const struct iwl_cfg iwl7265d_n_cfg = { |
| 333 | 354 | .name = "Intel(R) Wireless N 7265", |
| 334 | 355 | .fw_name_pre = IWL7265D_FW_PRE, |
| 335 | − IWL_DEVICE_7000, | |
| 356 | + IWL_DEVICE_7005D, | |
| 336 | 357 | .ht_params = &iwl7265_ht_params, |
| 337 | 358 | .nvm_ver = IWL7265D_NVM_VERSION, |
| 338 | 359 | .nvm_calib_ver = IWL7265_TX_POWER_VERSION, |
| @@ -342,5 +363,5 @@ const struct iwl_cfg iwl7265d_n_cfg = { · 3 unmodified lines | ||
| 342 | 363 | |
| 343 | 364 | MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); |
| 344 | 365 | MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); |
| 345 | −MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); | |
| 346 | −MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); | |
| 366 | +MODULE_FIRMWARE(IWL7265_MODULE_FIRMWARE(IWL7265_UCODE_API_OK)); | |
| 367 | +MODULE_FIRMWARE(IWL7265D_MODULE_FIRMWARE(IWL7265D_UCODE_API_OK)); | |
| @@ -1222,8 +1222,8 @@ static u8 iwl_mvm_get_key_sta_id(struct iwl_mvm *mvm, · 1221 unmodified lines | ||
| 1222 | 1222 | mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
| 1223 | 1223 | u8 sta_id = mvmvif->ap_sta_id; |
| 1224 | 1224 | |
| 1225 | − sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], | |
| 1226 | − lockdep_is_held(&mvm->mutex)); | |
| 1225 | + sta = rcu_dereference_check(mvm->fw_id_to_mac_id[sta_id], | |
| 1226 | + lockdep_is_held(&mvm->mutex)); | |
| 1227 | 1227 | /* |
| 1228 | 1228 | * It is possible that the 'sta' parameter is NULL, |
| 1229 | 1229 | * for example when a GTK is removed - the sta_id will then |
| @@ -1590,14 +1590,15 @@ void iwl_mvm_update_tkip_key(struct iwl_mvm *mvm, · 360 unmodified lines | ||
| 1590 | 1590 | u16 *phase1key) |
| 1591 | 1591 | { |
| 1592 | 1592 | struct iwl_mvm_sta *mvm_sta; |
| 1593 | − u8 sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); | |
| 1593 | + u8 sta_id; | |
| 1594 | 1594 | bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); |
| 1595 | 1595 | |
| 1596 | − if (WARN_ON_ONCE(sta_id == IWL_MVM_STATION_COUNT)) | |
| 1597 | − return; | |
| 1598 | − | |
| 1599 | 1596 | rcu_read_lock(); |
| 1600 | 1597 | |
| 1598 | + sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); | |
| 1599 | + if (WARN_ON_ONCE(sta_id == IWL_MVM_STATION_COUNT)) | |
| 1600 | + goto unlock; | |
| 1601 | + | |
| 1601 | 1602 | if (!sta) { |
| 1602 | 1603 | sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); |
| 1603 | 1604 | if (WARN_ON(IS_ERR_OR_NULL(sta))) { |
| @@ -1609,6 +1610,8 @@ void iwl_mvm_update_tkip_key(struct iwl_mvm *mvm, · 5 unmodified lines | ||
| 1609 | 1610 | mvm_sta = iwl_mvm_sta_from_mac80211(sta); |
| 1610 | 1611 | iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast, |
| 1611 | 1612 | iv32, phase1key, CMD_ASYNC, keyconf->hw_key_idx); |
| 1613 | + | |
| 1614 | + unlock: | |
| 1612 | 1615 | rcu_read_unlock(); |
| 1613 | 1616 | } |
| 1614 | 1617 | |
| @@ -258,18 +258,18 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif_queue *queue, · 257 unmodified lines | ||
| 258 | 258 | struct netrx_pending_operations *npo) |
| 259 | 259 | { |
| 260 | 260 | struct xenvif_rx_meta *meta; |
| 261 | − struct xen_netif_rx_request *req; | |
| 261 | + struct xen_netif_rx_request req; | |
| 262 | 262 | |
| 263 | − req = RING_GET_REQUEST(&queue->rx, queue->rx.req_cons++); | |
| 263 | + RING_COPY_REQUEST(&queue->rx, queue->rx.req_cons++, &req); | |
| 264 | 264 | |
| 265 | 265 | meta = npo->meta + npo->meta_prod++; |
| 266 | 266 | meta->gso_type = XEN_NETIF_GSO_TYPE_NONE; |
| 267 | 267 | meta->gso_size = 0; |
| 268 | 268 | meta->size = 0; |
| 269 | − meta->id = req->id; | |
| 269 | + meta->id = req.id; | |
| 270 | 270 | |
| 271 | 271 | npo->copy_off = 0; |
| 272 | − npo->copy_gref = req->gref; | |
| 272 | + npo->copy_gref = req.gref; | |
| 273 | 273 | |
| 274 | 274 | return meta; |
| 275 | 275 | } |
| @@ -424,7 +424,7 @@ static int xenvif_gop_skb(struct sk_buff *skb, · 148 unmodified lines | ||
| 424 | 424 | struct xenvif *vif = netdev_priv(skb->dev); |
| 425 | 425 | int nr_frags = skb_shinfo(skb)->nr_frags; |
| 426 | 426 | int i; |
| 427 | − struct xen_netif_rx_request *req; | |
| 427 | + struct xen_netif_rx_request req; | |
| 428 | 428 | struct xenvif_rx_meta *meta; |
| 429 | 429 | unsigned char *data; |
| 430 | 430 | int head = 1; |
| @@ -443,15 +443,15 @@ static int xenvif_gop_skb(struct sk_buff *skb, · 12 unmodified lines | ||
| 443 | 443 | |
| 444 | 444 | /* Set up a GSO prefix descriptor, if necessary */ |
| 445 | 445 | if ((1 << gso_type) & vif->gso_prefix_mask) { |
| 446 | − req = RING_GET_REQUEST(&queue->rx, queue->rx.req_cons++); | |
| 446 | + RING_COPY_REQUEST(&queue->rx, queue->rx.req_cons++, &req); | |
| 447 | 447 | meta = npo->meta + npo->meta_prod++; |
| 448 | 448 | meta->gso_type = gso_type; |
| 449 | 449 | meta->gso_size = skb_shinfo(skb)->gso_size; |
| 450 | 450 | meta->size = 0; |
| 451 | − meta->id = req->id; | |
| 451 | + meta->id = req.id; | |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | − req = RING_GET_REQUEST(&queue->rx, queue->rx.req_cons++); | |
| 454 | + RING_COPY_REQUEST(&queue->rx, queue->rx.req_cons++, &req); | |
| 455 | 455 | meta = npo->meta + npo->meta_prod++; |
| 456 | 456 | |
| 457 | 457 | if ((1 << gso_type) & vif->gso_mask) { |
| @@ -463,9 +463,9 @@ static int xenvif_gop_skb(struct sk_buff *skb, · 5 unmodified lines | ||
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | meta->size = 0; |
| 466 | − meta->id = req->id; | |
| 466 | + meta->id = req.id; | |
| 467 | 467 | npo->copy_off = 0; |
| 468 | − npo->copy_gref = req->gref; | |
| 468 | + npo->copy_gref = req.gref; | |
| 469 | 469 | |
| 470 | 470 | data = skb->data; |
| 471 | 471 | while (data < skb_tail_pointer(skb)) { |
| @@ -679,9 +679,7 @@ static void tx_add_credit(struct xenvif_queue *queue) · 207 unmodified lines | ||
| 679 | 679 | * Allow a burst big enough to transmit a jumbo packet of up to 128kB. |
| 680 | 680 | * Otherwise the interface can seize up due to insufficient credit. |
| 681 | 681 | */ |
| 682 | − max_burst = RING_GET_REQUEST(&queue->tx, queue->tx.req_cons)->size; | |
| 683 | − max_burst = min(max_burst, 131072UL); | |
| 684 | − max_burst = max(max_burst, queue->credit_bytes); | |
| 682 | + max_burst = max(131072UL, queue->credit_bytes); | |
| 685 | 683 | |
| 686 | 684 | /* Take care that adding a new chunk of credit doesn't wrap to zero. */ |
| 687 | 685 | max_credit = queue->remaining_credit + queue->credit_bytes; |
| @@ -711,7 +709,7 @@ static void xenvif_tx_err(struct xenvif_queue *queue, · 23 unmodified lines | ||
| 711 | 709 | spin_unlock_irqrestore(&queue->response_lock, flags); |
| 712 | 710 | if (cons == end) |
| 713 | 711 | break; |
| 714 | − txp = RING_GET_REQUEST(&queue->tx, cons++); | |
| 712 | + RING_COPY_REQUEST(&queue->tx, cons++, txp); | |
| 715 | 713 | } while (1); |
| 716 | 714 | queue->tx.req_cons = cons; |
| 717 | 715 | } |
| @@ -778,8 +776,7 @@ static int xenvif_count_requests(struct xenvif_queue *queue, · 60 unmodified lines | ||
| 778 | 776 | if (drop_err) |
| 779 | 777 | txp = &dropped_tx; |
| 780 | 778 | |
| 781 | − memcpy(txp, RING_GET_REQUEST(&queue->tx, cons + slots), | |
| 782 | − sizeof(*txp)); | |
| 779 | + RING_COPY_REQUEST(&queue->tx, cons + slots, txp); | |
| 783 | 780 | |
| 784 | 781 | /* If the guest submitted a frame >= 64 KiB then |
| 785 | 782 | * first->size overflowed and following slots will |
| @@ -1112,8 +1109,7 @@ static int xenvif_get_extras(struct xenvif_queue *queue, · 326 unmodified lines | ||
| 1112 | 1109 | return -EBADR; |
| 1113 | 1110 | } |
| 1114 | 1111 | |
| 1115 | − memcpy(&extra, RING_GET_REQUEST(&queue->tx, cons), | |
| 1116 | − sizeof(extra)); | |
| 1112 | + RING_COPY_REQUEST(&queue->tx, cons, &extra); | |
| 1117 | 1113 | if (unlikely(!extra.type || |
| 1118 | 1114 | extra.type >= XEN_NETIF_EXTRA_TYPE_MAX)) { |
| 1119 | 1115 | queue->tx.req_cons = ++cons; |
| @@ -1322,7 +1318,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 202 unmodified lines | ||
| 1322 | 1318 | |
| 1323 | 1319 | idx = queue->tx.req_cons; |
| 1324 | 1320 | rmb(); /* Ensure that we see the request before we copy it. */ |
| 1325 | − memcpy(&txreq, RING_GET_REQUEST(&queue->tx, idx), sizeof(txreq)); | |
| 1321 | + RING_COPY_REQUEST(&queue->tx, idx, &txreq); | |
| 1326 | 1322 | |
| 1327 | 1323 | /* Credit-based scheduling. */ |
| 1328 | 1324 | if (txreq.size > queue->remaining_credit && |
| @@ -2540,8 +2540,17 @@ static void nvme_ns_remove(struct nvme_ns *ns) · 2539 unmodified lines | ||
| 2540 | 2540 | { |
| 2541 | 2541 | bool kill = nvme_io_incapable(ns->dev) && !blk_queue_dying(ns->queue); |
| 2542 | 2542 | |
| 2543 | − if (kill) | |
| 2543 | + if (kill) { | |
| 2544 | 2544 | blk_set_queue_dying(ns->queue); |
| 2545 | + | |
| 2546 | + /* | |
| 2547 | + * The controller was shutdown first if we got here through | |
| 2548 | + * device removal. The shutdown may requeue outstanding | |
| 2549 | + * requests. These need to be aborted immediately so | |
| 2550 | + * del_gendisk doesn't block indefinitely for their completion. | |
| 2551 | + */ | |
| 2552 | + blk_mq_abort_requeue_list(ns->queue); | |
| 2553 | + } | |
| 2545 | 2554 | if (ns->disk->flags & GENHD_FL_UP) |
| 2546 | 2555 | del_gendisk(ns->disk); |
| 2547 | 2556 | if (kill || !blk_queue_dying(ns->queue)) { |
| @@ -2977,6 +2986,15 @@ static void nvme_dev_remove(struct nvme_dev *dev) · 429 unmodified lines | ||
| 2977 | 2986 | { |
| 2978 | 2987 | struct nvme_ns *ns, *next; |
| 2979 | 2988 | |
| 2989 | + if (nvme_io_incapable(dev)) { | |
| 2990 | + /* | |
| 2991 | + * If the device is not capable of IO (surprise hot-removal, | |
| 2992 | + * for example), we need to quiesce prior to deleting the | |
| 2993 | + * namespaces. This will end outstanding requests and prevent | |
| 2994 | + * attempts to sync dirty data. | |
| 2995 | + */ | |
| 2996 | + nvme_dev_shutdown(dev); | |
| 2997 | + } | |
| 2980 | 2998 | list_for_each_entry_safe(ns, next, &dev->namespaces, list) |
| 2981 | 2999 | nvme_ns_remove(ns); |
| 2982 | 3000 | } |
| @@ -5,6 +5,7 @@ config PCI_DRA7XX · 4 unmodified lines | ||
| 5 | 5 | bool "TI DRA7xx PCIe controller" |
| 6 | 6 | select PCIE_DW |
| 7 | 7 | depends on OF && HAS_IOMEM && TI_PIPE3 |
| 8 | + depends on BROKEN | |
| 8 | 9 | help |
| 9 | 10 | Enables support for the PCIe controller in the DRA7xx SoC. There |
| 10 | 11 | are two instances of PCIe controller in DRA7xx. This controller can |
| @@ -61,7 +61,9 @@ static int hisi_pcie_cfg_read(struct pcie_port *pp, int where, int size, · 60 unmodified lines | ||
| 61 | 61 | *val = *(u8 __force *) walker; |
| 62 | 62 | else if (size == 2) |
| 63 | 63 | *val = *(u16 __force *) walker; |
| 64 | − else if (size != 4) | |
| 64 | + else if (size == 4) | |
| 65 | + *val = reg_val; | |
| 66 | + else | |
| 65 | 67 | return PCIBIOS_BAD_REGISTER_NUMBER; |
| 66 | 68 | |
| 67 | 69 | return PCIBIOS_SUCCESSFUL; |
| @@ -233,6 +233,7 @@ config PHY_SUN9I_USB · 232 unmodified lines | ||
| 233 | 233 | tristate "Allwinner sun9i SoC USB PHY driver" |
| 234 | 234 | depends on ARCH_SUNXI && HAS_IOMEM && OF |
| 235 | 235 | depends on RESET_CONTROLLER |
| 236 | + depends on USB_COMMON | |
| 236 | 237 | select GENERIC_PHY |
| 237 | 238 | help |
| 238 | 239 | Enable this to support the transceiver that is part of Allwinner |
| @@ -128,6 +128,7 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev) · 127 unmodified lines | ||
| 128 | 128 | struct phy_provider *provider; |
| 129 | 129 | struct resource *res; |
| 130 | 130 | unsigned cnt = 0; |
| 131 | + int ret; | |
| 131 | 132 | |
| 132 | 133 | if (of_get_child_count(node) == 0) { |
| 133 | 134 | dev_err(dev, "PHY no child node\n"); |
| @@ -154,24 +155,28 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev) · 20 unmodified lines | ||
| 154 | 155 | if (of_property_read_u32(child, "reg", &id)) { |
| 155 | 156 | dev_err(dev, "missing reg property for %s\n", |
| 156 | 157 | child->name); |
| 157 | − return -EINVAL; | |
| 158 | + ret = -EINVAL; | |
| 159 | + goto put_child; | |
| 158 | 160 | } |
| 159 | 161 | |
| 160 | 162 | if (id >= MAX_NUM_PHYS) { |
| 161 | 163 | dev_err(dev, "invalid PHY id: %u\n", id); |
| 162 | − return -EINVAL; | |
| 164 | + ret = -EINVAL; | |
| 165 | + goto put_child; | |
| 163 | 166 | } |
| 164 | 167 | |
| 165 | 168 | if (core->phys[id].phy) { |
| 166 | 169 | dev_err(dev, "duplicated PHY id: %u\n", id); |
| 167 | − return -EINVAL; | |
| 170 | + ret = -EINVAL; | |
| 171 | + goto put_child; | |
| 168 | 172 | } |
| 169 | 173 | |
| 170 | 174 | p = &core->phys[id]; |
| 171 | 175 | p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); |
| 172 | 176 | if (IS_ERR(p->phy)) { |
| 173 | 177 | dev_err(dev, "failed to create PHY\n"); |
| 174 | − return PTR_ERR(p->phy); | |
| 178 | + ret = PTR_ERR(p->phy); | |
| 179 | + goto put_child; | |
| 175 | 180 | } |
| 176 | 181 | |
| 177 | 182 | p->core = core; |
| @@ -191,6 +196,9 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev) · 13 unmodified lines | ||
| 191 | 196 | dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); |
| 192 | 197 | |
| 193 | 198 | return 0; |
| 199 | +put_child: | |
| 200 | + of_node_put(child); | |
| 201 | + return ret; | |
| 194 | 202 | } |
| 195 | 203 | |
| 196 | 204 | static const struct of_device_id cygnus_pcie_phy_match_table[] = { |
| @@ -195,7 +195,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev) · 194 unmodified lines | ||
| 195 | 195 | struct phy_provider *phy_provider; |
| 196 | 196 | struct phy_berlin_priv *priv; |
| 197 | 197 | struct resource *res; |
| 198 | − int i = 0; | |
| 198 | + int ret, i = 0; | |
| 199 | 199 | u32 phy_id; |
| 200 | 200 | |
| 201 | 201 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| @@ -237,22 +237,27 @@ static int phy_berlin_sata_probe(struct platform_device *pdev) · 35 unmodified lines | ||
| 237 | 237 | if (of_property_read_u32(child, "reg", &phy_id)) { |
| 238 | 238 | dev_err(dev, "missing reg property in node %s\n", |
| 239 | 239 | child->name); |
| 240 | − return -EINVAL; | |
| 240 | + ret = -EINVAL; | |
| 241 | + goto put_child; | |
| 241 | 242 | } |
| 242 | 243 | |
| 243 | 244 | if (phy_id >= ARRAY_SIZE(phy_berlin_power_down_bits)) { |
| 244 | 245 | dev_err(dev, "invalid reg in node %s\n", child->name); |
| 245 | − return -EINVAL; | |
| 246 | + ret = -EINVAL; | |
| 247 | + goto put_child; | |
| 246 | 248 | } |
| 247 | 249 | |
| 248 | 250 | phy_desc = devm_kzalloc(dev, sizeof(*phy_desc), GFP_KERNEL); |
| 249 | − if (!phy_desc) | |
| 250 | − return -ENOMEM; | |
| 251 | + if (!phy_desc) { | |
| 252 | + ret = -ENOMEM; | |
| 253 | + goto put_child; | |
| 254 | + } | |
| 251 | 255 | |
| 252 | 256 | phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops); |
| 253 | 257 | if (IS_ERR(phy)) { |
| 254 | 258 | dev_err(dev, "failed to create PHY %d\n", phy_id); |
| 255 | − return PTR_ERR(phy); | |
| 259 | + ret = PTR_ERR(phy); | |
| 260 | + goto put_child; | |
| 256 | 261 | } |
| 257 | 262 | |
| 258 | 263 | phy_desc->phy = phy; |
| @@ -269,6 +274,9 @@ static int phy_berlin_sata_probe(struct platform_device *pdev) · 10 unmodified lines | ||
| 269 | 274 | phy_provider = |
| 270 | 275 | devm_of_phy_provider_register(dev, phy_berlin_sata_phy_xlate); |
| 271 | 276 | return PTR_ERR_OR_ZERO(phy_provider); |
| 277 | +put_child: | |
| 278 | + of_node_put(child); | |
| 279 | + return ret; | |
| 272 | 280 | } |
| 273 | 281 | |
| 274 | 282 | static const struct of_device_id phy_berlin_sata_of_match[] = { |
| @@ -140,7 +140,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) · 139 unmodified lines | ||
| 140 | 140 | struct brcm_sata_phy *priv; |
| 141 | 141 | struct resource *res; |
| 142 | 142 | struct phy_provider *provider; |
| 143 | − int count = 0; | |
| 143 | + int ret, count = 0; | |
| 144 | 144 | |
| 145 | 145 | if (of_get_child_count(dn) == 0) |
| 146 | 146 | return -ENODEV; |
| @@ -163,16 +163,19 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) · 16 unmodified lines | ||
| 163 | 163 | if (of_property_read_u32(child, "reg", &id)) { |
| 164 | 164 | dev_err(dev, "missing reg property in node %s\n", |
| 165 | 165 | child->name); |
| 166 | − return -EINVAL; | |
| 166 | + ret = -EINVAL; | |
| 167 | + goto put_child; | |
| 167 | 168 | } |
| 168 | 169 | |
| 169 | 170 | if (id >= MAX_PORTS) { |
| 170 | 171 | dev_err(dev, "invalid reg: %u\n", id); |
| 171 | − return -EINVAL; | |
| 172 | + ret = -EINVAL; | |
| 173 | + goto put_child; | |
| 172 | 174 | } |
| 173 | 175 | if (priv->phys[id].phy) { |
| 174 | 176 | dev_err(dev, "already registered port %u\n", id); |
| 175 | − return -EINVAL; | |
| 177 | + ret = -EINVAL; | |
| 178 | + goto put_child; | |
| 176 | 179 | } |
| 177 | 180 | |
| 178 | 181 | port = &priv->phys[id]; |
| @@ -182,7 +185,8 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 182 | 185 | port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); |
| 183 | 186 | if (IS_ERR(port->phy)) { |
| 184 | 187 | dev_err(dev, "failed to create PHY\n"); |
| 185 | − return PTR_ERR(port->phy); | |
| 188 | + ret = PTR_ERR(port->phy); | |
| 189 | + goto put_child; | |
| 186 | 190 | } |
| 187 | 191 | |
| 188 | 192 | phy_set_drvdata(port->phy, port); |
| @@ -198,6 +202,9 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) · 9 unmodified lines | ||
| 198 | 202 | dev_info(dev, "registered %d port(s)\n", count); |
| 199 | 203 | |
| 200 | 204 | return 0; |
| 205 | +put_child: | |
| 206 | + of_node_put(child); | |
| 207 | + return ret; | |
| 201 | 208 | } |
| 202 | 209 | |
| 203 | 210 | static struct platform_driver brcm_sata_phy_driver = { |
| @@ -636,8 +636,9 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get); · 635 unmodified lines | ||
| 636 | 636 | * @np: node containing the phy |
| 637 | 637 | * @index: index of the phy |
| 638 | 638 | * |
| 639 | − * Gets the phy using _of_phy_get(), and associates a device with it using | |
| 640 | − * devres. On driver detach, release function is invoked on the devres data, | |
| 639 | + * Gets the phy using _of_phy_get(), then gets a refcount to it, | |
| 640 | + * and associates a device with it using devres. On driver detach, | |
| 641 | + * release function is invoked on the devres data, | |
| 641 | 642 | * then, devres data is freed. |
| 642 | 643 | * |
| 643 | 644 | */ |
| @@ -651,13 +652,21 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, · 7 unmodified lines | ||
| 651 | 652 | return ERR_PTR(-ENOMEM); |
| 652 | 653 | |
| 653 | 654 | phy = _of_phy_get(np, index); |
| 654 | − if (!IS_ERR(phy)) { | |
| 655 | − *ptr = phy; | |
| 656 | − devres_add(dev, ptr); | |
| 657 | − } else { | |
| 655 | + if (IS_ERR(phy)) { | |
| 658 | 656 | devres_free(ptr); |
| 657 | + return phy; | |
| 659 | 658 | } |
| 660 | 659 | |
| 660 | + if (!try_module_get(phy->ops->owner)) { | |
| 661 | + devres_free(ptr); | |
| 662 | + return ERR_PTR(-EPROBE_DEFER); | |
| 663 | + } | |
| 664 | + | |
| 665 | + get_device(&phy->dev); | |
| 666 | + | |
| 667 | + *ptr = phy; | |
| 668 | + devres_add(dev, ptr); | |
| 669 | + | |
| 661 | 670 | return phy; |
| 662 | 671 | } |
| 663 | 672 | EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index); |
| @@ -1226,15 +1226,18 @@ static int miphy28lp_probe(struct platform_device *pdev) · 1225 unmodified lines | ||
| 1226 | 1226 | |
| 1227 | 1227 | miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy), |
| 1228 | 1228 | GFP_KERNEL); |
| 1229 | − if (!miphy_phy) | |
| 1230 | − return -ENOMEM; | |
| 1229 | + if (!miphy_phy) { | |
| 1230 | + ret = -ENOMEM; | |
| 1231 | + goto put_child; | |
| 1232 | + } | |
| 1231 | 1233 | |
| 1232 | 1234 | miphy_dev->phys[port] = miphy_phy; |
| 1233 | 1235 | |
| 1234 | 1236 | phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops); |
| 1235 | 1237 | if (IS_ERR(phy)) { |
| 1236 | 1238 | dev_err(&pdev->dev, "failed to create PHY\n"); |
| 1237 | − return PTR_ERR(phy); | |
| 1239 | + ret = PTR_ERR(phy); | |
| 1240 | + goto put_child; | |
| 1238 | 1241 | } |
| 1239 | 1242 | |
| 1240 | 1243 | miphy_dev->phys[port]->phy = phy; |
| @@ -1242,11 +1245,11 @@ static int miphy28lp_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 1242 | 1245 | |
| 1243 | 1246 | ret = miphy28lp_of_probe(child, miphy_phy); |
| 1244 | 1247 | if (ret) |
| 1245 | − return ret; | |
| 1248 | + goto put_child; | |
| 1246 | 1249 | |
| 1247 | 1250 | ret = miphy28lp_probe_resets(child, miphy_dev->phys[port]); |
| 1248 | 1251 | if (ret) |
| 1249 | − return ret; | |
| 1252 | + goto put_child; | |
| 1250 | 1253 | |
| 1251 | 1254 | phy_set_drvdata(phy, miphy_dev->phys[port]); |
| 1252 | 1255 | port++; |
| @@ -1255,6 +1258,9 @@ static int miphy28lp_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 1255 | 1258 | |
| 1256 | 1259 | provider = devm_of_phy_provider_register(&pdev->dev, miphy28lp_xlate); |
| 1257 | 1260 | return PTR_ERR_OR_ZERO(provider); |
| 1261 | +put_child: | |
| 1262 | + of_node_put(child); | |
| 1263 | + return ret; | |
| 1258 | 1264 | } |
| 1259 | 1265 | |
| 1260 | 1266 | static const struct of_device_id miphy28lp_of_match[] = { |
| @@ -566,22 +566,25 @@ static int miphy365x_probe(struct platform_device *pdev) · 565 unmodified lines | ||
| 566 | 566 | |
| 567 | 567 | miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy), |
| 568 | 568 | GFP_KERNEL); |
| 569 | − if (!miphy_phy) | |
| 570 | − return -ENOMEM; | |
| 569 | + if (!miphy_phy) { | |
| 570 | + ret = -ENOMEM; | |
| 571 | + goto put_child; | |
| 572 | + } | |
| 571 | 573 | |
| 572 | 574 | miphy_dev->phys[port] = miphy_phy; |
| 573 | 575 | |
| 574 | 576 | phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops); |
| 575 | 577 | if (IS_ERR(phy)) { |
| 576 | 578 | dev_err(&pdev->dev, "failed to create PHY\n"); |
| 577 | − return PTR_ERR(phy); | |
| 579 | + ret = PTR_ERR(phy); | |
| 580 | + goto put_child; | |
| 578 | 581 | } |
| 579 | 582 | |
| 580 | 583 | miphy_dev->phys[port]->phy = phy; |
| 581 | 584 | |
| 582 | 585 | ret = miphy365x_of_probe(child, miphy_phy); |
| 583 | 586 | if (ret) |
| 584 | − return ret; | |
| 587 | + goto put_child; | |
| 585 | 588 | |
| 586 | 589 | phy_set_drvdata(phy, miphy_dev->phys[port]); |
| 587 | 590 | |
| @@ -591,12 +594,15 @@ static int miphy365x_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 591 | 594 | &miphy_phy->ctrlreg); |
| 592 | 595 | if (ret) { |
| 593 | 596 | dev_err(&pdev->dev, "No sysconfig offset found\n"); |
| 594 | − return ret; | |
| 597 | + goto put_child; | |
| 595 | 598 | } |
| 596 | 599 | } |
| 597 | 600 | |
| 598 | 601 | provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate); |
| 599 | 602 | return PTR_ERR_OR_ZERO(provider); |
| 603 | +put_child: | |
| 604 | + of_node_put(child); | |
| 605 | + return ret; | |
| 600 | 606 | } |
| 601 | 607 | |
| 602 | 608 | static const struct of_device_id miphy365x_of_match[] = { |
| @@ -415,7 +415,7 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) · 414 unmodified lines | ||
| 415 | 415 | struct resource *sif_res; |
| 416 | 416 | struct mt65xx_u3phy *u3phy; |
| 417 | 417 | struct resource res; |
| 418 | − int port; | |
| 418 | + int port, retval; | |
| 419 | 419 | |
| 420 | 420 | u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); |
| 421 | 421 | if (!u3phy) |
| @@ -447,31 +447,34 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) · 25 unmodified lines | ||
| 447 | 447 | for_each_child_of_node(np, child_np) { |
| 448 | 448 | struct mt65xx_phy_instance *instance; |
| 449 | 449 | struct phy *phy; |
| 450 | − int retval; | |
| 451 | 450 | |
| 452 | 451 | instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); |
| 453 | − if (!instance) | |
| 454 | − return -ENOMEM; | |
| 452 | + if (!instance) { | |
| 453 | + retval = -ENOMEM; | |
| 454 | + goto put_child; | |
| 455 | + } | |
| 455 | 456 | |
| 456 | 457 | u3phy->phys[port] = instance; |
| 457 | 458 | |
| 458 | 459 | phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops); |
| 459 | 460 | if (IS_ERR(phy)) { |
| 460 | 461 | dev_err(dev, "failed to create phy\n"); |
| 461 | − return PTR_ERR(phy); | |
| 462 | + retval = PTR_ERR(phy); | |
| 463 | + goto put_child; | |
| 462 | 464 | } |
| 463 | 465 | |
| 464 | 466 | retval = of_address_to_resource(child_np, 0, &res); |
| 465 | 467 | if (retval) { |
| 466 | 468 | dev_err(dev, "failed to get address resource(id-%d)\n", |
| 467 | 469 | port); |
| 468 | − return retval; | |
| 470 | + goto put_child; | |
| 469 | 471 | } |
| 470 | 472 | |
| 471 | 473 | instance->port_base = devm_ioremap_resource(&phy->dev, &res); |
| 472 | 474 | if (IS_ERR(instance->port_base)) { |
| 473 | 475 | dev_err(dev, "failed to remap phy regs\n"); |
| 474 | − return PTR_ERR(instance->port_base); | |
| 476 | + retval = PTR_ERR(instance->port_base); | |
| 477 | + goto put_child; | |
| 475 | 478 | } |
| 476 | 479 | |
| 477 | 480 | instance->phy = phy; |
| @@ -483,6 +486,9 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 483 | 486 | provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate); |
| 484 | 487 | |
| 485 | 488 | return PTR_ERR_OR_ZERO(provider); |
| 489 | +put_child: | |
| 490 | + of_node_put(child_np); | |
| 491 | + return retval; | |
| 486 | 492 | } |
| 487 | 493 | |
| 488 | 494 | static const struct of_device_id mt65xx_u3phy_id_table[] = { |
| @@ -108,13 +108,16 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) · 107 unmodified lines | ||
| 108 | 108 | |
| 109 | 109 | for_each_available_child_of_node(dev->of_node, child) { |
| 110 | 110 | rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL); |
| 111 | − if (!rk_phy) | |
| 112 | − return -ENOMEM; | |
| 111 | + if (!rk_phy) { | |
| 112 | + err = -ENOMEM; | |
| 113 | + goto put_child; | |
| 114 | + } | |
| 113 | 115 | |
| 114 | 116 | if (of_property_read_u32(child, "reg", ®_offset)) { |
| 115 | 117 | dev_err(dev, "missing reg property in node %s\n", |
| 116 | 118 | child->name); |
| 117 | − return -EINVAL; | |
| 119 | + err = -EINVAL; | |
| 120 | + goto put_child; | |
| 118 | 121 | } |
| 119 | 122 | |
| 120 | 123 | rk_phy->reg_offset = reg_offset; |
| @@ -127,18 +130,22 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev) · 6 unmodified lines | ||
| 127 | 130 | rk_phy->phy = devm_phy_create(dev, child, &ops); |
| 128 | 131 | if (IS_ERR(rk_phy->phy)) { |
| 129 | 132 | dev_err(dev, "failed to create PHY\n"); |
| 130 | − return PTR_ERR(rk_phy->phy); | |
| 133 | + err = PTR_ERR(rk_phy->phy); | |
| 134 | + goto put_child; | |
| 131 | 135 | } |
| 132 | 136 | phy_set_drvdata(rk_phy->phy, rk_phy); |
| 133 | 137 | |
| 134 | 138 | /* only power up usb phy when it use, so disable it when init*/ |
| 135 | 139 | err = rockchip_usb_phy_power(rk_phy, 1); |
| 136 | 140 | if (err) |
| 137 | − return err; | |
| 141 | + goto put_child; | |
| 138 | 142 | } |
| 139 | 143 | |
| 140 | 144 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); |
| 141 | 145 | return PTR_ERR_OR_ZERO(phy_provider); |
| 146 | +put_child: | |
| 147 | + of_node_put(child); | |
| 148 | + return err; | |
| 142 | 149 | } |
| 143 | 150 | |
| 144 | 151 | static const struct of_device_id rockchip_usb_phy_dt_ids[] = { |
| @@ -342,12 +342,6 @@ static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset) · 341 unmodified lines | ||
| 342 | 342 | return bcm2835_gpio_get_bit(pc, GPLEV0, offset); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | −static int bcm2835_gpio_direction_output(struct gpio_chip *chip, | |
| 346 | − unsigned offset, int value) | |
| 347 | −{ | |
| 348 | − return pinctrl_gpio_direction_output(chip->base + offset); | |
| 349 | −} | |
| 350 | − | |
| 351 | 345 | static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
| 352 | 346 | { |
| 353 | 347 | struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->dev); |
| @@ -355,6 +349,13 @@ static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) · 1 unmodified line | ||
| 355 | 349 | bcm2835_gpio_set_bit(pc, value ? GPSET0 : GPCLR0, offset); |
| 356 | 350 | } |
| 357 | 351 | |
| 352 | +static int bcm2835_gpio_direction_output(struct gpio_chip *chip, | |
| 353 | + unsigned offset, int value) | |
| 354 | +{ | |
| 355 | + bcm2835_gpio_set(chip, offset, value); | |
| 356 | + return pinctrl_gpio_direction_output(chip->base + offset); | |
| 357 | +} | |
| 358 | + | |
| 358 | 359 | static int bcm2835_gpio_to_irq(struct gpio_chip *chip, unsigned offset) |
| 359 | 360 | { |
| 360 | 361 | struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->dev); |
| @@ -299,7 +299,7 @@ static const struct pinctrl_pin_desc vf610_pinctrl_pads[] = { · 298 unmodified lines | ||
| 299 | 299 | static struct imx_pinctrl_soc_info vf610_pinctrl_info = { |
| 300 | 300 | .pins = vf610_pinctrl_pads, |
| 301 | 301 | .npins = ARRAY_SIZE(vf610_pinctrl_pads), |
| 302 | − .flags = SHARE_MUX_CONF_REG, | |
| 302 | + .flags = SHARE_MUX_CONF_REG | ZERO_OFFSET_VALID, | |
| 303 | 303 | }; |
| 304 | 304 | |
| 305 | 305 | static const struct of_device_id vf610_pinctrl_of_match[] = { |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 28 | 28 | .padcfglock_offset = BXT_PADCFGLOCK, \ |
| 29 | 29 | .hostown_offset = BXT_HOSTSW_OWN, \ |
| 30 | 30 | .ie_offset = BXT_GPI_IE, \ |
| 31 | + .gpp_size = 32, \ | |
| 31 | 32 | .pin_base = (s), \ |
| 32 | 33 | .npins = ((e) - (s) + 1), \ |
| 33 | 34 | } |
| @@ -25,9 +25,6 @@ · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | #include "pinctrl-intel.h" |
| 27 | 27 | |
| 28 | −/* Maximum number of pads in each group */ | |
| 29 | −#define NPADS_IN_GPP 24 | |
| 30 | − | |
| 31 | 28 | /* Offset from regs */ |
| 32 | 29 | #define PADBAR 0x00c |
| 33 | 30 | #define GPI_IS 0x100 |
| @@ -37,6 +34,7 @@ · 3 unmodified lines | ||
| 37 | 34 | #define PADOWN_BITS 4 |
| 38 | 35 | #define PADOWN_SHIFT(p) ((p) % 8 * PADOWN_BITS) |
| 39 | 36 | #define PADOWN_MASK(p) (0xf << PADOWN_SHIFT(p)) |
| 37 | +#define PADOWN_GPP(p) ((p) / 8) | |
| 40 | 38 | |
| 41 | 39 | /* Offset from pad_regs */ |
| 42 | 40 | #define PADCFG0 0x000 |
| @@ -142,7 +140,7 @@ static void __iomem *intel_get_padcfg(struct intel_pinctrl *pctrl, unsigned pin, · 99 unmodified lines | ||
| 142 | 140 | static bool intel_pad_owned_by_host(struct intel_pinctrl *pctrl, unsigned pin) |
| 143 | 141 | { |
| 144 | 142 | const struct intel_community *community; |
| 145 | − unsigned padno, gpp, gpp_offset, offset; | |
| 143 | + unsigned padno, gpp, offset, group; | |
| 146 | 144 | void __iomem *padown; |
| 147 | 145 | |
| 148 | 146 | community = intel_get_community(pctrl, pin); |
| @@ -152,9 +150,9 @@ static bool intel_pad_owned_by_host(struct intel_pinctrl *pctrl, unsigned pin) · 3 unmodified lines | ||
| 152 | 150 | return true; |
| 153 | 151 | |
| 154 | 152 | padno = pin_to_padno(community, pin); |
| 155 | − gpp = padno / NPADS_IN_GPP; | |
| 156 | − gpp_offset = padno % NPADS_IN_GPP; | |
| 157 | − offset = community->padown_offset + gpp * 16 + (gpp_offset / 8) * 4; | |
| 153 | + group = padno / community->gpp_size; | |
| 154 | + gpp = PADOWN_GPP(padno % community->gpp_size); | |
| 155 | + offset = community->padown_offset + 0x10 * group + gpp * 4; | |
| 158 | 156 | padown = community->regs + offset; |
| 159 | 157 | |
| 160 | 158 | return !(readl(padown) & PADOWN_MASK(padno)); |
| @@ -173,11 +171,11 @@ static bool intel_pad_acpi_mode(struct intel_pinctrl *pctrl, unsigned pin) · 12 unmodified lines | ||
| 173 | 171 | return false; |
| 174 | 172 | |
| 175 | 173 | padno = pin_to_padno(community, pin); |
| 176 | − gpp = padno / NPADS_IN_GPP; | |
| 174 | + gpp = padno / community->gpp_size; | |
| 177 | 175 | offset = community->hostown_offset + gpp * 4; |
| 178 | 176 | hostown = community->regs + offset; |
| 179 | 177 | |
| 180 | − return !(readl(hostown) & BIT(padno % NPADS_IN_GPP)); | |
| 178 | + return !(readl(hostown) & BIT(padno % community->gpp_size)); | |
| 181 | 179 | } |
| 182 | 180 | |
| 183 | 181 | static bool intel_pad_locked(struct intel_pinctrl *pctrl, unsigned pin) |
| @@ -193,7 +191,7 @@ static bool intel_pad_locked(struct intel_pinctrl *pctrl, unsigned pin) · 9 unmodified lines | ||
| 193 | 191 | return false; |
| 194 | 192 | |
| 195 | 193 | padno = pin_to_padno(community, pin); |
| 196 | − gpp = padno / NPADS_IN_GPP; | |
| 194 | + gpp = padno / community->gpp_size; | |
| 197 | 195 | |
| 198 | 196 | /* |
| 199 | 197 | * If PADCFGLOCK and PADCFGLOCKTX bits are both clear for this pad, |
| @@ -202,12 +200,12 @@ static bool intel_pad_locked(struct intel_pinctrl *pctrl, unsigned pin) · 2 unmodified lines | ||
| 202 | 200 | */ |
| 203 | 201 | offset = community->padcfglock_offset + gpp * 8; |
| 204 | 202 | value = readl(community->regs + offset); |
| 205 | − if (value & BIT(pin % NPADS_IN_GPP)) | |
| 203 | + if (value & BIT(pin % community->gpp_size)) | |
| 206 | 204 | return true; |
| 207 | 205 | |
| 208 | 206 | offset = community->padcfglock_offset + 4 + gpp * 8; |
| 209 | 207 | value = readl(community->regs + offset); |
| 210 | − if (value & BIT(pin % NPADS_IN_GPP)) | |
| 208 | + if (value & BIT(pin % community->gpp_size)) | |
| 211 | 209 | return true; |
| 212 | 210 | |
| 213 | 211 | return false; |
| @@ -663,8 +661,8 @@ static void intel_gpio_irq_ack(struct irq_data *d) · 449 unmodified lines | ||
| 663 | 661 | community = intel_get_community(pctrl, pin); |
| 664 | 662 | if (community) { |
| 665 | 663 | unsigned padno = pin_to_padno(community, pin); |
| 666 | − unsigned gpp_offset = padno % NPADS_IN_GPP; | |
| 667 | − unsigned gpp = padno / NPADS_IN_GPP; | |
| 664 | + unsigned gpp_offset = padno % community->gpp_size; | |
| 665 | + unsigned gpp = padno / community->gpp_size; | |
| 668 | 666 | |
| 669 | 667 | writel(BIT(gpp_offset), community->regs + GPI_IS + gpp * 4); |
| 670 | 668 | } |
| @@ -685,8 +683,8 @@ static void intel_gpio_irq_mask_unmask(struct irq_data *d, bool mask) · 14 unmodified lines | ||
| 685 | 683 | community = intel_get_community(pctrl, pin); |
| 686 | 684 | if (community) { |
| 687 | 685 | unsigned padno = pin_to_padno(community, pin); |
| 688 | − unsigned gpp_offset = padno % NPADS_IN_GPP; | |
| 689 | − unsigned gpp = padno / NPADS_IN_GPP; | |
| 686 | + unsigned gpp_offset = padno % community->gpp_size; | |
| 687 | + unsigned gpp = padno / community->gpp_size; | |
| 690 | 688 | void __iomem *reg; |
| 691 | 689 | u32 value; |
| 692 | 690 | |
| @@ -780,8 +778,8 @@ static int intel_gpio_irq_wake(struct irq_data *d, unsigned int on) · 87 unmodified lines | ||
| 780 | 778 | return -EINVAL; |
| 781 | 779 | |
| 782 | 780 | padno = pin_to_padno(community, pin); |
| 783 | − gpp = padno / NPADS_IN_GPP; | |
| 784 | − gpp_offset = padno % NPADS_IN_GPP; | |
| 781 | + gpp = padno / community->gpp_size; | |
| 782 | + gpp_offset = padno % community->gpp_size; | |
| 785 | 783 | |
| 786 | 784 | /* Clear the existing wake status */ |
| 787 | 785 | writel(BIT(gpp_offset), community->regs + GPI_GPE_STS + gpp * 4); |
| @@ -819,14 +817,14 @@ static irqreturn_t intel_gpio_community_irq_handler(struct intel_pinctrl *pctrl, · 31 unmodified lines | ||
| 819 | 817 | /* Only interrupts that are enabled */ |
| 820 | 818 | pending &= enabled; |
| 821 | 819 | |
| 822 | − for_each_set_bit(gpp_offset, &pending, NPADS_IN_GPP) { | |
| 820 | + for_each_set_bit(gpp_offset, &pending, community->gpp_size) { | |
| 823 | 821 | unsigned padno, irq; |
| 824 | 822 | |
| 825 | 823 | /* |
| 826 | 824 | * The last group in community can have less pins |
| 827 | 825 | * than NPADS_IN_GPP. |
| 828 | 826 | */ |
| 829 | − padno = gpp_offset + gpp * NPADS_IN_GPP; | |
| 827 | + padno = gpp_offset + gpp * community->gpp_size; | |
| 830 | 828 | if (padno >= community->npins) |
| 831 | 829 | break; |
| 832 | 830 | |
| @@ -1002,7 +1000,8 @@ int intel_pinctrl_probe(struct platform_device *pdev, · 169 unmodified lines | ||
| 1002 | 1000 | |
| 1003 | 1001 | community->regs = regs; |
| 1004 | 1002 | community->pad_regs = regs + padbar; |
| 1005 | − community->ngpps = DIV_ROUND_UP(community->npins, NPADS_IN_GPP); | |
| 1003 | + community->ngpps = DIV_ROUND_UP(community->npins, | |
| 1004 | + community->gpp_size); | |
| 1006 | 1005 | } |
| 1007 | 1006 | |
| 1008 | 1007 | irq = platform_get_irq(pdev, 0); |
| @@ -55,6 +55,8 @@ struct intel_function { · 54 unmodified lines | ||
| 55 | 55 | * ACPI). |
| 56 | 56 | * @ie_offset: Register offset of GPI_IE from @regs. |
| 57 | 57 | * @pin_base: Starting pin of pins in this community |
| 58 | + * @gpp_size: Maximum number of pads in each group, such as PADCFGLOCK, | |
| 59 | + * HOSTSW_OWN, GPI_IS, GPI_IE, etc. | |
| 58 | 60 | * @npins: Number of pins in this community |
| 59 | 61 | * @regs: Community specific common registers (reserved for core driver) |
| 60 | 62 | * @pad_regs: Community specific pad registers (reserved for core driver) |
| @@ -68,6 +70,7 @@ struct intel_community { · 7 unmodified lines | ||
| 68 | 70 | unsigned hostown_offset; |
| 69 | 71 | unsigned ie_offset; |
| 70 | 72 | unsigned pin_base; |
| 73 | + unsigned gpp_size; | |
| 71 | 74 | size_t npins; |
| 72 | 75 | void __iomem *regs; |
| 73 | 76 | void __iomem *pad_regs; |
| @@ -30,6 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | .padcfglock_offset = SPT_PADCFGLOCK, \ |
| 31 | 31 | .hostown_offset = SPT_HOSTSW_OWN, \ |
| 32 | 32 | .ie_offset = SPT_GPI_IE, \ |
| 33 | + .gpp_size = 24, \ | |
| 33 | 34 | .pin_base = (s), \ |
| 34 | 35 | .npins = ((e) - (s) + 1), \ |
| 35 | 36 | } |
| @@ -1341,10 +1341,13 @@ static int rapl_detect_domains(struct rapl_package *rp, int cpu) · 1340 unmodified lines | ||
| 1341 | 1341 | |
| 1342 | 1342 | for (rd = rp->domains; rd < rp->domains + rp->nr_domains; rd++) { |
| 1343 | 1343 | /* check if the domain is locked by BIOS */ |
| 1344 | − if (rapl_read_data_raw(rd, FW_LOCK, false, &locked)) { | |
| 1344 | + ret = rapl_read_data_raw(rd, FW_LOCK, false, &locked); | |
| 1345 | + if (ret) | |
| 1346 | + return ret; | |
| 1347 | + if (locked) { | |
| 1345 | 1348 | pr_info("RAPL package %d domain %s locked by BIOS\n", |
| 1346 | 1349 | rp->id, rd->name); |
| 1347 | − rd->state |= DOMAIN_STATE_BIOS_LOCKED; | |
| 1350 | + rd->state |= DOMAIN_STATE_BIOS_LOCKED; | |
| 1348 | 1351 | } |
| 1349 | 1352 | } |
| 1350 | 1353 | |
| @@ -483,24 +483,23 @@ static int da9063_rtc_probe(struct platform_device *pdev) · 482 unmodified lines | ||
| 483 | 483 | |
| 484 | 484 | platform_set_drvdata(pdev, rtc); |
| 485 | 485 | |
| 486 | + rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, DA9063_DRVNAME_RTC, | |
| 487 | + &da9063_rtc_ops, THIS_MODULE); | |
| 488 | + if (IS_ERR(rtc->rtc_dev)) | |
| 489 | + return PTR_ERR(rtc->rtc_dev); | |
| 490 | + | |
| 491 | + da9063_data_to_tm(data, &rtc->alarm_time, rtc); | |
| 492 | + rtc->rtc_sync = false; | |
| 493 | + | |
| 486 | 494 | irq_alarm = platform_get_irq_byname(pdev, "ALARM"); |
| 487 | 495 | ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL, |
| 488 | 496 | da9063_alarm_event, |
| 489 | 497 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
| 490 | 498 | "ALARM", rtc); |
| 491 | − if (ret) { | |
| 499 | + if (ret) | |
| 492 | 500 | dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n", |
| 493 | 501 | irq_alarm, ret); |
| 494 | − return ret; | |
| 495 | − } | |
| 496 | − | |
| 497 | − rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, DA9063_DRVNAME_RTC, | |
| 498 | − &da9063_rtc_ops, THIS_MODULE); | |
| 499 | − if (IS_ERR(rtc->rtc_dev)) | |
| 500 | − return PTR_ERR(rtc->rtc_dev); | |
| 501 | 502 | |
| 502 | − da9063_data_to_tm(data, &rtc->alarm_time, rtc); | |
| 503 | − rtc->rtc_sync = false; | |
| 504 | 503 | return ret; |
| 505 | 504 | } |
| 506 | 505 | |
| @@ -56,6 +56,42 @@ struct rk808_rtc { · 55 unmodified lines | ||
| 56 | 56 | int irq; |
| 57 | 57 | }; |
| 58 | 58 | |
| 59 | +/* | |
| 60 | + * The Rockchip calendar used by the RK808 counts November with 31 days. We use | |
| 61 | + * these translation functions to convert its dates to/from the Gregorian | |
| 62 | + * calendar used by the rest of the world. We arbitrarily define Jan 1st, 2016 | |
| 63 | + * as the day when both calendars were in sync, and treat all other dates | |
| 64 | + * relative to that. | |
| 65 | + * NOTE: Other system software (e.g. firmware) that reads the same hardware must | |
| 66 | + * implement this exact same conversion algorithm, with the same anchor date. | |
| 67 | + */ | |
| 68 | +static time64_t nov2dec_transitions(struct rtc_time *tm) | |
| 69 | +{ | |
| 70 | + return (tm->tm_year + 1900) - 2016 + (tm->tm_mon + 1 > 11 ? 1 : 0); | |
| 71 | +} | |
| 72 | + | |
| 73 | +static void rockchip_to_gregorian(struct rtc_time *tm) | |
| 74 | +{ | |
| 75 | + /* If it's Nov 31st, rtc_tm_to_time64() will count that like Dec 1st */ | |
| 76 | + time64_t time = rtc_tm_to_time64(tm); | |
| 77 | + rtc_time64_to_tm(time + nov2dec_transitions(tm) * 86400, tm); | |
| 78 | +} | |
| 79 | + | |
| 80 | +static void gregorian_to_rockchip(struct rtc_time *tm) | |
| 81 | +{ | |
| 82 | + time64_t extra_days = nov2dec_transitions(tm); | |
| 83 | + time64_t time = rtc_tm_to_time64(tm); | |
| 84 | + rtc_time64_to_tm(time - extra_days * 86400, tm); | |
| 85 | + | |
| 86 | + /* Compensate if we went back over Nov 31st (will work up to 2381) */ | |
| 87 | + if (nov2dec_transitions(tm) < extra_days) { | |
| 88 | + if (tm->tm_mon + 1 == 11) | |
| 89 | + tm->tm_mday++; /* This may result in 31! */ | |
| 90 | + else | |
| 91 | + rtc_time64_to_tm(time - (extra_days - 1) * 86400, tm); | |
| 92 | + } | |
| 93 | +} | |
| 94 | + | |
| 59 | 95 | /* Read current time and date in RTC */ |
| 60 | 96 | static int rk808_rtc_readtime(struct device *dev, struct rtc_time *tm) |
| 61 | 97 | { |
| @@ -101,9 +137,10 @@ static int rk808_rtc_readtime(struct device *dev, struct rtc_time *tm) · 39 unmodified lines | ||
| 101 | 137 | tm->tm_mon = (bcd2bin(rtc_data[4] & MONTHS_REG_MSK)) - 1; |
| 102 | 138 | tm->tm_year = (bcd2bin(rtc_data[5] & YEARS_REG_MSK)) + 100; |
| 103 | 139 | tm->tm_wday = bcd2bin(rtc_data[6] & WEEKS_REG_MSK); |
| 140 | + rockchip_to_gregorian(tm); | |
| 104 | 141 | dev_dbg(dev, "RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n", |
| 105 | 142 | 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, |
| 106 | − tm->tm_wday, tm->tm_hour , tm->tm_min, tm->tm_sec); | |
| 143 | + tm->tm_wday, tm->tm_hour, tm->tm_min, tm->tm_sec); | |
| 107 | 144 | |
| 108 | 145 | return ret; |
| 109 | 146 | } |
| @@ -116,6 +153,10 @@ static int rk808_rtc_set_time(struct device *dev, struct rtc_time *tm) · 6 unmodified lines | ||
| 116 | 153 | u8 rtc_data[NUM_TIME_REGS]; |
| 117 | 154 | int ret; |
| 118 | 155 | |
| 156 | + dev_dbg(dev, "set RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n", | |
| 157 | + 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, | |
| 158 | + tm->tm_wday, tm->tm_hour, tm->tm_min, tm->tm_sec); | |
| 159 | + gregorian_to_rockchip(tm); | |
| 119 | 160 | rtc_data[0] = bin2bcd(tm->tm_sec); |
| 120 | 161 | rtc_data[1] = bin2bcd(tm->tm_min); |
| 121 | 162 | rtc_data[2] = bin2bcd(tm->tm_hour); |
| @@ -123,9 +164,6 @@ static int rk808_rtc_set_time(struct device *dev, struct rtc_time *tm) · 1 unmodified line | ||
| 123 | 164 | rtc_data[4] = bin2bcd(tm->tm_mon + 1); |
| 124 | 165 | rtc_data[5] = bin2bcd(tm->tm_year - 100); |
| 125 | 166 | rtc_data[6] = bin2bcd(tm->tm_wday); |
| 126 | − dev_dbg(dev, "set RTC date/time %4d-%02d-%02d(%d) %02d:%02d:%02d\n", | |
| 127 | − 1900 + tm->tm_year, tm->tm_mon + 1, tm->tm_mday, | |
| 128 | − tm->tm_wday, tm->tm_hour , tm->tm_min, tm->tm_sec); | |
| 129 | 167 | |
| 130 | 168 | /* Stop RTC while updating the RTC registers */ |
| 131 | 169 | ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG, |
| @@ -170,6 +208,7 @@ static int rk808_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) · 38 unmodified lines | ||
| 170 | 208 | alrm->time.tm_mday = bcd2bin(alrm_data[3] & DAYS_REG_MSK); |
| 171 | 209 | alrm->time.tm_mon = (bcd2bin(alrm_data[4] & MONTHS_REG_MSK)) - 1; |
| 172 | 210 | alrm->time.tm_year = (bcd2bin(alrm_data[5] & YEARS_REG_MSK)) + 100; |
| 211 | + rockchip_to_gregorian(&alrm->time); | |
| 173 | 212 | |
| 174 | 213 | ret = regmap_read(rk808->regmap, RK808_RTC_INT_REG, &int_reg); |
| 175 | 214 | if (ret) { |
| @@ -227,6 +266,7 @@ static int rk808_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) · 51 unmodified lines | ||
| 227 | 266 | alrm->time.tm_mday, alrm->time.tm_wday, alrm->time.tm_hour, |
| 228 | 267 | alrm->time.tm_min, alrm->time.tm_sec); |
| 229 | 268 | |
| 269 | + gregorian_to_rockchip(&alrm->time); | |
| 230 | 270 | alrm_data[0] = bin2bcd(alrm->time.tm_sec); |
| 231 | 271 | alrm_data[1] = bin2bcd(alrm->time.tm_min); |
| 232 | 272 | alrm_data[2] = bin2bcd(alrm->time.tm_hour); |
| @@ -599,8 +599,10 @@ static enum ap_wait ap_sm_read(struct ap_device *ap_dev) · 598 unmodified lines | ||
| 599 | 599 | status = ap_sm_recv(ap_dev); |
| 600 | 600 | switch (status.response_code) { |
| 601 | 601 | case AP_RESPONSE_NORMAL: |
| 602 | − if (ap_dev->queue_count > 0) | |
| 602 | + if (ap_dev->queue_count > 0) { | |
| 603 | + ap_dev->state = AP_STATE_WORKING; | |
| 603 | 604 | return AP_WAIT_AGAIN; |
| 605 | + } | |
| 604 | 606 | ap_dev->state = AP_STATE_IDLE; |
| 605 | 607 | return AP_WAIT_NONE; |
| 606 | 608 | case AP_RESPONSE_NO_PENDING_REPLY: |
| @@ -984,6 +984,36 @@ static struct virtqueue *virtio_ccw_vq_by_ind(struct virtio_ccw_device *vcdev, · 983 unmodified lines | ||
| 984 | 984 | return vq; |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | +static void virtio_ccw_check_activity(struct virtio_ccw_device *vcdev, | |
| 988 | + __u32 activity) | |
| 989 | +{ | |
| 990 | + if (vcdev->curr_io & activity) { | |
| 991 | + switch (activity) { | |
| 992 | + case VIRTIO_CCW_DOING_READ_FEAT: | |
| 993 | + case VIRTIO_CCW_DOING_WRITE_FEAT: | |
| 994 | + case VIRTIO_CCW_DOING_READ_CONFIG: | |
| 995 | + case VIRTIO_CCW_DOING_WRITE_CONFIG: | |
| 996 | + case VIRTIO_CCW_DOING_WRITE_STATUS: | |
| 997 | + case VIRTIO_CCW_DOING_SET_VQ: | |
| 998 | + case VIRTIO_CCW_DOING_SET_IND: | |
| 999 | + case VIRTIO_CCW_DOING_SET_CONF_IND: | |
| 1000 | + case VIRTIO_CCW_DOING_RESET: | |
| 1001 | + case VIRTIO_CCW_DOING_READ_VQ_CONF: | |
| 1002 | + case VIRTIO_CCW_DOING_SET_IND_ADAPTER: | |
| 1003 | + case VIRTIO_CCW_DOING_SET_VIRTIO_REV: | |
| 1004 | + vcdev->curr_io &= ~activity; | |
| 1005 | + wake_up(&vcdev->wait_q); | |
| 1006 | + break; | |
| 1007 | + default: | |
| 1008 | + /* don't know what to do... */ | |
| 1009 | + dev_warn(&vcdev->cdev->dev, | |
| 1010 | + "Suspicious activity '%08x'\n", activity); | |
| 1011 | + WARN_ON(1); | |
| 1012 | + break; | |
| 1013 | + } | |
| 1014 | + } | |
| 1015 | +} | |
| 1016 | + | |
| 987 | 1017 | static void virtio_ccw_int_handler(struct ccw_device *cdev, |
| 988 | 1018 | unsigned long intparm, |
| 989 | 1019 | struct irb *irb) |
| @@ -995,6 +1025,12 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev, · 5 unmodified lines | ||
| 995 | 1025 | |
| 996 | 1026 | if (!vcdev) |
| 997 | 1027 | return; |
| 1028 | + if (IS_ERR(irb)) { | |
| 1029 | + vcdev->err = PTR_ERR(irb); | |
| 1030 | + virtio_ccw_check_activity(vcdev, activity); | |
| 1031 | + /* Don't poke around indicators, something's wrong. */ | |
| 1032 | + return; | |
| 1033 | + } | |
| 998 | 1034 | /* Check if it's a notification from the host. */ |
| 999 | 1035 | if ((intparm == 0) && |
| 1000 | 1036 | (scsw_stctl(&irb->scsw) == |
| @@ -1010,31 +1046,7 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev, · 9 unmodified lines | ||
| 1010 | 1046 | /* Map everything else to -EIO. */ |
| 1011 | 1047 | vcdev->err = -EIO; |
| 1012 | 1048 | } |
| 1013 | − if (vcdev->curr_io & activity) { | |
| 1014 | − switch (activity) { | |
| 1015 | − case VIRTIO_CCW_DOING_READ_FEAT: | |
| 1016 | − case VIRTIO_CCW_DOING_WRITE_FEAT: | |
| 1017 | − case VIRTIO_CCW_DOING_READ_CONFIG: | |
| 1018 | − case VIRTIO_CCW_DOING_WRITE_CONFIG: | |
| 1019 | − case VIRTIO_CCW_DOING_WRITE_STATUS: | |
| 1020 | − case VIRTIO_CCW_DOING_SET_VQ: | |
| 1021 | − case VIRTIO_CCW_DOING_SET_IND: | |
| 1022 | − case VIRTIO_CCW_DOING_SET_CONF_IND: | |
| 1023 | − case VIRTIO_CCW_DOING_RESET: | |
| 1024 | − case VIRTIO_CCW_DOING_READ_VQ_CONF: | |
| 1025 | − case VIRTIO_CCW_DOING_SET_IND_ADAPTER: | |
| 1026 | − case VIRTIO_CCW_DOING_SET_VIRTIO_REV: | |
| 1027 | − vcdev->curr_io &= ~activity; | |
| 1028 | − wake_up(&vcdev->wait_q); | |
| 1029 | − break; | |
| 1030 | − default: | |
| 1031 | − /* don't know what to do... */ | |
| 1032 | − dev_warn(&cdev->dev, "Suspicious activity '%08x'\n", | |
| 1033 | − activity); | |
| 1034 | − WARN_ON(1); | |
| 1035 | − break; | |
| 1036 | − } | |
| 1037 | − } | |
| 1049 | + virtio_ccw_check_activity(vcdev, activity); | |
| 1038 | 1050 | for_each_set_bit(i, &vcdev->indicators, |
| 1039 | 1051 | sizeof(vcdev->indicators) * BITS_PER_BYTE) { |
| 1040 | 1052 | /* The bit clear must happen before the vring kick. */ |
| @@ -219,13 +219,13 @@ static int sdev_runtime_suspend(struct device *dev) · 218 unmodified lines | ||
| 219 | 219 | struct scsi_device *sdev = to_scsi_device(dev); |
| 220 | 220 | int err = 0; |
| 221 | 221 | |
| 222 | − if (pm && pm->runtime_suspend) { | |
| 223 | − err = blk_pre_runtime_suspend(sdev->request_queue); | |
| 224 | − if (err) | |
| 225 | − return err; | |
| 222 | + err = blk_pre_runtime_suspend(sdev->request_queue); | |
| 223 | + if (err) | |
| 224 | + return err; | |
| 225 | + if (pm && pm->runtime_suspend) | |
| 226 | 226 | err = pm->runtime_suspend(dev); |
| 227 | − blk_post_runtime_suspend(sdev->request_queue, err); | |
| 228 | − } | |
| 227 | + blk_post_runtime_suspend(sdev->request_queue, err); | |
| 228 | + | |
| 229 | 229 | return err; |
| 230 | 230 | } |
| 231 | 231 | |
| @@ -248,11 +248,11 @@ static int sdev_runtime_resume(struct device *dev) · 16 unmodified lines | ||
| 248 | 248 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
| 249 | 249 | int err = 0; |
| 250 | 250 | |
| 251 | − if (pm && pm->runtime_resume) { | |
| 252 | − blk_pre_runtime_resume(sdev->request_queue); | |
| 251 | + blk_pre_runtime_resume(sdev->request_queue); | |
| 252 | + if (pm && pm->runtime_resume) | |
| 253 | 253 | err = pm->runtime_resume(dev); |
| 254 | − blk_post_runtime_resume(sdev->request_queue, err); | |
| 255 | − } | |
| 254 | + blk_post_runtime_resume(sdev->request_queue, err); | |
| 255 | + | |
| 256 | 256 | return err; |
| 257 | 257 | } |
| 258 | 258 | |
| @@ -2885,10 +2885,13 @@ static int sd_revalidate_disk(struct gendisk *disk) · 2884 unmodified lines | ||
| 2885 | 2885 | |
| 2886 | 2886 | /* |
| 2887 | 2887 | * Use the device's preferred I/O size for reads and writes |
| 2888 | − * unless the reported value is unreasonably large (or garbage). | |
| 2888 | + * unless the reported value is unreasonably small, large, or | |
| 2889 | + * garbage. | |
| 2889 | 2890 | */ |
| 2890 | − if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max && | |
| 2891 | − sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS) | |
| 2891 | + if (sdkp->opt_xfer_blocks && | |
| 2892 | + sdkp->opt_xfer_blocks <= dev_max && | |
| 2893 | + sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS && | |
| 2894 | + sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE) | |
| 2892 | 2895 | rw_max = q->limits.io_opt = |
| 2893 | 2896 | logical_to_sectors(sdp, sdkp->opt_xfer_blocks); |
| 2894 | 2897 | else |
| @@ -84,6 +84,7 @@ static void init_device_slot_control(unsigned char *dest_desc, · 83 unmodified lines | ||
| 84 | 84 | static int ses_recv_diag(struct scsi_device *sdev, int page_code, |
| 85 | 85 | void *buf, int bufflen) |
| 86 | 86 | { |
| 87 | + int ret; | |
| 87 | 88 | unsigned char cmd[] = { |
| 88 | 89 | RECEIVE_DIAGNOSTIC, |
| 89 | 90 | 1, /* Set PCV bit */ |
| @@ -92,9 +93,26 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code, · 2 unmodified lines | ||
| 92 | 93 | bufflen & 0xff, |
| 93 | 94 | 0 |
| 94 | 95 | }; |
| 96 | + unsigned char recv_page_code; | |
| 95 | 97 | |
| 96 | − return scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, | |
| 98 | + ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, | |
| 97 | 99 | NULL, SES_TIMEOUT, SES_RETRIES, NULL); |
| 100 | + if (unlikely(!ret)) | |
| 101 | + return ret; | |
| 102 | + | |
| 103 | + recv_page_code = ((unsigned char *)buf)[0]; | |
| 104 | + | |
| 105 | + if (likely(recv_page_code == page_code)) | |
| 106 | + return ret; | |
| 107 | + | |
| 108 | + /* successful diagnostic but wrong page code. This happens to some | |
| 109 | + * USB devices, just print a message and pretend there was an error */ | |
| 110 | + | |
| 111 | + sdev_printk(KERN_ERR, sdev, | |
| 112 | + "Wrong diagnostic page; asked for %d got %u\n", | |
| 113 | + page_code, recv_page_code); | |
| 114 | + | |
| 115 | + return -EINVAL; | |
| 98 | 116 | } |
| 99 | 117 | |
| 100 | 118 | static int ses_send_diag(struct scsi_device *sdev, int page_code, |
| @@ -541,7 +559,15 @@ static void ses_enclosure_data_process(struct enclosure_device *edev, · 440 unmodified lines | ||
| 541 | 559 | if (desc_ptr) |
| 542 | 560 | desc_ptr += len; |
| 543 | 561 | |
| 544 | − if (addl_desc_ptr) | |
| 562 | + if (addl_desc_ptr && | |
| 563 | + /* only find additional descriptions for specific devices */ | |
| 564 | + (type_ptr[0] == ENCLOSURE_COMPONENT_DEVICE || | |
| 565 | + type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE || | |
| 566 | + type_ptr[0] == ENCLOSURE_COMPONENT_SAS_EXPANDER || | |
| 567 | + /* these elements are optional */ | |
| 568 | + type_ptr[0] == ENCLOSURE_COMPONENT_SCSI_TARGET_PORT || | |
| 569 | + type_ptr[0] == ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT || | |
| 570 | + type_ptr[0] == ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS)) | |
| 545 | 571 | addl_desc_ptr += addl_desc_ptr[1] + 2; |
| 546 | 572 | |
| 547 | 573 | } |
| @@ -167,7 +167,7 @@ static inline int is_double_byte_mode(struct fsl_dspi *dspi) · 166 unmodified lines | ||
| 167 | 167 | { |
| 168 | 168 | unsigned int val; |
| 169 | 169 | |
| 170 | − regmap_read(dspi->regmap, SPI_CTAR(dspi->cs), &val); | |
| 170 | + regmap_read(dspi->regmap, SPI_CTAR(0), &val); | |
| 171 | 171 | |
| 172 | 172 | return ((val & SPI_FRAME_BITS_MASK) == SPI_FRAME_BITS(8)) ? 0 : 1; |
| 173 | 173 | } |
| @@ -257,7 +257,7 @@ static u32 dspi_data_to_pushr(struct fsl_dspi *dspi, int tx_word) · 83 unmodified lines | ||
| 257 | 257 | |
| 258 | 258 | return SPI_PUSHR_TXDATA(d16) | |
| 259 | 259 | SPI_PUSHR_PCS(dspi->cs) | |
| 260 | − SPI_PUSHR_CTAS(dspi->cs) | | |
| 260 | + SPI_PUSHR_CTAS(0) | | |
| 261 | 261 | SPI_PUSHR_CONT; |
| 262 | 262 | } |
| 263 | 263 | |
| @@ -290,7 +290,7 @@ static int dspi_eoq_write(struct fsl_dspi *dspi) · 26 unmodified lines | ||
| 290 | 290 | */ |
| 291 | 291 | if (tx_word && (dspi->len == 1)) { |
| 292 | 292 | dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; |
| 293 | − regmap_update_bits(dspi->regmap, SPI_CTAR(dspi->cs), | |
| 293 | + regmap_update_bits(dspi->regmap, SPI_CTAR(0), | |
| 294 | 294 | SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); |
| 295 | 295 | tx_word = 0; |
| 296 | 296 | } |
| @@ -339,7 +339,7 @@ static int dspi_tcfq_write(struct fsl_dspi *dspi) · 42 unmodified lines | ||
| 339 | 339 | |
| 340 | 340 | if (tx_word && (dspi->len == 1)) { |
| 341 | 341 | dspi->dataflags |= TRAN_STATE_WORD_ODD_NUM; |
| 342 | − regmap_update_bits(dspi->regmap, SPI_CTAR(dspi->cs), | |
| 342 | + regmap_update_bits(dspi->regmap, SPI_CTAR(0), | |
| 343 | 343 | SPI_FRAME_BITS_MASK, SPI_FRAME_BITS(8)); |
| 344 | 344 | tx_word = 0; |
| 345 | 345 | } |
| @@ -407,7 +407,7 @@ static int dspi_transfer_one_message(struct spi_master *master, · 61 unmodified lines | ||
| 407 | 407 | regmap_update_bits(dspi->regmap, SPI_MCR, |
| 408 | 408 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF, |
| 409 | 409 | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); |
| 410 | − regmap_write(dspi->regmap, SPI_CTAR(dspi->cs), | |
| 410 | + regmap_write(dspi->regmap, SPI_CTAR(0), | |
| 411 | 411 | dspi->cur_chip->ctar_val); |
| 412 | 412 | |
| 413 | 413 | trans_mode = dspi->devtype_data->trans_mode; |
| @@ -566,7 +566,7 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id) · 152 unmodified lines | ||
| 566 | 566 | if (!dspi->len) { |
| 567 | 567 | if (dspi->dataflags & TRAN_STATE_WORD_ODD_NUM) { |
| 568 | 568 | regmap_update_bits(dspi->regmap, |
| 569 | − SPI_CTAR(dspi->cs), | |
| 569 | + SPI_CTAR(0), | |
| 570 | 570 | SPI_FRAME_BITS_MASK, |
| 571 | 571 | SPI_FRAME_BITS(16)); |
| 572 | 572 | dspi->dataflags &= ~TRAN_STATE_WORD_ODD_NUM; |
| @@ -1705,7 +1705,7 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size) · 1704 unmodified lines | ||
| 1705 | 1705 | master->bus_num = -1; |
| 1706 | 1706 | master->num_chipselect = 1; |
| 1707 | 1707 | master->dev.class = &spi_master_class; |
| 1708 | − master->dev.parent = get_device(dev); | |
| 1708 | + master->dev.parent = dev; | |
| 1709 | 1709 | spi_master_set_devdata(master, &master[1]); |
| 1710 | 1710 | |
| 1711 | 1711 | return master; |
| @@ -651,11 +651,11 @@ static int spidev_release(struct inode *inode, struct file *filp) · 650 unmodified lines | ||
| 651 | 651 | kfree(spidev->rx_buffer); |
| 652 | 652 | spidev->rx_buffer = NULL; |
| 653 | 653 | |
| 654 | + spin_lock_irq(&spidev->spi_lock); | |
| 654 | 655 | if (spidev->spi) |
| 655 | 656 | spidev->speed_hz = spidev->spi->max_speed_hz; |
| 656 | 657 | |
| 657 | 658 | /* ... after we unbound from the underlying device? */ |
| 658 | − spin_lock_irq(&spidev->spi_lock); | |
| 659 | 659 | dofree = (spidev->spi == NULL); |
| 660 | 660 | spin_unlock_irq(&spidev->spi_lock); |
| 661 | 661 | |
| @@ -81,7 +81,7 @@ static int ion_chunk_heap_allocate(struct ion_heap *heap, · 80 unmodified lines | ||
| 81 | 81 | err: |
| 82 | 82 | sg = table->sgl; |
| 83 | 83 | for (i -= 1; i >= 0; i--) { |
| 84 | − gen_pool_free(chunk_heap->pool, sg_phys(sg) & PAGE_MASK, | |
| 84 | + gen_pool_free(chunk_heap->pool, page_to_phys(sg_page(sg)), | |
| 85 | 85 | sg->length); |
| 86 | 86 | sg = sg_next(sg); |
| 87 | 87 | } |
| @@ -109,7 +109,7 @@ static void ion_chunk_heap_free(struct ion_buffer *buffer) · 21 unmodified lines | ||
| 109 | 109 | DMA_BIDIRECTIONAL); |
| 110 | 110 | |
| 111 | 111 | for_each_sg(table->sgl, sg, table->nents, i) { |
| 112 | − gen_pool_free(chunk_heap->pool, sg_phys(sg) & PAGE_MASK, | |
| 112 | + gen_pool_free(chunk_heap->pool, page_to_phys(sg_page(sg)), | |
| 113 | 113 | sg->length); |
| 114 | 114 | } |
| 115 | 115 | chunk_heap->allocated -= allocated_size; |
| @@ -2054,13 +2054,13 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, · 2053 unmodified lines | ||
| 2054 | 2054 | size_t eol; |
| 2055 | 2055 | size_t tail; |
| 2056 | 2056 | int ret, found = 0; |
| 2057 | − bool eof_push = 0; | |
| 2058 | 2057 | |
| 2059 | 2058 | /* N.B. avoid overrun if nr == 0 */ |
| 2060 | − n = min(*nr, smp_load_acquire(&ldata->canon_head) - ldata->read_tail); | |
| 2061 | − if (!n) | |
| 2059 | + if (!*nr) | |
| 2062 | 2060 | return 0; |
| 2063 | 2061 | |
| 2062 | + n = min(*nr + 1, smp_load_acquire(&ldata->canon_head) - ldata->read_tail); | |
| 2063 | + | |
| 2064 | 2064 | tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1); |
| 2065 | 2065 | size = min_t(size_t, tail + n, N_TTY_BUF_SIZE); |
| 2066 | 2066 | |
| @@ -2081,12 +2081,11 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, · 14 unmodified lines | ||
| 2081 | 2081 | n = eol - tail; |
| 2082 | 2082 | if (n > N_TTY_BUF_SIZE) |
| 2083 | 2083 | n += N_TTY_BUF_SIZE; |
| 2084 | − n += found; | |
| 2085 | − c = n; | |
| 2084 | + c = n + found; | |
| 2086 | 2085 | |
| 2087 | − if (found && !ldata->push && read_buf(ldata, eol) == __DISABLED_CHAR) { | |
| 2088 | − n--; | |
| 2089 | − eof_push = !n && ldata->read_tail != ldata->line_start; | |
| 2086 | + if (!found || read_buf(ldata, eol) != __DISABLED_CHAR) { | |
| 2087 | + c = min(*nr, c); | |
| 2088 | + n = c; | |
| 2090 | 2089 | } |
| 2091 | 2090 | |
| 2092 | 2091 | n_tty_trace("%s: eol:%zu found:%d n:%zu c:%zu size:%zu more:%zu\n", |
| @@ -2116,7 +2115,7 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, · 23 unmodified lines | ||
| 2116 | 2115 | ldata->push = 0; |
| 2117 | 2116 | tty_audit_push(tty); |
| 2118 | 2117 | } |
| 2119 | − return eof_push ? -EAGAIN : 0; | |
| 2118 | + return 0; | |
| 2120 | 2119 | } |
| 2121 | 2120 | |
| 2122 | 2121 | extern ssize_t redirected_tty_write(struct file *, const char __user *, |
| @@ -2273,10 +2272,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, · 150 unmodified lines | ||
| 2273 | 2272 | |
| 2274 | 2273 | if (ldata->icanon && !L_EXTPROC(tty)) { |
| 2275 | 2274 | retval = canon_copy_from_read_buf(tty, &b, &nr); |
| 2276 | − if (retval == -EAGAIN) { | |
| 2277 | − retval = 0; | |
| 2278 | − continue; | |
| 2279 | − } else if (retval) | |
| 2275 | + if (retval) | |
| 2280 | 2276 | break; |
| 2281 | 2277 | } else { |
| 2282 | 2278 | int uncopied; |
| @@ -115,12 +115,16 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value) · 114 unmodified lines | ||
| 115 | 115 | */ |
| 116 | 116 | static int uniphier_serial_dl_read(struct uart_8250_port *up) |
| 117 | 117 | { |
| 118 | − return readl(up->port.membase + UNIPHIER_UART_DLR); | |
| 118 | + int offset = UNIPHIER_UART_DLR << up->port.regshift; | |
| 119 | + | |
| 120 | + return readl(up->port.membase + offset); | |
| 119 | 121 | } |
| 120 | 122 | |
| 121 | 123 | static void uniphier_serial_dl_write(struct uart_8250_port *up, int value) |
| 122 | 124 | { |
| 123 | − writel(value, up->port.membase + UNIPHIER_UART_DLR); | |
| 125 | + int offset = UNIPHIER_UART_DLR << up->port.regshift; | |
| 126 | + | |
| 127 | + writel(value, up->port.membase + offset); | |
| 124 | 128 | } |
| 125 | 129 | |
| 126 | 130 | static int uniphier_of_serial_setup(struct device *dev, struct uart_port *port, |
| @@ -115,6 +115,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match) · 114 unmodified lines | ||
| 115 | 115 | if (buf && !parse_options(&early_console_dev, buf)) |
| 116 | 116 | buf = NULL; |
| 117 | 117 | |
| 118 | + spin_lock_init(&port->lock); | |
| 118 | 119 | port->uartclk = BASE_BAUD * 16; |
| 119 | 120 | if (port->mapbase) |
| 120 | 121 | port->membase = earlycon_map(port->mapbase, 64); |
| @@ -202,6 +203,7 @@ int __init of_setup_earlycon(unsigned long addr, · 81 unmodified lines | ||
| 202 | 203 | int err; |
| 203 | 204 | struct uart_port *port = &early_console_dev.port; |
| 204 | 205 | |
| 206 | + spin_lock_init(&port->lock); | |
| 205 | 207 | port->iotype = UPIO_MEM; |
| 206 | 208 | port->mapbase = addr; |
| 207 | 209 | port->uartclk = BASE_BAUD * 16; |
| @@ -1437,7 +1437,7 @@ static void sci_request_dma(struct uart_port *port) · 1436 unmodified lines | ||
| 1437 | 1437 | sg_init_table(sg, 1); |
| 1438 | 1438 | s->rx_buf[i] = buf; |
| 1439 | 1439 | sg_dma_address(sg) = dma; |
| 1440 | − sg->length = s->buf_len_rx; | |
| 1440 | + sg_dma_len(sg) = s->buf_len_rx; | |
| 1441 | 1441 | |
| 1442 | 1442 | buf += s->buf_len_rx; |
| 1443 | 1443 | dma += s->buf_len_rx; |
| @@ -148,8 +148,10 @@ static int receive_chars_read(struct uart_port *port) · 147 unmodified lines | ||
| 148 | 148 | uart_handle_dcd_change(port, 1); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | − for (i = 0; i < bytes_read; i++) | |
| 152 | − uart_handle_sysrq_char(port, con_read_page[i]); | |
| 151 | + if (port->sysrq != 0 && *con_read_page) { | |
| 152 | + for (i = 0; i < bytes_read; i++) | |
| 153 | + uart_handle_sysrq_char(port, con_read_page[i]); | |
| 154 | + } | |
| 153 | 155 | |
| 154 | 156 | if (port->state == NULL) |
| 155 | 157 | continue; |
| @@ -168,17 +170,17 @@ struct sunhv_ops { · 12 unmodified lines | ||
| 168 | 170 | int (*receive_chars)(struct uart_port *port); |
| 169 | 171 | }; |
| 170 | 172 | |
| 171 | −static struct sunhv_ops bychar_ops = { | |
| 173 | +static const struct sunhv_ops bychar_ops = { | |
| 172 | 174 | .transmit_chars = transmit_chars_putchar, |
| 173 | 175 | .receive_chars = receive_chars_getchar, |
| 174 | 176 | }; |
| 175 | 177 | |
| 176 | −static struct sunhv_ops bywrite_ops = { | |
| 178 | +static const struct sunhv_ops bywrite_ops = { | |
| 177 | 179 | .transmit_chars = transmit_chars_write, |
| 178 | 180 | .receive_chars = receive_chars_read, |
| 179 | 181 | }; |
| 180 | 182 | |
| 181 | −static struct sunhv_ops *sunhv_ops = &bychar_ops; | |
| 183 | +static const struct sunhv_ops *sunhv_ops = &bychar_ops; | |
| 182 | 184 | |
| 183 | 185 | static struct tty_port *receive_chars(struct uart_port *port) |
| 184 | 186 | { |
| @@ -450,7 +450,7 @@ receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count) · 449 unmodified lines | ||
| 450 | 450 | count = disc->ops->receive_buf2(tty, p, f, count); |
| 451 | 451 | else { |
| 452 | 452 | count = min_t(int, count, tty->receive_room); |
| 453 | − if (count) | |
| 453 | + if (count && disc->ops->receive_buf) | |
| 454 | 454 | disc->ops->receive_buf(tty, p, f, count); |
| 455 | 455 | } |
| 456 | 456 | return count; |
| @@ -1035,10 +1035,20 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) · 1034 unmodified lines | ||
| 1035 | 1035 | unsigned delay; |
| 1036 | 1036 | |
| 1037 | 1037 | /* Continue a partial initialization */ |
| 1038 | − if (type == HUB_INIT2) | |
| 1039 | − goto init2; | |
| 1040 | − if (type == HUB_INIT3) | |
| 1038 | + if (type == HUB_INIT2 || type == HUB_INIT3) { | |
| 1039 | + device_lock(hub->intfdev); | |
| 1040 | + | |
| 1041 | + /* Was the hub disconnected while we were waiting? */ | |
| 1042 | + if (hub->disconnected) { | |
| 1043 | + device_unlock(hub->intfdev); | |
| 1044 | + kref_put(&hub->kref, hub_release); | |
| 1045 | + return; | |
| 1046 | + } | |
| 1047 | + if (type == HUB_INIT2) | |
| 1048 | + goto init2; | |
| 1041 | 1049 | goto init3; |
| 1050 | + } | |
| 1051 | + kref_get(&hub->kref); | |
| 1042 | 1052 | |
| 1043 | 1053 | /* The superspeed hub except for root hub has to use Hub Depth |
| 1044 | 1054 | * value as an offset into the route string to locate the bits |
| @@ -1236,6 +1246,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) · 191 unmodified lines | ||
| 1236 | 1246 | queue_delayed_work(system_power_efficient_wq, |
| 1237 | 1247 | &hub->init_work, |
| 1238 | 1248 | msecs_to_jiffies(delay)); |
| 1249 | + device_unlock(hub->intfdev); | |
| 1239 | 1250 | return; /* Continues at init3: below */ |
| 1240 | 1251 | } else { |
| 1241 | 1252 | msleep(delay); |
| @@ -1257,6 +1268,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) · 15 unmodified lines | ||
| 1257 | 1268 | /* Allow autosuspend if it was suppressed */ |
| 1258 | 1269 | if (type <= HUB_INIT3) |
| 1259 | 1270 | usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); |
| 1271 | + | |
| 1272 | + if (type == HUB_INIT2 || type == HUB_INIT3) | |
| 1273 | + device_unlock(hub->intfdev); | |
| 1274 | + | |
| 1275 | + kref_put(&hub->kref, hub_release); | |
| 1260 | 1276 | } |
| 1261 | 1277 | |
| 1262 | 1278 | /* Implement the continuations for the delays above */ |
| @@ -531,7 +531,8 @@ static int ipaq_open(struct tty_struct *tty, · 530 unmodified lines | ||
| 531 | 531 | * through. Since this has a reasonably high failure rate, we retry |
| 532 | 532 | * several times. |
| 533 | 533 | */ |
| 534 | − while (retries--) { | |
| 534 | + while (retries) { | |
| 535 | + retries--; | |
| 535 | 536 | result = usb_control_msg(serial->dev, |
| 536 | 537 | usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, |
| 537 | 538 | 0x1, 0, NULL, 0, 100); |
| @@ -479,7 +479,10 @@ static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s) · 478 unmodified lines | ||
| 479 | 479 | port = FSL_DIU_PORT_DLVDS; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | − return diu_ops.valid_monitor_port(port); | |
| 482 | + if (diu_ops.valid_monitor_port) | |
| 483 | + port = diu_ops.valid_monitor_port(port); | |
| 484 | + | |
| 485 | + return port; | |
| 483 | 486 | } |
| 484 | 487 | |
| 485 | 488 | /* |
| @@ -1915,6 +1918,14 @@ static int __init fsl_diu_init(void) · 1429 unmodified lines | ||
| 1915 | 1918 | #else |
| 1916 | 1919 | monitor_port = fsl_diu_name_to_port(monitor_string); |
| 1917 | 1920 | #endif |
| 1921 | + | |
| 1922 | + /* | |
| 1923 | + * Must to verify set_pixel_clock. If not implement on platform, | |
| 1924 | + * then that means that there is no platform support for the DIU. | |
| 1925 | + */ | |
| 1926 | + if (!diu_ops.set_pixel_clock) | |
| 1927 | + return -ENODEV; | |
| 1928 | + | |
| 1918 | 1929 | pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); |
| 1919 | 1930 | |
| 1920 | 1931 | #ifdef CONFIG_NOT_COHERENT_CACHE |
| @@ -275,6 +275,12 @@ const struct omap_video_timings omap_dss_pal_timings = { · 274 unmodified lines | ||
| 275 | 275 | .vbp = 41, |
| 276 | 276 | |
| 277 | 277 | .interlace = true, |
| 278 | + | |
| 279 | + .hsync_level = OMAPDSS_SIG_ACTIVE_LOW, | |
| 280 | + .vsync_level = OMAPDSS_SIG_ACTIVE_LOW, | |
| 281 | + .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE, | |
| 282 | + .de_level = OMAPDSS_SIG_ACTIVE_HIGH, | |
| 283 | + .sync_pclk_edge = OMAPDSS_DRIVE_SIG_FALLING_EDGE, | |
| 278 | 284 | }; |
| 279 | 285 | EXPORT_SYMBOL(omap_dss_pal_timings); |
| 280 | 286 | |
| @@ -290,6 +296,12 @@ const struct omap_video_timings omap_dss_ntsc_timings = { · 9 unmodified lines | ||
| 290 | 296 | .vbp = 31, |
| 291 | 297 | |
| 292 | 298 | .interlace = true, |
| 299 | + | |
| 300 | + .hsync_level = OMAPDSS_SIG_ACTIVE_LOW, | |
| 301 | + .vsync_level = OMAPDSS_SIG_ACTIVE_LOW, | |
| 302 | + .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE, | |
| 303 | + .de_level = OMAPDSS_SIG_ACTIVE_HIGH, | |
| 304 | + .sync_pclk_edge = OMAPDSS_DRIVE_SIG_FALLING_EDGE, | |
| 293 | 305 | }; |
| 294 | 306 | EXPORT_SYMBOL(omap_dss_ntsc_timings); |
| 295 | 307 | |
| @@ -281,7 +281,8 @@ static void handle_irq_for_port(unsigned port) · 280 unmodified lines | ||
| 281 | 281 | |
| 282 | 282 | static void consume_one_event(unsigned cpu, |
| 283 | 283 | struct evtchn_fifo_control_block *control_block, |
| 284 | − unsigned priority, unsigned long *ready) | |
| 284 | + unsigned priority, unsigned long *ready, | |
| 285 | + bool drop) | |
| 285 | 286 | { |
| 286 | 287 | struct evtchn_fifo_queue *q = &per_cpu(cpu_queue, cpu); |
| 287 | 288 | uint32_t head; |
| @@ -313,13 +314,17 @@ static void consume_one_event(unsigned cpu, · 25 unmodified lines | ||
| 313 | 314 | if (head == 0) |
| 314 | 315 | clear_bit(priority, ready); |
| 315 | 316 | |
| 316 | − if (evtchn_fifo_is_pending(port) && !evtchn_fifo_is_masked(port)) | |
| 317 | − handle_irq_for_port(port); | |
| 317 | + if (evtchn_fifo_is_pending(port) && !evtchn_fifo_is_masked(port)) { | |
| 318 | + if (unlikely(drop)) | |
| 319 | + pr_warn("Dropping pending event for port %u\n", port); | |
| 320 | + else | |
| 321 | + handle_irq_for_port(port); | |
| 322 | + } | |
| 318 | 323 | |
| 319 | 324 | q->head[priority] = head; |
| 320 | 325 | } |
| 321 | 326 | |
| 322 | −static void evtchn_fifo_handle_events(unsigned cpu) | |
| 327 | +static void __evtchn_fifo_handle_events(unsigned cpu, bool drop) | |
| 323 | 328 | { |
| 324 | 329 | struct evtchn_fifo_control_block *control_block; |
| 325 | 330 | unsigned long ready; |
| @@ -331,11 +336,16 @@ static void evtchn_fifo_handle_events(unsigned cpu) · 5 unmodified lines | ||
| 331 | 336 | |
| 332 | 337 | while (ready) { |
| 333 | 338 | q = find_first_bit(&ready, EVTCHN_FIFO_MAX_QUEUES); |
| 334 | − consume_one_event(cpu, control_block, q, &ready); | |
| 339 | + consume_one_event(cpu, control_block, q, &ready, drop); | |
| 335 | 340 | ready |= xchg(&control_block->ready, 0); |
| 336 | 341 | } |
| 337 | 342 | } |
| 338 | 343 | |
| 344 | +static void evtchn_fifo_handle_events(unsigned cpu) | |
| 345 | +{ | |
| 346 | + __evtchn_fifo_handle_events(cpu, false); | |
| 347 | +} | |
| 348 | + | |
| 339 | 349 | static void evtchn_fifo_resume(void) |
| 340 | 350 | { |
| 341 | 351 | unsigned cpu; |
| @@ -420,6 +430,9 @@ static int evtchn_fifo_cpu_notification(struct notifier_block *self, · 78 unmodified lines | ||
| 420 | 430 | if (!per_cpu(cpu_control_block, cpu)) |
| 421 | 431 | ret = evtchn_fifo_alloc_control_block(cpu); |
| 422 | 432 | break; |
| 433 | + case CPU_DEAD: | |
| 434 | + __evtchn_fifo_handle_events(cpu, true); | |
| 435 | + break; | |
| 423 | 436 | default: |
| 424 | 437 | break; |
| 425 | 438 | } |
| @@ -37,6 +37,7 @@ struct xen_pcibk_device { · 36 unmodified lines | ||
| 37 | 37 | struct xen_pci_sharedinfo *sh_info; |
| 38 | 38 | unsigned long flags; |
| 39 | 39 | struct work_struct op_work; |
| 40 | + struct xen_pci_op op; | |
| 40 | 41 | }; |
| 41 | 42 | |
| 42 | 43 | struct xen_pcibk_dev_data { |
| @@ -70,6 +70,13 @@ static void xen_pcibk_control_isr(struct pci_dev *dev, int reset) · 69 unmodified lines | ||
| 70 | 70 | enable ? "enable" : "disable"); |
| 71 | 71 | |
| 72 | 72 | if (enable) { |
| 73 | + /* | |
| 74 | + * The MSI or MSI-X should not have an IRQ handler. Otherwise | |
| 75 | + * if the guest terminates we BUG_ON in free_msi_irqs. | |
| 76 | + */ | |
| 77 | + if (dev->msi_enabled || dev->msix_enabled) | |
| 78 | + goto out; | |
| 79 | + | |
| 73 | 80 | rc = request_irq(dev_data->irq, |
| 74 | 81 | xen_pcibk_guest_interrupt, IRQF_SHARED, |
| 75 | 82 | dev_data->irq_name, dev); |
| @@ -144,7 +151,12 @@ int xen_pcibk_enable_msi(struct xen_pcibk_device *pdev, · 68 unmodified lines | ||
| 144 | 151 | if (unlikely(verbose_request)) |
| 145 | 152 | printk(KERN_DEBUG DRV_NAME ": %s: enable MSI\n", pci_name(dev)); |
| 146 | 153 | |
| 147 | − status = pci_enable_msi(dev); | |
| 154 | + if (dev->msi_enabled) | |
| 155 | + status = -EALREADY; | |
| 156 | + else if (dev->msix_enabled) | |
| 157 | + status = -ENXIO; | |
| 158 | + else | |
| 159 | + status = pci_enable_msi(dev); | |
| 148 | 160 | |
| 149 | 161 | if (status) { |
| 150 | 162 | pr_warn_ratelimited("%s: error enabling MSI for guest %u: err %d\n", |
| @@ -173,20 +185,23 @@ static · 22 unmodified lines | ||
| 173 | 185 | int xen_pcibk_disable_msi(struct xen_pcibk_device *pdev, |
| 174 | 186 | struct pci_dev *dev, struct xen_pci_op *op) |
| 175 | 187 | { |
| 176 | − struct xen_pcibk_dev_data *dev_data; | |
| 177 | − | |
| 178 | 188 | if (unlikely(verbose_request)) |
| 179 | 189 | printk(KERN_DEBUG DRV_NAME ": %s: disable MSI\n", |
| 180 | 190 | pci_name(dev)); |
| 181 | − pci_disable_msi(dev); | |
| 182 | 191 | |
| 192 | + if (dev->msi_enabled) { | |
| 193 | + struct xen_pcibk_dev_data *dev_data; | |
| 194 | + | |
| 195 | + pci_disable_msi(dev); | |
| 196 | + | |
| 197 | + dev_data = pci_get_drvdata(dev); | |
| 198 | + if (dev_data) | |
| 199 | + dev_data->ack_intr = 1; | |
| 200 | + } | |
| 183 | 201 | op->value = dev->irq ? xen_pirq_from_irq(dev->irq) : 0; |
| 184 | 202 | if (unlikely(verbose_request)) |
| 185 | 203 | printk(KERN_DEBUG DRV_NAME ": %s: MSI: %d\n", pci_name(dev), |
| 186 | 204 | op->value); |
| 187 | − dev_data = pci_get_drvdata(dev); | |
| 188 | − if (dev_data) | |
| 189 | − dev_data->ack_intr = 1; | |
| 190 | 205 | return 0; |
| 191 | 206 | } |
| 192 | 207 | |
| @@ -197,13 +212,26 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev, · 4 unmodified lines | ||
| 197 | 212 | struct xen_pcibk_dev_data *dev_data; |
| 198 | 213 | int i, result; |
| 199 | 214 | struct msix_entry *entries; |
| 215 | + u16 cmd; | |
| 200 | 216 | |
| 201 | 217 | if (unlikely(verbose_request)) |
| 202 | 218 | printk(KERN_DEBUG DRV_NAME ": %s: enable MSI-X\n", |
| 203 | 219 | pci_name(dev)); |
| 220 | + | |
| 204 | 221 | if (op->value > SH_INFO_MAX_VEC) |
| 205 | 222 | return -EINVAL; |
| 206 | 223 | |
| 224 | + if (dev->msix_enabled) | |
| 225 | + return -EALREADY; | |
| 226 | + | |
| 227 | + /* | |
| 228 | + * PCI_COMMAND_MEMORY must be enabled, otherwise we may not be able | |
| 229 | + * to access the BARs where the MSI-X entries reside. | |
| 230 | + */ | |
| 231 | + pci_read_config_word(dev, PCI_COMMAND, &cmd); | |
| 232 | + if (dev->msi_enabled || !(cmd & PCI_COMMAND_MEMORY)) | |
| 233 | + return -ENXIO; | |
| 234 | + | |
| 207 | 235 | entries = kmalloc(op->value * sizeof(*entries), GFP_KERNEL); |
| 208 | 236 | if (entries == NULL) |
| 209 | 237 | return -ENOMEM; |
| @@ -245,23 +273,27 @@ static · 35 unmodified lines | ||
| 245 | 273 | int xen_pcibk_disable_msix(struct xen_pcibk_device *pdev, |
| 246 | 274 | struct pci_dev *dev, struct xen_pci_op *op) |
| 247 | 275 | { |
| 248 | − struct xen_pcibk_dev_data *dev_data; | |
| 249 | 276 | if (unlikely(verbose_request)) |
| 250 | 277 | printk(KERN_DEBUG DRV_NAME ": %s: disable MSI-X\n", |
| 251 | 278 | pci_name(dev)); |
| 252 | − pci_disable_msix(dev); | |
| 253 | 279 | |
| 280 | + if (dev->msix_enabled) { | |
| 281 | + struct xen_pcibk_dev_data *dev_data; | |
| 282 | + | |
| 283 | + pci_disable_msix(dev); | |
| 284 | + | |
| 285 | + dev_data = pci_get_drvdata(dev); | |
| 286 | + if (dev_data) | |
| 287 | + dev_data->ack_intr = 1; | |
| 288 | + } | |
| 254 | 289 | /* |
| 255 | 290 | * SR-IOV devices (which don't have any legacy IRQ) have |
| 256 | 291 | * an undefined IRQ value of zero. |
| 257 | 292 | */ |
| 258 | 293 | op->value = dev->irq ? xen_pirq_from_irq(dev->irq) : 0; |
| 259 | 294 | if (unlikely(verbose_request)) |
| 260 | − printk(KERN_DEBUG DRV_NAME ": %s: MSI-X: %d\n", pci_name(dev), | |
| 261 | − op->value); | |
| 262 | − dev_data = pci_get_drvdata(dev); | |
| 263 | − if (dev_data) | |
| 264 | − dev_data->ack_intr = 1; | |
| 295 | + printk(KERN_DEBUG DRV_NAME ": %s: MSI-X: %d\n", | |
| 296 | + pci_name(dev), op->value); | |
| 265 | 297 | return 0; |
| 266 | 298 | } |
| 267 | 299 | #endif |
| @@ -298,9 +330,11 @@ void xen_pcibk_do_op(struct work_struct *data) · 30 unmodified lines | ||
| 298 | 330 | container_of(data, struct xen_pcibk_device, op_work); |
| 299 | 331 | struct pci_dev *dev; |
| 300 | 332 | struct xen_pcibk_dev_data *dev_data = NULL; |
| 301 | − struct xen_pci_op *op = &pdev->sh_info->op; | |
| 333 | + struct xen_pci_op *op = &pdev->op; | |
| 302 | 334 | int test_intx = 0; |
| 303 | 335 | |
| 336 | + *op = pdev->sh_info->op; | |
| 337 | + barrier(); | |
| 304 | 338 | dev = xen_pcibk_get_pci_dev(pdev, op->domain, op->bus, op->devfn); |
| 305 | 339 | |
| 306 | 340 | if (dev == NULL) |
| @@ -342,6 +376,17 @@ void xen_pcibk_do_op(struct work_struct *data) · 35 unmodified lines | ||
| 342 | 376 | if ((dev_data->enable_intx != test_intx)) |
| 343 | 377 | xen_pcibk_control_isr(dev, 0 /* no reset */); |
| 344 | 378 | } |
| 379 | + pdev->sh_info->op.err = op->err; | |
| 380 | + pdev->sh_info->op.value = op->value; | |
| 381 | +#ifdef CONFIG_PCI_MSI | |
| 382 | + if (op->cmd == XEN_PCI_OP_enable_msix && op->err == 0) { | |
| 383 | + unsigned int i; | |
| 384 | + | |
| 385 | + for (i = 0; i < op->value; i++) | |
| 386 | + pdev->sh_info->op.msix_entries[i].vector = | |
| 387 | + op->msix_entries[i].vector; | |
| 388 | + } | |
| 389 | +#endif | |
| 345 | 390 | /* Tell the driver domain that we're done. */ |
| 346 | 391 | wmb(); |
| 347 | 392 | clear_bit(_XEN_PCIF_active, (unsigned long *)&pdev->sh_info->flags); |
| @@ -44,7 +44,6 @@ static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev) · 43 unmodified lines | ||
| 44 | 44 | dev_dbg(&xdev->dev, "allocated pdev @ 0x%p\n", pdev); |
| 45 | 45 | |
| 46 | 46 | pdev->xdev = xdev; |
| 47 | − dev_set_drvdata(&xdev->dev, pdev); | |
| 48 | 47 | |
| 49 | 48 | mutex_init(&pdev->dev_lock); |
| 50 | 49 | |
| @@ -58,6 +57,9 @@ static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev) · 7 unmodified lines | ||
| 58 | 57 | kfree(pdev); |
| 59 | 58 | pdev = NULL; |
| 60 | 59 | } |
| 60 | + | |
| 61 | + dev_set_drvdata(&xdev->dev, pdev); | |
| 62 | + | |
| 61 | 63 | out: |
| 62 | 64 | return pdev; |
| 63 | 65 | } |
| @@ -726,7 +726,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info) · 725 unmodified lines | ||
| 726 | 726 | if (!pending_req) |
| 727 | 727 | return 1; |
| 728 | 728 | |
| 729 | − ring_req = *RING_GET_REQUEST(ring, rc); | |
| 729 | + RING_COPY_REQUEST(ring, rc, &ring_req); | |
| 730 | 730 | ring->req_cons = ++rc; |
| 731 | 731 | |
| 732 | 732 | err = prepare_pending_reqs(info, &ring_req, pending_req); |
| @@ -10480,11 +10480,15 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) · 10479 unmodified lines | ||
| 10480 | 10480 | * until transaction commit to do the actual discard. |
| 10481 | 10481 | */ |
| 10482 | 10482 | if (trimming) { |
| 10483 | − WARN_ON(!list_empty(&block_group->bg_list)); | |
| 10484 | − spin_lock(&trans->transaction->deleted_bgs_lock); | |
| 10483 | + spin_lock(&fs_info->unused_bgs_lock); | |
| 10484 | + /* | |
| 10485 | + * A concurrent scrub might have added us to the list | |
| 10486 | + * fs_info->unused_bgs, so use a list_move operation | |
| 10487 | + * to add the block group to the deleted_bgs list. | |
| 10488 | + */ | |
| 10485 | 10489 | list_move(&block_group->bg_list, |
| 10486 | 10490 | &trans->transaction->deleted_bgs); |
| 10487 | − spin_unlock(&trans->transaction->deleted_bgs_lock); | |
| 10491 | + spin_unlock(&fs_info->unused_bgs_lock); | |
| 10488 | 10492 | btrfs_get_block_group(block_group); |
| 10489 | 10493 | } |
| 10490 | 10494 | end_trans: |
| @@ -1291,7 +1291,8 @@ out: · 1290 unmodified lines | ||
| 1291 | 1291 | * on error we return an unlocked page and the error value |
| 1292 | 1292 | * on success we return a locked page and 0 |
| 1293 | 1293 | */ |
| 1294 | −static int prepare_uptodate_page(struct page *page, u64 pos, | |
| 1294 | +static int prepare_uptodate_page(struct inode *inode, | |
| 1295 | + struct page *page, u64 pos, | |
| 1295 | 1296 | bool force_uptodate) |
| 1296 | 1297 | { |
| 1297 | 1298 | int ret = 0; |
| @@ -1306,6 +1307,10 @@ static int prepare_uptodate_page(struct page *page, u64 pos, · 8 unmodified lines | ||
| 1306 | 1307 | unlock_page(page); |
| 1307 | 1308 | return -EIO; |
| 1308 | 1309 | } |
| 1310 | + if (page->mapping != inode->i_mapping) { | |
| 1311 | + unlock_page(page); | |
| 1312 | + return -EAGAIN; | |
| 1313 | + } | |
| 1309 | 1314 | } |
| 1310 | 1315 | return 0; |
| 1311 | 1316 | } |
| @@ -1324,6 +1329,7 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, · 12 unmodified lines | ||
| 1324 | 1329 | int faili; |
| 1325 | 1330 | |
| 1326 | 1331 | for (i = 0; i < num_pages; i++) { |
| 1332 | +again: | |
| 1327 | 1333 | pages[i] = find_or_create_page(inode->i_mapping, index + i, |
| 1328 | 1334 | mask | __GFP_WRITE); |
| 1329 | 1335 | if (!pages[i]) { |
| @@ -1333,13 +1339,17 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, · 3 unmodified lines | ||
| 1333 | 1339 | } |
| 1334 | 1340 | |
| 1335 | 1341 | if (i == 0) |
| 1336 | − err = prepare_uptodate_page(pages[i], pos, | |
| 1342 | + err = prepare_uptodate_page(inode, pages[i], pos, | |
| 1337 | 1343 | force_uptodate); |
| 1338 | − if (i == num_pages - 1) | |
| 1339 | − err = prepare_uptodate_page(pages[i], | |
| 1344 | + if (!err && i == num_pages - 1) | |
| 1345 | + err = prepare_uptodate_page(inode, pages[i], | |
| 1340 | 1346 | pos + write_bytes, false); |
| 1341 | 1347 | if (err) { |
| 1342 | 1348 | page_cache_release(pages[i]); |
| 1349 | + if (err == -EAGAIN) { | |
| 1350 | + err = 0; | |
| 1351 | + goto again; | |
| 1352 | + } | |
| 1343 | 1353 | faili = i - 1; |
| 1344 | 1354 | goto fail; |
| 1345 | 1355 | } |
| @@ -891,7 +891,7 @@ out: · 890 unmodified lines | ||
| 891 | 891 | spin_unlock(&block_group->lock); |
| 892 | 892 | ret = 0; |
| 893 | 893 | |
| 894 | − btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuild it now", | |
| 894 | + btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuilding it now", | |
| 895 | 895 | block_group->key.objectid); |
| 896 | 896 | } |
| 897 | 897 | |
| @@ -2972,7 +2972,7 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, · 2074 unmodified lines | ||
| 2972 | 2972 | u64 cont1_bytes, u64 min_bytes) |
| 2973 | 2973 | { |
| 2974 | 2974 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; |
| 2975 | − struct btrfs_free_space *entry; | |
| 2975 | + struct btrfs_free_space *entry = NULL; | |
| 2976 | 2976 | int ret = -ENOSPC; |
| 2977 | 2977 | u64 bitmap_offset = offset_to_bitmap(ctl, offset); |
| 2978 | 2978 | |
| @@ -2983,8 +2983,10 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, · 4 unmodified lines | ||
| 2983 | 2983 | * The bitmap that covers offset won't be in the list unless offset |
| 2984 | 2984 | * is just its start offset. |
| 2985 | 2985 | */ |
| 2986 | − entry = list_first_entry(bitmaps, struct btrfs_free_space, list); | |
| 2987 | − if (entry->offset != bitmap_offset) { | |
| 2986 | + if (!list_empty(bitmaps)) | |
| 2987 | + entry = list_first_entry(bitmaps, struct btrfs_free_space, list); | |
| 2988 | + | |
| 2989 | + if (!entry || entry->offset != bitmap_offset) { | |
| 2988 | 2990 | entry = tree_search_offset(ctl, bitmap_offset, 1, 0); |
| 2989 | 2991 | if (entry && list_empty(&entry->list)) |
| 2990 | 2992 | list_add(&entry->list, bitmaps); |
| @@ -274,7 +274,6 @@ loop: · 273 unmodified lines | ||
| 274 | 274 | cur_trans->num_dirty_bgs = 0; |
| 275 | 275 | spin_lock_init(&cur_trans->dirty_bgs_lock); |
| 276 | 276 | INIT_LIST_HEAD(&cur_trans->deleted_bgs); |
| 277 | − spin_lock_init(&cur_trans->deleted_bgs_lock); | |
| 278 | 277 | spin_lock_init(&cur_trans->dropped_roots_lock); |
| 279 | 278 | list_add_tail(&cur_trans->list, &fs_info->trans_list); |
| 280 | 279 | extent_io_tree_init(&cur_trans->dirty_pages, |
| @@ -77,8 +77,8 @@ struct btrfs_transaction { · 76 unmodified lines | ||
| 77 | 77 | */ |
| 78 | 78 | struct mutex cache_write_mutex; |
| 79 | 79 | spinlock_t dirty_bgs_lock; |
| 80 | + /* Protected by spin lock fs_info->unused_bgs_lock. */ | |
| 80 | 81 | struct list_head deleted_bgs; |
| 81 | − spinlock_t deleted_bgs_lock; | |
| 82 | 82 | spinlock_t dropped_roots_lock; |
| 83 | 83 | struct btrfs_delayed_ref_root delayed_refs; |
| 84 | 84 | int aborted; |
| @@ -3548,12 +3548,11 @@ again: · 3547 unmodified lines | ||
| 3548 | 3548 | |
| 3549 | 3549 | ret = btrfs_force_chunk_alloc(trans, chunk_root, |
| 3550 | 3550 | BTRFS_BLOCK_GROUP_DATA); |
| 3551 | + btrfs_end_transaction(trans, chunk_root); | |
| 3551 | 3552 | if (ret < 0) { |
| 3552 | 3553 | mutex_unlock(&fs_info->delete_unused_bgs_mutex); |
| 3553 | 3554 | goto error; |
| 3554 | 3555 | } |
| 3555 | − | |
| 3556 | − btrfs_end_transaction(trans, chunk_root); | |
| 3557 | 3556 | chunk_reserved = 1; |
| 3558 | 3557 | } |
| 3559 | 3558 | |
| @@ -616,6 +616,7 @@ nfsd4_cb_layout_prepare(struct nfsd4_callback *cb) · 615 unmodified lines | ||
| 616 | 616 | |
| 617 | 617 | mutex_lock(&ls->ls_mutex); |
| 618 | 618 | nfs4_inc_and_copy_stateid(&ls->ls_recall_sid, &ls->ls_stid); |
| 619 | + mutex_unlock(&ls->ls_mutex); | |
| 619 | 620 | } |
| 620 | 621 | |
| 621 | 622 | static int |
| @@ -659,7 +660,6 @@ nfsd4_cb_layout_release(struct nfsd4_callback *cb) · 37 unmodified lines | ||
| 659 | 660 | |
| 660 | 661 | trace_layout_recall_release(&ls->ls_stid.sc_stateid); |
| 661 | 662 | |
| 662 | − mutex_unlock(&ls->ls_mutex); | |
| 663 | 663 | nfsd4_return_all_layouts(ls, &reaplist); |
| 664 | 664 | nfsd4_free_layouts(&reaplist); |
| 665 | 665 | nfs4_put_stid(&ls->ls_stid); |
| @@ -2843,6 +2843,8 @@ again: · 2842 unmodified lines | ||
| 2843 | 2843 | res->state &= ~DLM_LOCK_RES_BLOCK_DIRTY; |
| 2844 | 2844 | if (!ret) |
| 2845 | 2845 | BUG_ON(!(res->state & DLM_LOCK_RES_MIGRATING)); |
| 2846 | + else | |
| 2847 | + res->migration_pending = 0; | |
| 2846 | 2848 | spin_unlock(&res->spinlock); |
| 2847 | 2849 | |
| 2848 | 2850 | /* |
| @@ -67,7 +67,10 @@ static int ocfs2_do_flock(struct file *file, struct inode *inode, · 66 unmodified lines | ||
| 67 | 67 | */ |
| 68 | 68 | |
| 69 | 69 | locks_lock_file_wait(file, |
| 70 | − &(struct file_lock){.fl_type = F_UNLCK}); | |
| 70 | + &(struct file_lock) { | |
| 71 | + .fl_type = F_UNLCK, | |
| 72 | + .fl_flags = FL_FLOCK | |
| 73 | + }); | |
| 71 | 74 | |
| 72 | 75 | ocfs2_file_unlock(file); |
| 73 | 76 | } |
| @@ -54,11 +54,12 @@ · 53 unmodified lines | ||
| 54 | 54 | static u16 ocfs2_calc_new_backup_super(struct inode *inode, |
| 55 | 55 | struct ocfs2_group_desc *gd, |
| 56 | 56 | u16 cl_cpg, |
| 57 | + u16 old_bg_clusters, | |
| 57 | 58 | int set) |
| 58 | 59 | { |
| 59 | 60 | int i; |
| 60 | 61 | u16 backups = 0; |
| 61 | − u32 cluster; | |
| 62 | + u32 cluster, lgd_cluster; | |
| 62 | 63 | u64 blkno, gd_blkno, lgd_blkno = le64_to_cpu(gd->bg_blkno); |
| 63 | 64 | |
| 64 | 65 | for (i = 0; i < OCFS2_MAX_BACKUP_SUPERBLOCKS; i++) { |
| @@ -71,6 +72,12 @@ static u16 ocfs2_calc_new_backup_super(struct inode *inode, · 6 unmodified lines | ||
| 71 | 72 | else if (gd_blkno > lgd_blkno) |
| 72 | 73 | break; |
| 73 | 74 | |
| 75 | + /* check if already done backup super */ | |
| 76 | + lgd_cluster = ocfs2_blocks_to_clusters(inode->i_sb, lgd_blkno); | |
| 77 | + lgd_cluster += old_bg_clusters; | |
| 78 | + if (lgd_cluster >= cluster) | |
| 79 | + continue; | |
| 80 | + | |
| 74 | 81 | if (set) |
| 75 | 82 | ocfs2_set_bit(cluster % cl_cpg, |
| 76 | 83 | (unsigned long *)gd->bg_bitmap); |
| @@ -99,6 +106,7 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle, · 22 unmodified lines | ||
| 99 | 106 | u16 chain, num_bits, backups = 0; |
| 100 | 107 | u16 cl_bpc = le16_to_cpu(cl->cl_bpc); |
| 101 | 108 | u16 cl_cpg = le16_to_cpu(cl->cl_cpg); |
| 109 | + u16 old_bg_clusters; | |
| 102 | 110 | |
| 103 | 111 | trace_ocfs2_update_last_group_and_inode(new_clusters, |
| 104 | 112 | first_new_cluster); |
| @@ -112,6 +120,7 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle, · 7 unmodified lines | ||
| 112 | 120 | |
| 113 | 121 | group = (struct ocfs2_group_desc *)group_bh->b_data; |
| 114 | 122 | |
| 123 | + old_bg_clusters = le16_to_cpu(group->bg_bits) / cl_bpc; | |
| 115 | 124 | /* update the group first. */ |
| 116 | 125 | num_bits = new_clusters * cl_bpc; |
| 117 | 126 | le16_add_cpu(&group->bg_bits, num_bits); |
| @@ -125,7 +134,7 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle, · 7 unmodified lines | ||
| 125 | 134 | OCFS2_FEATURE_COMPAT_BACKUP_SB)) { |
| 126 | 135 | backups = ocfs2_calc_new_backup_super(bm_inode, |
| 127 | 136 | group, |
| 128 | − cl_cpg, 1); | |
| 137 | + cl_cpg, old_bg_clusters, 1); | |
| 129 | 138 | le16_add_cpu(&group->bg_free_bits_count, -1 * backups); |
| 130 | 139 | } |
| 131 | 140 | |
| @@ -163,7 +172,7 @@ out_rollback: · 31 unmodified lines | ||
| 163 | 172 | if (ret < 0) { |
| 164 | 173 | ocfs2_calc_new_backup_super(bm_inode, |
| 165 | 174 | group, |
| 166 | − cl_cpg, 0); | |
| 175 | + cl_cpg, old_bg_clusters, 0); | |
| 167 | 176 | le16_add_cpu(&group->bg_free_bits_count, backups); |
| 168 | 177 | le16_add_cpu(&group->bg_bits, -1 * num_bits); |
| 169 | 178 | le16_add_cpu(&group->bg_free_bits_count, -1 * num_bits); |
| @@ -2494,6 +2494,7 @@ static ssize_t proc_coredump_filter_write(struct file *file, · 2493 unmodified lines | ||
| 2494 | 2494 | mm = get_task_mm(task); |
| 2495 | 2495 | if (!mm) |
| 2496 | 2496 | goto out_no_mm; |
| 2497 | + ret = 0; | |
| 2497 | 2498 | |
| 2498 | 2499 | for (i = 0, mask = 1; i < MMF_DUMP_FILTER_BITS; i++, mask <<= 1) { |
| 2499 | 2500 | if (val & mask) |
| @@ -797,6 +797,7 @@ extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t, · 796 unmodified lines | ||
| 797 | 797 | extern int blk_queue_enter(struct request_queue *q, gfp_t gfp); |
| 798 | 798 | extern void blk_queue_exit(struct request_queue *q); |
| 799 | 799 | extern void blk_start_queue(struct request_queue *q); |
| 800 | +extern void blk_start_queue_async(struct request_queue *q); | |
| 800 | 801 | extern void blk_stop_queue(struct request_queue *q); |
| 801 | 802 | extern void blk_sync_queue(struct request_queue *q); |
| 802 | 803 | extern void __blk_stop_queue(struct request_queue *q); |
| @@ -29,7 +29,11 @@ · 28 unmodified lines | ||
| 29 | 29 | /* A few generic types ... taken from ses-2 */ |
| 30 | 30 | enum enclosure_component_type { |
| 31 | 31 | ENCLOSURE_COMPONENT_DEVICE = 0x01, |
| 32 | + ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS = 0x07, | |
| 33 | + ENCLOSURE_COMPONENT_SCSI_TARGET_PORT = 0x14, | |
| 34 | + ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT = 0x15, | |
| 32 | 35 | ENCLOSURE_COMPONENT_ARRAY_DEVICE = 0x17, |
| 36 | + ENCLOSURE_COMPONENT_SAS_EXPANDER = 0x18, | |
| 33 | 37 | }; |
| 34 | 38 | |
| 35 | 39 | /* ses-2 common element status */ |
| @@ -493,6 +493,25 @@ static inline void bpf_jit_free(struct bpf_prog *fp) · 492 unmodified lines | ||
| 493 | 493 | |
| 494 | 494 | #define BPF_ANC BIT(15) |
| 495 | 495 | |
| 496 | +static inline bool bpf_needs_clear_a(const struct sock_filter *first) | |
| 497 | +{ | |
| 498 | + switch (first->code) { | |
| 499 | + case BPF_RET | BPF_K: | |
| 500 | + case BPF_LD | BPF_W | BPF_LEN: | |
| 501 | + return false; | |
| 502 | + | |
| 503 | + case BPF_LD | BPF_W | BPF_ABS: | |
| 504 | + case BPF_LD | BPF_H | BPF_ABS: | |
| 505 | + case BPF_LD | BPF_B | BPF_ABS: | |
| 506 | + if (first->k == SKF_AD_OFF + SKF_AD_ALU_XOR_X) | |
| 507 | + return true; | |
| 508 | + return false; | |
| 509 | + | |
| 510 | + default: | |
| 511 | + return true; | |
| 512 | + } | |
| 513 | +} | |
| 514 | + | |
| 496 | 515 | static inline u16 bpf_anc_helper(const struct sock_filter *ftest) |
| 497 | 516 | { |
| 498 | 517 | BUG_ON(ftest->code & BPF_ANC); |
| @@ -586,6 +586,7 @@ extern int ftrace_arch_read_dyn_info(char *buf, int size); · 585 unmodified lines | ||
| 586 | 586 | |
| 587 | 587 | extern int skip_trace(unsigned long ip); |
| 588 | 588 | extern void ftrace_module_init(struct module *mod); |
| 589 | +extern void ftrace_release_mod(struct module *mod); | |
| 589 | 590 | |
| 590 | 591 | extern void ftrace_disable_daemon(void); |
| 591 | 592 | extern void ftrace_enable_daemon(void); |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | #ifndef LINUX_MM_DEBUG_H |
| 2 | 2 | #define LINUX_MM_DEBUG_H 1 |
| 3 | 3 | |
| 4 | +#include <linux/bug.h> | |
| 4 | 5 | #include <linux/stringify.h> |
| 5 | 6 | |
| 6 | 7 | struct page; |
| @@ -25,7 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #define SNOR_MFR_MACRONIX CFI_MFR_MACRONIX |
| 26 | 26 | #define SNOR_MFR_SPANSION CFI_MFR_AMD |
| 27 | 27 | #define SNOR_MFR_SST CFI_MFR_SST |
| 28 | −#define SNOR_MFR_WINBOND 0xef | |
| 28 | +#define SNOR_MFR_WINBOND 0xef /* Also used by some Spansion */ | |
| 29 | 29 | |
| 30 | 30 | /* |
| 31 | 31 | * Note on opcode nomenclature: some opcodes have a format like |
| @@ -2084,7 +2084,7 @@ struct pcpu_sw_netstats { · 2083 unmodified lines | ||
| 2084 | 2084 | }) |
| 2085 | 2085 | |
| 2086 | 2086 | #define netdev_alloc_pcpu_stats(type) \ |
| 2087 | − __netdev_alloc_pcpu_stats(type, GFP_KERNEL); | |
| 2087 | + __netdev_alloc_pcpu_stats(type, GFP_KERNEL) | |
| 2088 | 2088 | |
| 2089 | 2089 | #include <linux/notifier.h> |
| 2090 | 2090 | |
| @@ -14,7 +14,7 @@ struct nfnl_callback { · 13 unmodified lines | ||
| 14 | 14 | int (*call_rcu)(struct sock *nl, struct sk_buff *skb, |
| 15 | 15 | const struct nlmsghdr *nlh, |
| 16 | 16 | const struct nlattr * const cda[]); |
| 17 | − int (*call_batch)(struct sock *nl, struct sk_buff *skb, | |
| 17 | + int (*call_batch)(struct net *net, struct sock *nl, struct sk_buff *skb, | |
| 18 | 18 | const struct nlmsghdr *nlh, |
| 19 | 19 | const struct nlattr * const cda[]); |
| 20 | 20 | const struct nla_policy *policy; /* netlink attribute policy */ |
| @@ -72,7 +72,7 @@ struct edma_soc_info { · 71 unmodified lines | ||
| 72 | 72 | struct edma_rsv_info *rsv; |
| 73 | 73 | |
| 74 | 74 | /* List of channels allocated for memcpy, terminated with -1 */ |
| 75 | − s16 *memcpy_channels; | |
| 75 | + s32 *memcpy_channels; | |
| 76 | 76 | |
| 77 | 77 | s8 (*queue_priority_mapping)[2]; |
| 78 | 78 | const s16 (*xbar_chans)[2]; |
| @@ -9,6 +9,8 @@ · 8 unmodified lines | ||
| 9 | 9 | #ifndef __COMMON_HSI__ |
| 10 | 10 | #define __COMMON_HSI__ |
| 11 | 11 | |
| 12 | +#define CORE_SPQE_PAGE_SIZE_BYTES 4096 | |
| 13 | + | |
| 12 | 14 | #define FW_MAJOR_VERSION 8 |
| 13 | 15 | #define FW_MINOR_VERSION 4 |
| 14 | 16 | #define FW_REVISION_VERSION 2 |
| @@ -111,7 +111,8 @@ static inline u16 qed_chain_get_elem_left(struct qed_chain *p_chain) · 110 unmodified lines | ||
| 111 | 111 | used = ((u32)0x10000u + (u32)(p_chain->prod_idx)) - |
| 112 | 112 | (u32)p_chain->cons_idx; |
| 113 | 113 | if (p_chain->mode == QED_CHAIN_MODE_NEXT_PTR) |
| 114 | − used -= (used / p_chain->elem_per_page); | |
| 114 | + used -= p_chain->prod_idx / p_chain->elem_per_page - | |
| 115 | + p_chain->cons_idx / p_chain->elem_per_page; | |
| 115 | 116 | |
| 116 | 117 | return p_chain->capacity - used; |
| 117 | 118 | } |
| @@ -19,6 +19,7 @@ · 18 unmodified lines | ||
| 19 | 19 | |
| 20 | 20 | #include <linux/atomic.h> |
| 21 | 21 | #include <linux/compiler.h> |
| 22 | +#include <linux/err.h> | |
| 22 | 23 | #include <linux/errno.h> |
| 23 | 24 | #include <linux/jhash.h> |
| 24 | 25 | #include <linux/list_nulls.h> |
| @@ -339,10 +340,11 @@ static inline int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, · 314 unmodified lines | ||
| 339 | 340 | int rhashtable_init(struct rhashtable *ht, |
| 340 | 341 | const struct rhashtable_params *params); |
| 341 | 342 | |
| 342 | −int rhashtable_insert_slow(struct rhashtable *ht, const void *key, | |
| 343 | − struct rhash_head *obj, | |
| 344 | − struct bucket_table *old_tbl); | |
| 345 | −int rhashtable_insert_rehash(struct rhashtable *ht); | |
| 343 | +struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht, | |
| 344 | + const void *key, | |
| 345 | + struct rhash_head *obj, | |
| 346 | + struct bucket_table *old_tbl); | |
| 347 | +int rhashtable_insert_rehash(struct rhashtable *ht, struct bucket_table *tbl); | |
| 346 | 348 | |
| 347 | 349 | int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter); |
| 348 | 350 | void rhashtable_walk_exit(struct rhashtable_iter *iter); |
| @@ -598,9 +600,11 @@ restart: · 249 unmodified lines | ||
| 598 | 600 | |
| 599 | 601 | new_tbl = rht_dereference_rcu(tbl->future_tbl, ht); |
| 600 | 602 | if (unlikely(new_tbl)) { |
| 601 | − err = rhashtable_insert_slow(ht, key, obj, new_tbl); | |
| 602 | − if (err == -EAGAIN) | |
| 603 | + tbl = rhashtable_insert_slow(ht, key, obj, new_tbl); | |
| 604 | + if (!IS_ERR_OR_NULL(tbl)) | |
| 603 | 605 | goto slow_path; |
| 606 | + | |
| 607 | + err = PTR_ERR(tbl); | |
| 604 | 608 | goto out; |
| 605 | 609 | } |
| 606 | 610 | |
| @@ -611,7 +615,7 @@ restart: · 4 unmodified lines | ||
| 611 | 615 | if (unlikely(rht_grow_above_100(ht, tbl))) { |
| 612 | 616 | slow_path: |
| 613 | 617 | spin_unlock_bh(lock); |
| 614 | − err = rhashtable_insert_rehash(ht); | |
| 618 | + err = rhashtable_insert_rehash(ht, tbl); | |
| 615 | 619 | rcu_read_unlock(); |
| 616 | 620 | if (err) |
| 617 | 621 | return err; |
| @@ -1,17 +0,0 @@ | ||
| 1 | −#ifndef __ROTARY_ENCODER_H__ | |
| 2 | −#define __ROTARY_ENCODER_H__ | |
| 3 | − | |
| 4 | −struct rotary_encoder_platform_data { | |
| 5 | − unsigned int steps; | |
| 6 | − unsigned int axis; | |
| 7 | − unsigned int gpio_a; | |
| 8 | − unsigned int gpio_b; | |
| 9 | − unsigned int inverted_a; | |
| 10 | − unsigned int inverted_b; | |
| 11 | − unsigned int steps_per_period; | |
| 12 | − bool relative_axis; | |
| 13 | − bool rollover; | |
| 14 | − bool wakeup_source; | |
| 15 | −}; | |
| 16 | − | |
| 17 | −#endif /* __ROTARY_ENCODER_H__ */ | |
| @@ -1455,14 +1455,15 @@ struct task_struct { · 1454 unmodified lines | ||
| 1455 | 1455 | /* Used for emulating ABI behavior of previous Linux versions */ |
| 1456 | 1456 | unsigned int personality; |
| 1457 | 1457 | |
| 1458 | − unsigned in_execve:1; /* Tell the LSMs that the process is doing an | |
| 1459 | − * execve */ | |
| 1460 | − unsigned in_iowait:1; | |
| 1461 | − | |
| 1462 | − /* Revert to default priority/policy when forking */ | |
| 1458 | + /* scheduler bits, serialized by scheduler locks */ | |
| 1463 | 1459 | unsigned sched_reset_on_fork:1; |
| 1464 | 1460 | unsigned sched_contributes_to_load:1; |
| 1465 | 1461 | unsigned sched_migrated:1; |
| 1462 | + unsigned :0; /* force alignment to the next boundary */ | |
| 1463 | + | |
| 1464 | + /* unserialized, strictly 'current' */ | |
| 1465 | + unsigned in_execve:1; /* bit to tell LSMs we're in execve */ | |
| 1466 | + unsigned in_iowait:1; | |
| 1466 | 1467 | #ifdef CONFIG_MEMCG |
| 1467 | 1468 | unsigned memcg_may_oom:1; |
| 1468 | 1469 | #endif |
| @@ -2002,7 +2003,8 @@ static inline int pid_alive(const struct task_struct *p) · 533 unmodified lines | ||
| 2002 | 2003 | } |
| 2003 | 2004 | |
| 2004 | 2005 | /** |
| 2005 | − * is_global_init - check if a task structure is init | |
| 2006 | + * is_global_init - check if a task structure is init. Since init | |
| 2007 | + * is free to have sub-threads we need to check tgid. | |
| 2006 | 2008 | * @tsk: Task structure to be checked. |
| 2007 | 2009 | * |
| 2008 | 2010 | * Check if a task structure is the first user space task the kernel created. |
| @@ -2011,7 +2013,7 @@ static inline int pid_alive(const struct task_struct *p) · 2 unmodified lines | ||
| 2011 | 2013 | */ |
| 2012 | 2014 | static inline int is_global_init(struct task_struct *tsk) |
| 2013 | 2015 | { |
| 2014 | − return tsk->pid == 1; | |
| 2016 | + return task_tgid_nr(tsk) == 1; | |
| 2015 | 2017 | } |
| 2016 | 2018 | |
| 2017 | 2019 | extern struct pid *cad_pid; |
| @@ -138,6 +138,7 @@ struct cdc_ncm_ctx { · 137 unmodified lines | ||
| 138 | 138 | }; |
| 139 | 139 | |
| 140 | 140 | u8 cdc_ncm_select_altsetting(struct usb_interface *intf); |
| 141 | +int cdc_ncm_change_mtu(struct net_device *net, int new_mtu); | |
| 141 | 142 | int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting, int drvflags); |
| 142 | 143 | void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf); |
| 143 | 144 | struct sk_buff *cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign); |
| @@ -176,11 +176,11 @@ extern void zone_statistics(struct zone *, struct zone *, gfp_t gfp); · 175 unmodified lines | ||
| 176 | 176 | #define sub_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, -(__d)) |
| 177 | 177 | |
| 178 | 178 | #ifdef CONFIG_SMP |
| 179 | −void __mod_zone_page_state(struct zone *, enum zone_stat_item item, int); | |
| 179 | +void __mod_zone_page_state(struct zone *, enum zone_stat_item item, long); | |
| 180 | 180 | void __inc_zone_page_state(struct page *, enum zone_stat_item); |
| 181 | 181 | void __dec_zone_page_state(struct page *, enum zone_stat_item); |
| 182 | 182 | |
| 183 | −void mod_zone_page_state(struct zone *, enum zone_stat_item, int); | |
| 183 | +void mod_zone_page_state(struct zone *, enum zone_stat_item, long); | |
| 184 | 184 | void inc_zone_page_state(struct page *, enum zone_stat_item); |
| 185 | 185 | void dec_zone_page_state(struct page *, enum zone_stat_item); |
| 186 | 186 | |
| @@ -205,7 +205,7 @@ void set_pgdat_percpu_threshold(pg_data_t *pgdat, · 18 unmodified lines | ||
| 205 | 205 | * The functions directly modify the zone and global counters. |
| 206 | 206 | */ |
| 207 | 207 | static inline void __mod_zone_page_state(struct zone *zone, |
| 208 | − enum zone_stat_item item, int delta) | |
| 208 | + enum zone_stat_item item, long delta) | |
| 209 | 209 | { |
| 210 | 210 | zone_page_state_add(delta, zone, item); |
| 211 | 211 | } |
| @@ -322,6 +322,39 @@ static inline void skb_dst_force(struct sk_buff *skb) · 321 unmodified lines | ||
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | +/** | |
| 326 | + * dst_hold_safe - Take a reference on a dst if possible | |
| 327 | + * @dst: pointer to dst entry | |
| 328 | + * | |
| 329 | + * This helper returns false if it could not safely | |
| 330 | + * take a reference on a dst. | |
| 331 | + */ | |
| 332 | +static inline bool dst_hold_safe(struct dst_entry *dst) | |
| 333 | +{ | |
| 334 | + if (dst->flags & DST_NOCACHE) | |
| 335 | + return atomic_inc_not_zero(&dst->__refcnt); | |
| 336 | + dst_hold(dst); | |
| 337 | + return true; | |
| 338 | +} | |
| 339 | + | |
| 340 | +/** | |
| 341 | + * skb_dst_force_safe - makes sure skb dst is refcounted | |
| 342 | + * @skb: buffer | |
| 343 | + * | |
| 344 | + * If dst is not yet refcounted and not destroyed, grab a ref on it. | |
| 345 | + */ | |
| 346 | +static inline void skb_dst_force_safe(struct sk_buff *skb) | |
| 347 | +{ | |
| 348 | + if (skb_dst_is_noref(skb)) { | |
| 349 | + struct dst_entry *dst = skb_dst(skb); | |
| 350 | + | |
| 351 | + if (!dst_hold_safe(dst)) | |
| 352 | + dst = NULL; | |
| 353 | + | |
| 354 | + skb->_skb_refdst = (unsigned long)dst; | |
| 355 | + } | |
| 356 | +} | |
| 357 | + | |
| 325 | 358 | |
| 326 | 359 | /** |
| 327 | 360 | * __skb_tunnel_rx - prepare skb for rx reinsert |
| @@ -210,18 +210,37 @@ struct inet_sock { · 209 unmodified lines | ||
| 210 | 210 | #define IP_CMSG_ORIGDSTADDR BIT(6) |
| 211 | 211 | #define IP_CMSG_CHECKSUM BIT(7) |
| 212 | 212 | |
| 213 | −/* SYNACK messages might be attached to request sockets. | |
| 213 | +/** | |
| 214 | + * sk_to_full_sk - Access to a full socket | |
| 215 | + * @sk: pointer to a socket | |
| 216 | + * | |
| 217 | + * SYNACK messages might be attached to request sockets. | |
| 214 | 218 | * Some places want to reach the listener in this case. |
| 215 | 219 | */ |
| 216 | −static inline struct sock *skb_to_full_sk(const struct sk_buff *skb) | |
| 220 | +static inline struct sock *sk_to_full_sk(struct sock *sk) | |
| 217 | 221 | { |
| 218 | − struct sock *sk = skb->sk; | |
| 219 | − | |
| 222 | +#ifdef CONFIG_INET | |
| 220 | 223 | if (sk && sk->sk_state == TCP_NEW_SYN_RECV) |
| 221 | 224 | sk = inet_reqsk(sk)->rsk_listener; |
| 225 | +#endif | |
| 226 | + return sk; | |
| 227 | +} | |
| 228 | + | |
| 229 | +/* sk_to_full_sk() variant with a const argument */ | |
| 230 | +static inline const struct sock *sk_const_to_full_sk(const struct sock *sk) | |
| 231 | +{ | |
| 232 | +#ifdef CONFIG_INET | |
| 233 | + if (sk && sk->sk_state == TCP_NEW_SYN_RECV) | |
| 234 | + sk = ((const struct request_sock *)sk)->rsk_listener; | |
| 235 | +#endif | |
| 222 | 236 | return sk; |
| 223 | 237 | } |
| 224 | 238 | |
| 239 | +static inline struct sock *skb_to_full_sk(const struct sk_buff *skb) | |
| 240 | +{ | |
| 241 | + return sk_to_full_sk(skb->sk); | |
| 242 | +} | |
| 243 | + | |
| 225 | 244 | static inline struct inet_sock *inet_sk(const struct sock *sk) |
| 226 | 245 | { |
| 227 | 246 | return (struct inet_sock *)sk; |
| @@ -78,6 +78,7 @@ void inet_initpeers(void) __init; · 77 unmodified lines | ||
| 78 | 78 | static inline void inetpeer_set_addr_v4(struct inetpeer_addr *iaddr, __be32 ip) |
| 79 | 79 | { |
| 80 | 80 | iaddr->a4.addr = ip; |
| 81 | + iaddr->a4.vif = 0; | |
| 81 | 82 | iaddr->family = AF_INET; |
| 82 | 83 | } |
| 83 | 84 | |
| @@ -29,7 +29,7 @@ struct l3mdev_ops { · 28 unmodified lines | ||
| 29 | 29 | /* IPv4 ops */ |
| 30 | 30 | struct rtable * (*l3mdev_get_rtable)(const struct net_device *dev, |
| 31 | 31 | const struct flowi4 *fl4); |
| 32 | − void (*l3mdev_get_saddr)(struct net_device *dev, | |
| 32 | + int (*l3mdev_get_saddr)(struct net_device *dev, | |
| 33 | 33 | struct flowi4 *fl4); |
| 34 | 34 | |
| 35 | 35 | /* IPv6 ops */ |
| @@ -112,10 +112,11 @@ static inline bool netif_index_is_l3_master(struct net *net, int ifindex) · 76 unmodified lines | ||
| 112 | 112 | return rc; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | −static inline void l3mdev_get_saddr(struct net *net, int ifindex, | |
| 116 | − struct flowi4 *fl4) | |
| 115 | +static inline int l3mdev_get_saddr(struct net *net, int ifindex, | |
| 116 | + struct flowi4 *fl4) | |
| 117 | 117 | { |
| 118 | 118 | struct net_device *dev; |
| 119 | + int rc = 0; | |
| 119 | 120 | |
| 120 | 121 | if (ifindex) { |
| 121 | 122 | |
| @@ -124,11 +125,13 @@ static inline void l3mdev_get_saddr(struct net *net, int ifindex, · 2 unmodified lines | ||
| 124 | 125 | dev = dev_get_by_index_rcu(net, ifindex); |
| 125 | 126 | if (dev && netif_is_l3_master(dev) && |
| 126 | 127 | dev->l3mdev_ops->l3mdev_get_saddr) { |
| 127 | − dev->l3mdev_ops->l3mdev_get_saddr(dev, fl4); | |
| 128 | + rc = dev->l3mdev_ops->l3mdev_get_saddr(dev, fl4); | |
| 128 | 129 | } |
| 129 | 130 | |
| 130 | 131 | rcu_read_unlock(); |
| 131 | 132 | } |
| 133 | + | |
| 134 | + return rc; | |
| 132 | 135 | } |
| 133 | 136 | |
| 134 | 137 | static inline struct dst_entry *l3mdev_get_rt6_dst(const struct net_device *dev, |
| @@ -200,9 +203,10 @@ static inline bool netif_index_is_l3_master(struct net *net, int ifindex) · 65 unmodified lines | ||
| 200 | 203 | return false; |
| 201 | 204 | } |
| 202 | 205 | |
| 203 | −static inline void l3mdev_get_saddr(struct net *net, int ifindex, | |
| 204 | − struct flowi4 *fl4) | |
| 206 | +static inline int l3mdev_get_saddr(struct net *net, int ifindex, | |
| 207 | + struct flowi4 *fl4) | |
| 205 | 208 | { |
| 209 | + return 0; | |
| 206 | 210 | } |
| 207 | 211 | |
| 208 | 212 | static inline |
| @@ -283,7 +283,12 @@ static inline struct rtable *ip_route_connect(struct flowi4 *fl4, · 282 unmodified lines | ||
| 283 | 283 | sport, dport, sk); |
| 284 | 284 | |
| 285 | 285 | if (!src && oif) { |
| 286 | − l3mdev_get_saddr(net, oif, fl4); | |
| 286 | + int rc; | |
| 287 | + | |
| 288 | + rc = l3mdev_get_saddr(net, oif, fl4); | |
| 289 | + if (rc < 0) | |
| 290 | + return ERR_PTR(rc); | |
| 291 | + | |
| 287 | 292 | src = fl4->saddr; |
| 288 | 293 | } |
| 289 | 294 | if (!dst || !src) { |
| @@ -1493,7 +1493,8 @@ struct sctp_association { · 1492 unmodified lines | ||
| 1493 | 1493 | * : SACK's are not delayed (see Section 6). |
| 1494 | 1494 | */ |
| 1495 | 1495 | __u8 sack_needed:1, /* Do we need to sack the peer? */ |
| 1496 | − sack_generation:1; | |
| 1496 | + sack_generation:1, | |
| 1497 | + zero_window_announced:1; | |
| 1497 | 1498 | __u32 sack_cnt; |
| 1498 | 1499 | |
| 1499 | 1500 | __u32 adaptation_ind; /* Adaptation Code point. */ |
| @@ -388,7 +388,7 @@ struct sock { · 387 unmodified lines | ||
| 388 | 388 | struct socket_wq *sk_wq_raw; |
| 389 | 389 | }; |
| 390 | 390 | #ifdef CONFIG_XFRM |
| 391 | − struct xfrm_policy *sk_policy[2]; | |
| 391 | + struct xfrm_policy __rcu *sk_policy[2]; | |
| 392 | 392 | #endif |
| 393 | 393 | struct dst_entry *sk_rx_dst; |
| 394 | 394 | struct dst_entry __rcu *sk_dst_cache; |
| @@ -404,6 +404,7 @@ struct sock { · 9 unmodified lines | ||
| 404 | 404 | sk_userlocks : 4, |
| 405 | 405 | sk_protocol : 8, |
| 406 | 406 | sk_type : 16; |
| 407 | +#define SK_PROTOCOL_MAX U8_MAX | |
| 407 | 408 | kmemcheck_bitfield_end(flags); |
| 408 | 409 | int sk_wmem_queued; |
| 409 | 410 | gfp_t sk_allocation; |
| @@ -740,6 +741,8 @@ enum sock_flags { · 330 unmodified lines | ||
| 740 | 741 | SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */ |
| 741 | 742 | }; |
| 742 | 743 | |
| 744 | +#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)) | |
| 745 | + | |
| 743 | 746 | static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) |
| 744 | 747 | { |
| 745 | 748 | nsk->sk_flags = osk->sk_flags; |
| @@ -814,7 +817,7 @@ void sk_stream_write_space(struct sock *sk); · 68 unmodified lines | ||
| 814 | 817 | static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb) |
| 815 | 818 | { |
| 816 | 819 | /* dont let skb dst not refcounted, we are going to leave rcu lock */ |
| 817 | − skb_dst_force(skb); | |
| 820 | + skb_dst_force_safe(skb); | |
| 818 | 821 | |
| 819 | 822 | if (!sk->sk_backlog.tail) |
| 820 | 823 | sk->sk_backlog.head = skb; |
| @@ -79,7 +79,7 @@ struct vxlanhdr { · 78 unmodified lines | ||
| 79 | 79 | }; |
| 80 | 80 | |
| 81 | 81 | /* VXLAN header flags. */ |
| 82 | −#define VXLAN_HF_RCO BIT(24) | |
| 82 | +#define VXLAN_HF_RCO BIT(21) | |
| 83 | 83 | #define VXLAN_HF_VNI BIT(27) |
| 84 | 84 | #define VXLAN_HF_GBP BIT(31) |
| 85 | 85 | |
| @@ -548,6 +548,7 @@ struct xfrm_policy { · 547 unmodified lines | ||
| 548 | 548 | u16 family; |
| 549 | 549 | struct xfrm_sec_ctx *security; |
| 550 | 550 | struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; |
| 551 | + struct rcu_head rcu; | |
| 551 | 552 | }; |
| 552 | 553 | |
| 553 | 554 | static inline struct net *xp_net(const struct xfrm_policy *xp) |
| @@ -1141,12 +1142,14 @@ static inline int xfrm6_route_forward(struct sk_buff *skb) · 587 unmodified lines | ||
| 1141 | 1142 | return xfrm_route_forward(skb, AF_INET6); |
| 1142 | 1143 | } |
| 1143 | 1144 | |
| 1144 | −int __xfrm_sk_clone_policy(struct sock *sk); | |
| 1145 | +int __xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk); | |
| 1145 | 1146 | |
| 1146 | −static inline int xfrm_sk_clone_policy(struct sock *sk) | |
| 1147 | +static inline int xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk) | |
| 1147 | 1148 | { |
| 1148 | − if (unlikely(sk->sk_policy[0] || sk->sk_policy[1])) | |
| 1149 | − return __xfrm_sk_clone_policy(sk); | |
| 1149 | + sk->sk_policy[0] = NULL; | |
| 1150 | + sk->sk_policy[1] = NULL; | |
| 1151 | + if (unlikely(osk->sk_policy[0] || osk->sk_policy[1])) | |
| 1152 | + return __xfrm_sk_clone_policy(sk, osk); | |
| 1150 | 1153 | return 0; |
| 1151 | 1154 | } |
| 1152 | 1155 | |
| @@ -1154,12 +1157,16 @@ int xfrm_policy_delete(struct xfrm_policy *pol, int dir); · 1 unmodified line | ||
| 1154 | 1157 | |
| 1155 | 1158 | static inline void xfrm_sk_free_policy(struct sock *sk) |
| 1156 | 1159 | { |
| 1157 | − if (unlikely(sk->sk_policy[0] != NULL)) { | |
| 1158 | − xfrm_policy_delete(sk->sk_policy[0], XFRM_POLICY_MAX); | |
| 1160 | + struct xfrm_policy *pol; | |
| 1161 | + | |
| 1162 | + pol = rcu_dereference_protected(sk->sk_policy[0], 1); | |
| 1163 | + if (unlikely(pol != NULL)) { | |
| 1164 | + xfrm_policy_delete(pol, XFRM_POLICY_MAX); | |
| 1159 | 1165 | sk->sk_policy[0] = NULL; |
| 1160 | 1166 | } |
| 1161 | − if (unlikely(sk->sk_policy[1] != NULL)) { | |
| 1162 | − xfrm_policy_delete(sk->sk_policy[1], XFRM_POLICY_MAX+1); | |
| 1167 | + pol = rcu_dereference_protected(sk->sk_policy[1], 1); | |
| 1168 | + if (unlikely(pol != NULL)) { | |
| 1169 | + xfrm_policy_delete(pol, XFRM_POLICY_MAX+1); | |
| 1163 | 1170 | sk->sk_policy[1] = NULL; |
| 1164 | 1171 | } |
| 1165 | 1172 | } |
| @@ -1169,7 +1176,7 @@ void xfrm_garbage_collect(struct net *net); · 3 unmodified lines | ||
| 1169 | 1176 | #else |
| 1170 | 1177 | |
| 1171 | 1178 | static inline void xfrm_sk_free_policy(struct sock *sk) {} |
| 1172 | −static inline int xfrm_sk_clone_policy(struct sock *sk) { return 0; } | |
| 1179 | +static inline int xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk) { return 0; } | |
| 1173 | 1180 | static inline int xfrm6_route_forward(struct sk_buff *skb) { return 1; } |
| 1174 | 1181 | static inline int xfrm4_route_forward(struct sk_buff *skb) { return 1; } |
| 1175 | 1182 | static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *skb) |
| @@ -1655,7 +1655,7 @@ extern const struct dev_pm_ops snd_soc_pm_ops; · 1654 unmodified lines | ||
| 1655 | 1655 | /* Helper functions */ |
| 1656 | 1656 | static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm) |
| 1657 | 1657 | { |
| 1658 | − mutex_lock(&dapm->card->dapm_mutex); | |
| 1658 | + mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); | |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) |
| @@ -186,6 +186,7 @@ header-y += if_tunnel.h · 185 unmodified lines | ||
| 186 | 186 | header-y += if_vlan.h |
| 187 | 187 | header-y += if_x25.h |
| 188 | 188 | header-y += igmp.h |
| 189 | +header-y += ila.h | |
| 189 | 190 | header-y += in6.h |
| 190 | 191 | header-y += inet_diag.h |
| 191 | 192 | header-y += in.h |
| @@ -628,7 +628,7 @@ struct ovs_action_hash { · 627 unmodified lines | ||
| 628 | 628 | * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the |
| 629 | 629 | * mask, the corresponding bit in the value is copied to the connection |
| 630 | 630 | * tracking mark field in the connection. |
| 631 | − * @OVS_CT_ATTR_LABEL: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN | |
| 631 | + * @OVS_CT_ATTR_LABELS: %OVS_CT_LABELS_LEN value followed by %OVS_CT_LABELS_LEN | |
| 632 | 632 | * mask. For each bit set in the mask, the corresponding bit in the value is |
| 633 | 633 | * copied to the connection tracking label field in the connection. |
| 634 | 634 | * @OVS_CT_ATTR_HELPER: variable length string defining conntrack ALG. |
| @@ -181,6 +181,20 @@ struct __name##_back_ring { \ · 180 unmodified lines | ||
| 181 | 181 | #define RING_GET_REQUEST(_r, _idx) \ |
| 182 | 182 | (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) |
| 183 | 183 | |
| 184 | +/* | |
| 185 | + * Get a local copy of a request. | |
| 186 | + * | |
| 187 | + * Use this in preference to RING_GET_REQUEST() so all processing is | |
| 188 | + * done on a local copy that cannot be modified by the other end. | |
| 189 | + * | |
| 190 | + * Note that https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 may cause this | |
| 191 | + * to be ineffective where _req is a struct which consists of only bitfields. | |
| 192 | + */ | |
| 193 | +#define RING_COPY_REQUEST(_r, _idx, _req) do { \ | |
| 194 | + /* Use volatile to force the copy into _req. */ \ | |
| 195 | + *(_req) = *(volatile typeof(_req))RING_GET_REQUEST(_r, _idx); \ | |
| 196 | +} while (0) | |
| 197 | + | |
| 184 | 198 | #define RING_GET_RESPONSE(_r, _idx) \ |
| 185 | 199 | (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp)) |
| 186 | 200 | |
| @@ -3154,15 +3154,16 @@ static int event_enable_on_exec(struct perf_event *event, · 3153 unmodified lines | ||
| 3154 | 3154 | * Enable all of a task's events that have been marked enable-on-exec. |
| 3155 | 3155 | * This expects task == current. |
| 3156 | 3156 | */ |
| 3157 | −static void perf_event_enable_on_exec(struct perf_event_context *ctx) | |
| 3157 | +static void perf_event_enable_on_exec(int ctxn) | |
| 3158 | 3158 | { |
| 3159 | − struct perf_event_context *clone_ctx = NULL; | |
| 3159 | + struct perf_event_context *ctx, *clone_ctx = NULL; | |
| 3160 | 3160 | struct perf_event *event; |
| 3161 | 3161 | unsigned long flags; |
| 3162 | 3162 | int enabled = 0; |
| 3163 | 3163 | int ret; |
| 3164 | 3164 | |
| 3165 | 3165 | local_irq_save(flags); |
| 3166 | + ctx = current->perf_event_ctxp[ctxn]; | |
| 3166 | 3167 | if (!ctx || !ctx->nr_events) |
| 3167 | 3168 | goto out; |
| 3168 | 3169 | |
| @@ -3205,17 +3206,11 @@ out: · 36 unmodified lines | ||
| 3205 | 3206 | |
| 3206 | 3207 | void perf_event_exec(void) |
| 3207 | 3208 | { |
| 3208 | − struct perf_event_context *ctx; | |
| 3209 | 3209 | int ctxn; |
| 3210 | 3210 | |
| 3211 | 3211 | rcu_read_lock(); |
| 3212 | − for_each_task_context_nr(ctxn) { | |
| 3213 | − ctx = current->perf_event_ctxp[ctxn]; | |
| 3214 | − if (!ctx) | |
| 3215 | − continue; | |
| 3216 | − | |
| 3217 | − perf_event_enable_on_exec(ctx); | |
| 3218 | − } | |
| 3212 | + for_each_task_context_nr(ctxn) | |
| 3213 | + perf_event_enable_on_exec(ctxn); | |
| 3219 | 3214 | rcu_read_unlock(); |
| 3220 | 3215 | } |
| 3221 | 3216 | |
| @@ -6493,9 +6488,6 @@ struct swevent_htable { · 3271 unmodified lines | ||
| 6493 | 6488 | |
| 6494 | 6489 | /* Recursion avoidance in each contexts */ |
| 6495 | 6490 | int recursion[PERF_NR_CONTEXTS]; |
| 6496 | − | |
| 6497 | − /* Keeps track of cpu being initialized/exited */ | |
| 6498 | − bool online; | |
| 6499 | 6491 | }; |
| 6500 | 6492 | |
| 6501 | 6493 | static DEFINE_PER_CPU(struct swevent_htable, swevent_htable); |
| @@ -6753,14 +6745,8 @@ static int perf_swevent_add(struct perf_event *event, int flags) · 251 unmodified lines | ||
| 6753 | 6745 | hwc->state = !(flags & PERF_EF_START); |
| 6754 | 6746 | |
| 6755 | 6747 | head = find_swevent_head(swhash, event); |
| 6756 | − if (!head) { | |
| 6757 | − /* | |
| 6758 | − * We can race with cpu hotplug code. Do not | |
| 6759 | − * WARN if the cpu just got unplugged. | |
| 6760 | − */ | |
| 6761 | − WARN_ON_ONCE(swhash->online); | |
| 6748 | + if (WARN_ON_ONCE(!head)) | |
| 6762 | 6749 | return -EINVAL; |
| 6763 | − } | |
| 6764 | 6750 | |
| 6765 | 6751 | hlist_add_head_rcu(&event->hlist_entry, head); |
| 6766 | 6752 | perf_event_update_userpage(event); |
| @@ -6828,7 +6814,6 @@ static int swevent_hlist_get_cpu(struct perf_event *event, int cpu) · 61 unmodified lines | ||
| 6828 | 6814 | int err = 0; |
| 6829 | 6815 | |
| 6830 | 6816 | mutex_lock(&swhash->hlist_mutex); |
| 6831 | − | |
| 6832 | 6817 | if (!swevent_hlist_deref(swhash) && cpu_online(cpu)) { |
| 6833 | 6818 | struct swevent_hlist *hlist; |
| 6834 | 6819 | |
| @@ -9291,7 +9276,6 @@ static void perf_event_init_cpu(int cpu) · 2456 unmodified lines | ||
| 9291 | 9276 | struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu); |
| 9292 | 9277 | |
| 9293 | 9278 | mutex_lock(&swhash->hlist_mutex); |
| 9294 | − swhash->online = true; | |
| 9295 | 9279 | if (swhash->hlist_refcount > 0) { |
| 9296 | 9280 | struct swevent_hlist *hlist; |
| 9297 | 9281 | |
| @@ -9333,14 +9317,7 @@ static void perf_event_exit_cpu_context(int cpu) · 35 unmodified lines | ||
| 9333 | 9317 | |
| 9334 | 9318 | static void perf_event_exit_cpu(int cpu) |
| 9335 | 9319 | { |
| 9336 | − struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu); | |
| 9337 | − | |
| 9338 | 9320 | perf_event_exit_cpu_context(cpu); |
| 9339 | − | |
| 9340 | − mutex_lock(&swhash->hlist_mutex); | |
| 9341 | − swhash->online = false; | |
| 9342 | − swevent_hlist_release(swhash); | |
| 9343 | − mutex_unlock(&swhash->hlist_mutex); | |
| 9344 | 9321 | } |
| 9345 | 9322 | #else |
| 9346 | 9323 | static inline void perf_event_exit_cpu(int cpu) { } |
| @@ -380,6 +380,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) · 379 unmodified lines | ||
| 380 | 380 | #endif |
| 381 | 381 | tsk->splice_pipe = NULL; |
| 382 | 382 | tsk->task_frag.page = NULL; |
| 383 | + tsk->wake_q.next = NULL; | |
| 383 | 384 | |
| 384 | 385 | account_kernel_stack(ti, 1); |
| 385 | 386 | |
| @@ -1434,6 +1434,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) · 1433 unmodified lines | ||
| 1434 | 1434 | if (!desc) |
| 1435 | 1435 | return NULL; |
| 1436 | 1436 | |
| 1437 | + chip_bus_lock(desc); | |
| 1437 | 1438 | raw_spin_lock_irqsave(&desc->lock, flags); |
| 1438 | 1439 | |
| 1439 | 1440 | /* |
| @@ -1447,7 +1448,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) · 7 unmodified lines | ||
| 1447 | 1448 | if (!action) { |
| 1448 | 1449 | WARN(1, "Trying to free already-free IRQ %d\n", irq); |
| 1449 | 1450 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
| 1450 | − | |
| 1451 | + chip_bus_sync_unlock(desc); | |
| 1451 | 1452 | return NULL; |
| 1452 | 1453 | } |
| 1453 | 1454 | |
| @@ -1475,6 +1476,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) · 21 unmodified lines | ||
| 1475 | 1476 | #endif |
| 1476 | 1477 | |
| 1477 | 1478 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
| 1479 | + chip_bus_sync_unlock(desc); | |
| 1478 | 1480 | |
| 1479 | 1481 | unregister_handler_proc(irq, action); |
| 1480 | 1482 | |
| @@ -1553,9 +1555,7 @@ void free_irq(unsigned int irq, void *dev_id) · 72 unmodified lines | ||
| 1553 | 1555 | desc->affinity_notify = NULL; |
| 1554 | 1556 | #endif |
| 1555 | 1557 | |
| 1556 | − chip_bus_lock(desc); | |
| 1557 | 1558 | kfree(__free_irq(irq, dev_id)); |
| 1558 | − chip_bus_sync_unlock(desc); | |
| 1559 | 1559 | } |
| 1560 | 1560 | EXPORT_SYMBOL(free_irq); |
| 1561 | 1561 | |
| @@ -93,10 +93,12 @@ bool osq_lock(struct optimistic_spin_queue *lock) · 92 unmodified lines | ||
| 93 | 93 | node->cpu = curr; |
| 94 | 94 | |
| 95 | 95 | /* |
| 96 | − * ACQUIRE semantics, pairs with corresponding RELEASE | |
| 97 | − * in unlock() uncontended, or fastpath. | |
| 96 | + * We need both ACQUIRE (pairs with corresponding RELEASE in | |
| 97 | + * unlock() uncontended, or fastpath) and RELEASE (to publish | |
| 98 | + * the node fields we just initialised) semantics when updating | |
| 99 | + * the lock tail. | |
| 98 | 100 | */ |
| 99 | − old = atomic_xchg_acquire(&lock->tail, curr); | |
| 101 | + old = atomic_xchg(&lock->tail, curr); | |
| 100 | 102 | if (old == OSQ_UNLOCKED_VAL) |
| 101 | 103 | return true; |
| 102 | 104 | |
| @@ -3571,6 +3571,12 @@ static int load_module(struct load_info *info, const char __user *uargs, · 3570 unmodified lines | ||
| 3571 | 3571 | synchronize_sched(); |
| 3572 | 3572 | mutex_unlock(&module_mutex); |
| 3573 | 3573 | free_module: |
| 3574 | + /* | |
| 3575 | + * Ftrace needs to clean up what it initialized. | |
| 3576 | + * This does nothing if ftrace_module_init() wasn't called, | |
| 3577 | + * but it must be called outside of module_mutex. | |
| 3578 | + */ | |
| 3579 | + ftrace_release_mod(mod); | |
| 3574 | 3580 | /* Free lock-classes; relies on the preceding sync_rcu() */ |
| 3575 | 3581 | lockdep_free_key_range(mod->module_core, mod->core_size); |
| 3576 | 3582 | |
| @@ -2689,7 +2689,7 @@ static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) · 2688 unmodified lines | ||
| 2689 | 2689 | int decayed, removed = 0; |
| 2690 | 2690 | |
| 2691 | 2691 | if (atomic_long_read(&cfs_rq->removed_load_avg)) { |
| 2692 | − long r = atomic_long_xchg(&cfs_rq->removed_load_avg, 0); | |
| 2692 | + s64 r = atomic_long_xchg(&cfs_rq->removed_load_avg, 0); | |
| 2693 | 2693 | sa->load_avg = max_t(long, sa->load_avg - r, 0); |
| 2694 | 2694 | sa->load_sum = max_t(s64, sa->load_sum - r * LOAD_AVG_MAX, 0); |
| 2695 | 2695 | removed = 1; |
| @@ -273,6 +273,7 @@ static const char **find_next(void *v, loff_t *pos) · 272 unmodified lines | ||
| 273 | 273 | if (*pos < last_index + start_index) |
| 274 | 274 | return __start___tracepoint_str + (*pos - last_index); |
| 275 | 275 | |
| 276 | + start_index += last_index; | |
| 276 | 277 | return find_next_mod_format(start_index, v, fmt, pos); |
| 277 | 278 | } |
| 278 | 279 | |
| @@ -1464,7 +1464,7 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size, · 1463 unmodified lines | ||
| 1464 | 1464 | entry->type = dma_debug_coherent; |
| 1465 | 1465 | entry->dev = dev; |
| 1466 | 1466 | entry->pfn = page_to_pfn(virt_to_page(virt)); |
| 1467 | − entry->offset = (size_t) virt & PAGE_MASK; | |
| 1467 | + entry->offset = (size_t) virt & ~PAGE_MASK; | |
| 1468 | 1468 | entry->size = size; |
| 1469 | 1469 | entry->dev_addr = dma_addr; |
| 1470 | 1470 | entry->direction = DMA_BIDIRECTIONAL; |
| @@ -1480,7 +1480,7 @@ void debug_dma_free_coherent(struct device *dev, size_t size, · 9 unmodified lines | ||
| 1480 | 1480 | .type = dma_debug_coherent, |
| 1481 | 1481 | .dev = dev, |
| 1482 | 1482 | .pfn = page_to_pfn(virt_to_page(virt)), |
| 1483 | − .offset = (size_t) virt & PAGE_MASK, | |
| 1483 | + .offset = (size_t) virt & ~PAGE_MASK, | |
| 1484 | 1484 | .dev_addr = addr, |
| 1485 | 1485 | .size = size, |
| 1486 | 1486 | .direction = DMA_BIDIRECTIONAL, |
| @@ -389,33 +389,31 @@ static bool rhashtable_check_elasticity(struct rhashtable *ht, · 388 unmodified lines | ||
| 389 | 389 | return false; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | −int rhashtable_insert_rehash(struct rhashtable *ht) | |
| 392 | +int rhashtable_insert_rehash(struct rhashtable *ht, | |
| 393 | + struct bucket_table *tbl) | |
| 393 | 394 | { |
| 394 | 395 | struct bucket_table *old_tbl; |
| 395 | 396 | struct bucket_table *new_tbl; |
| 396 | − struct bucket_table *tbl; | |
| 397 | 397 | unsigned int size; |
| 398 | 398 | int err; |
| 399 | 399 | |
| 400 | 400 | old_tbl = rht_dereference_rcu(ht->tbl, ht); |
| 401 | − tbl = rhashtable_last_table(ht, old_tbl); | |
| 402 | 401 | |
| 403 | 402 | size = tbl->size; |
| 404 | 403 | |
| 404 | + err = -EBUSY; | |
| 405 | + | |
| 405 | 406 | if (rht_grow_above_75(ht, tbl)) |
| 406 | 407 | size *= 2; |
| 407 | 408 | /* Do not schedule more than one rehash */ |
| 408 | 409 | else if (old_tbl != tbl) |
| 409 | − return -EBUSY; | |
| 410 | + goto fail; | |
| 411 | + | |
| 412 | + err = -ENOMEM; | |
| 410 | 413 | |
| 411 | 414 | new_tbl = bucket_table_alloc(ht, size, GFP_ATOMIC); |
| 412 | − if (new_tbl == NULL) { | |
| 413 | − /* Schedule async resize/rehash to try allocation | |
| 414 | − * non-atomic context. | |
| 415 | − */ | |
| 416 | − schedule_work(&ht->run_work); | |
| 417 | − return -ENOMEM; | |
| 418 | − } | |
| 415 | + if (new_tbl == NULL) | |
| 416 | + goto fail; | |
| 419 | 417 | |
| 420 | 418 | err = rhashtable_rehash_attach(ht, tbl, new_tbl); |
| 421 | 419 | if (err) { |
| @@ -426,12 +424,24 @@ int rhashtable_insert_rehash(struct rhashtable *ht) · 4 unmodified lines | ||
| 426 | 424 | schedule_work(&ht->run_work); |
| 427 | 425 | |
| 428 | 426 | return err; |
| 427 | + | |
| 428 | +fail: | |
| 429 | + /* Do not fail the insert if someone else did a rehash. */ | |
| 430 | + if (likely(rcu_dereference_raw(tbl->future_tbl))) | |
| 431 | + return 0; | |
| 432 | + | |
| 433 | + /* Schedule async rehash to retry allocation in process context. */ | |
| 434 | + if (err == -ENOMEM) | |
| 435 | + schedule_work(&ht->run_work); | |
| 436 | + | |
| 437 | + return err; | |
| 429 | 438 | } |
| 430 | 439 | EXPORT_SYMBOL_GPL(rhashtable_insert_rehash); |
| 431 | 440 | |
| 432 | −int rhashtable_insert_slow(struct rhashtable *ht, const void *key, | |
| 433 | − struct rhash_head *obj, | |
| 434 | − struct bucket_table *tbl) | |
| 441 | +struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht, | |
| 442 | + const void *key, | |
| 443 | + struct rhash_head *obj, | |
| 444 | + struct bucket_table *tbl) | |
| 435 | 445 | { |
| 436 | 446 | struct rhash_head *head; |
| 437 | 447 | unsigned int hash; |
| @@ -467,7 +477,12 @@ int rhashtable_insert_slow(struct rhashtable *ht, const void *key, · 29 unmodified lines | ||
| 467 | 477 | exit: |
| 468 | 478 | spin_unlock(rht_bucket_lock(tbl, hash)); |
| 469 | 479 | |
| 470 | − return err; | |
| 480 | + if (err == 0) | |
| 481 | + return NULL; | |
| 482 | + else if (err == -EAGAIN) | |
| 483 | + return tbl; | |
| 484 | + else | |
| 485 | + return ERR_PTR(err); | |
| 471 | 486 | } |
| 472 | 487 | EXPORT_SYMBOL_GPL(rhashtable_insert_slow); |
| 473 | 488 | |
| @@ -503,10 +518,11 @@ int rhashtable_walk_init(struct rhashtable *ht, struct rhashtable_iter *iter) · 29 unmodified lines | ||
| 503 | 518 | if (!iter->walker) |
| 504 | 519 | return -ENOMEM; |
| 505 | 520 | |
| 506 | − mutex_lock(&ht->mutex); | |
| 507 | − iter->walker->tbl = rht_dereference(ht->tbl, ht); | |
| 521 | + spin_lock(&ht->lock); | |
| 522 | + iter->walker->tbl = | |
| 523 | + rcu_dereference_protected(ht->tbl, lockdep_is_held(&ht->lock)); | |
| 508 | 524 | list_add(&iter->walker->list, &iter->walker->tbl->walkers); |
| 509 | − mutex_unlock(&ht->mutex); | |
| 525 | + spin_unlock(&ht->lock); | |
| 510 | 526 | |
| 511 | 527 | return 0; |
| 512 | 528 | } |
| @@ -520,10 +536,10 @@ EXPORT_SYMBOL_GPL(rhashtable_walk_init); · 7 unmodified lines | ||
| 520 | 536 | */ |
| 521 | 537 | void rhashtable_walk_exit(struct rhashtable_iter *iter) |
| 522 | 538 | { |
| 523 | − mutex_lock(&iter->ht->mutex); | |
| 539 | + spin_lock(&iter->ht->lock); | |
| 524 | 540 | if (iter->walker->tbl) |
| 525 | 541 | list_del(&iter->walker->list); |
| 526 | − mutex_unlock(&iter->ht->mutex); | |
| 542 | + spin_unlock(&iter->ht->lock); | |
| 527 | 543 | kfree(iter->walker); |
| 528 | 544 | } |
| 529 | 545 | EXPORT_SYMBOL_GPL(rhashtable_walk_exit); |
| @@ -547,14 +563,12 @@ int rhashtable_walk_start(struct rhashtable_iter *iter) · 17 unmodified lines | ||
| 547 | 563 | { |
| 548 | 564 | struct rhashtable *ht = iter->ht; |
| 549 | 565 | |
| 550 | − mutex_lock(&ht->mutex); | |
| 566 | + rcu_read_lock(); | |
| 551 | 567 | |
| 568 | + spin_lock(&ht->lock); | |
| 552 | 569 | if (iter->walker->tbl) |
| 553 | 570 | list_del(&iter->walker->list); |
| 554 | − | |
| 555 | − rcu_read_lock(); | |
| 556 | − | |
| 557 | − mutex_unlock(&ht->mutex); | |
| 571 | + spin_unlock(&ht->lock); | |
| 558 | 572 | |
| 559 | 573 | if (!iter->walker->tbl) { |
| 560 | 574 | iter->walker->tbl = rht_dereference_rcu(ht->tbl, ht); |
| @@ -723,9 +737,6 @@ int rhashtable_init(struct rhashtable *ht, · 162 unmodified lines | ||
| 723 | 737 | if (params->nulls_base && params->nulls_base < (1U << RHT_BASE_SHIFT)) |
| 724 | 738 | return -EINVAL; |
| 725 | 739 | |
| 726 | − if (params->nelem_hint) | |
| 727 | − size = rounded_hashtable_size(params); | |
| 728 | − | |
| 729 | 740 | memset(ht, 0, sizeof(*ht)); |
| 730 | 741 | mutex_init(&ht->mutex); |
| 731 | 742 | spin_lock_init(&ht->lock); |
| @@ -745,6 +756,9 @@ int rhashtable_init(struct rhashtable *ht, · 13 unmodified lines | ||
| 745 | 756 | |
| 746 | 757 | ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); |
| 747 | 758 | |
| 759 | + if (params->nelem_hint) | |
| 760 | + size = rounded_hashtable_size(&ht->p); | |
| 761 | + | |
| 748 | 762 | /* The maximum (not average) chain length grows with the |
| 749 | 763 | * size of the hash table, at a rate of (log N)/(log log N). |
| 750 | 764 | * The value of 16 is selected so that even if the hash |
| @@ -903,14 +903,20 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, · 902 unmodified lines | ||
| 903 | 903 | if (prev && reclaim->generation != iter->generation) |
| 904 | 904 | goto out_unlock; |
| 905 | 905 | |
| 906 | − do { | |
| 906 | + while (1) { | |
| 907 | 907 | pos = READ_ONCE(iter->position); |
| 908 | + if (!pos || css_tryget(&pos->css)) | |
| 909 | + break; | |
| 908 | 910 | /* |
| 909 | − * A racing update may change the position and | |
| 910 | − * put the last reference, hence css_tryget(), | |
| 911 | − * or retry to see the updated position. | |
| 911 | + * css reference reached zero, so iter->position will | |
| 912 | + * be cleared by ->css_released. However, we should not | |
| 913 | + * rely on this happening soon, because ->css_released | |
| 914 | + * is called from a work queue, and by busy-waiting we | |
| 915 | + * might block it. So we clear iter->position right | |
| 916 | + * away. | |
| 912 | 917 | */ |
| 913 | − } while (pos && !css_tryget(&pos->css)); | |
| 918 | + (void)cmpxchg(&iter->position, pos, NULL); | |
| 919 | + } | |
| 914 | 920 | } |
| 915 | 921 | |
| 916 | 922 | if (pos) |
| @@ -956,17 +962,13 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, · 39 unmodified lines | ||
| 956 | 962 | } |
| 957 | 963 | |
| 958 | 964 | if (reclaim) { |
| 959 | − if (cmpxchg(&iter->position, pos, memcg) == pos) { | |
| 960 | − if (memcg) | |
| 961 | − css_get(&memcg->css); | |
| 962 | − if (pos) | |
| 963 | − css_put(&pos->css); | |
| 964 | − } | |
| 965 | − | |
| 966 | 965 | /* |
| 967 | − * pairs with css_tryget when dereferencing iter->position | |
| 968 | − * above. | |
| 966 | + * The position could have already been updated by a competing | |
| 967 | + * thread, so check that the value hasn't changed since we read | |
| 968 | + * it to avoid reclaiming from the same cgroup twice. | |
| 969 | 969 | */ |
| 970 | + (void)cmpxchg(&iter->position, pos, memcg); | |
| 971 | + | |
| 970 | 972 | if (pos) |
| 971 | 973 | css_put(&pos->css); |
| 972 | 974 | |
| @@ -999,6 +1001,28 @@ void mem_cgroup_iter_break(struct mem_cgroup *root, · 26 unmodified lines | ||
| 999 | 1001 | css_put(&prev->css); |
| 1000 | 1002 | } |
| 1001 | 1003 | |
| 1004 | +static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg) | |
| 1005 | +{ | |
| 1006 | + struct mem_cgroup *memcg = dead_memcg; | |
| 1007 | + struct mem_cgroup_reclaim_iter *iter; | |
| 1008 | + struct mem_cgroup_per_zone *mz; | |
| 1009 | + int nid, zid; | |
| 1010 | + int i; | |
| 1011 | + | |
| 1012 | + while ((memcg = parent_mem_cgroup(memcg))) { | |
| 1013 | + for_each_node(nid) { | |
| 1014 | + for (zid = 0; zid < MAX_NR_ZONES; zid++) { | |
| 1015 | + mz = &memcg->nodeinfo[nid]->zoneinfo[zid]; | |
| 1016 | + for (i = 0; i <= DEF_PRIORITY; i++) { | |
| 1017 | + iter = &mz->iter[i]; | |
| 1018 | + cmpxchg(&iter->position, | |
| 1019 | + dead_memcg, NULL); | |
| 1020 | + } | |
| 1021 | + } | |
| 1022 | + } | |
| 1023 | + } | |
| 1024 | +} | |
| 1025 | + | |
| 1002 | 1026 | /* |
| 1003 | 1027 | * Iteration constructs for visiting all cgroups (under a tree). If |
| 1004 | 1028 | * loops are exited prematurely (break), mem_cgroup_iter_break() must |
| @@ -4324,6 +4348,13 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) · 3319 unmodified lines | ||
| 4324 | 4348 | wb_memcg_offline(memcg); |
| 4325 | 4349 | } |
| 4326 | 4350 | |
| 4351 | +static void mem_cgroup_css_released(struct cgroup_subsys_state *css) | |
| 4352 | +{ | |
| 4353 | + struct mem_cgroup *memcg = mem_cgroup_from_css(css); | |
| 4354 | + | |
| 4355 | + invalidate_reclaim_iterators(memcg); | |
| 4356 | +} | |
| 4357 | + | |
| 4327 | 4358 | static void mem_cgroup_css_free(struct cgroup_subsys_state *css) |
| 4328 | 4359 | { |
| 4329 | 4360 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); |
| @@ -5185,6 +5216,7 @@ struct cgroup_subsys memory_cgrp_subsys = { · 855 unmodified lines | ||
| 5185 | 5216 | .css_alloc = mem_cgroup_css_alloc, |
| 5186 | 5217 | .css_online = mem_cgroup_css_online, |
| 5187 | 5218 | .css_offline = mem_cgroup_css_offline, |
| 5219 | + .css_released = mem_cgroup_css_released, | |
| 5188 | 5220 | .css_free = mem_cgroup_css_free, |
| 5189 | 5221 | .css_reset = mem_cgroup_css_reset, |
| 5190 | 5222 | .can_attach = mem_cgroup_can_attach, |
| @@ -1375,23 +1375,30 @@ int is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages) · 1374 unmodified lines | ||
| 1375 | 1375 | */ |
| 1376 | 1376 | int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn) |
| 1377 | 1377 | { |
| 1378 | − unsigned long pfn; | |
| 1378 | + unsigned long pfn, sec_end_pfn; | |
| 1379 | 1379 | struct zone *zone = NULL; |
| 1380 | 1380 | struct page *page; |
| 1381 | 1381 | int i; |
| 1382 | − for (pfn = start_pfn; | |
| 1382 | + for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn); | |
| 1383 | 1383 | pfn < end_pfn; |
| 1384 | − pfn += MAX_ORDER_NR_PAGES) { | |
| 1385 | − i = 0; | |
| 1386 | − /* This is just a CONFIG_HOLES_IN_ZONE check.*/ | |
| 1387 | − while ((i < MAX_ORDER_NR_PAGES) && !pfn_valid_within(pfn + i)) | |
| 1388 | − i++; | |
| 1389 | − if (i == MAX_ORDER_NR_PAGES) | |
| 1384 | + pfn = sec_end_pfn + 1, sec_end_pfn += PAGES_PER_SECTION) { | |
| 1385 | + /* Make sure the memory section is present first */ | |
| 1386 | + if (!present_section_nr(pfn_to_section_nr(pfn))) | |
| 1390 | 1387 | continue; |
| 1391 | − page = pfn_to_page(pfn + i); | |
| 1392 | − if (zone && page_zone(page) != zone) | |
| 1393 | − return 0; | |
| 1394 | − zone = page_zone(page); | |
| 1388 | + for (; pfn < sec_end_pfn && pfn < end_pfn; | |
| 1389 | + pfn += MAX_ORDER_NR_PAGES) { | |
| 1390 | + i = 0; | |
| 1391 | + /* This is just a CONFIG_HOLES_IN_ZONE check.*/ | |
| 1392 | + while ((i < MAX_ORDER_NR_PAGES) && | |
| 1393 | + !pfn_valid_within(pfn + i)) | |
| 1394 | + i++; | |
| 1395 | + if (i == MAX_ORDER_NR_PAGES) | |
| 1396 | + continue; | |
| 1397 | + page = pfn_to_page(pfn + i); | |
| 1398 | + if (zone && page_zone(page) != zone) | |
| 1399 | + return 0; | |
| 1400 | + zone = page_zone(page); | |
| 1401 | + } | |
| 1395 | 1402 | } |
| 1396 | 1403 | return 1; |
| 1397 | 1404 | } |
| @@ -219,7 +219,7 @@ void set_pgdat_percpu_threshold(pg_data_t *pgdat, · 218 unmodified lines | ||
| 219 | 219 | * particular counter cannot be updated from interrupt context. |
| 220 | 220 | */ |
| 221 | 221 | void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item, |
| 222 | − int delta) | |
| 222 | + long delta) | |
| 223 | 223 | { |
| 224 | 224 | struct per_cpu_pageset __percpu *pcp = zone->pageset; |
| 225 | 225 | s8 __percpu *p = pcp->vm_stat_diff + item; |
| @@ -318,8 +318,8 @@ EXPORT_SYMBOL(__dec_zone_page_state); · 92 unmodified lines | ||
| 318 | 318 | * 1 Overstepping half of threshold |
| 319 | 319 | * -1 Overstepping minus half of threshold |
| 320 | 320 | */ |
| 321 | −static inline void mod_state(struct zone *zone, | |
| 322 | − enum zone_stat_item item, int delta, int overstep_mode) | |
| 321 | +static inline void mod_state(struct zone *zone, enum zone_stat_item item, | |
| 322 | + long delta, int overstep_mode) | |
| 323 | 323 | { |
| 324 | 324 | struct per_cpu_pageset __percpu *pcp = zone->pageset; |
| 325 | 325 | s8 __percpu *p = pcp->vm_stat_diff + item; |
| @@ -357,7 +357,7 @@ static inline void mod_state(struct zone *zone, · 31 unmodified lines | ||
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | void mod_zone_page_state(struct zone *zone, enum zone_stat_item item, |
| 360 | − int delta) | |
| 360 | + long delta) | |
| 361 | 361 | { |
| 362 | 362 | mod_state(zone, item, delta, 0); |
| 363 | 363 | } |
| @@ -384,7 +384,7 @@ EXPORT_SYMBOL(dec_zone_page_state); · 20 unmodified lines | ||
| 384 | 384 | * Use interrupt disable to serialize counter updates |
| 385 | 385 | */ |
| 386 | 386 | void mod_zone_page_state(struct zone *zone, enum zone_stat_item item, |
| 387 | − int delta) | |
| 387 | + long delta) | |
| 388 | 388 | { |
| 389 | 389 | unsigned long flags; |
| 390 | 390 | |
| @@ -1483,6 +1483,7 @@ static void __init start_shepherd_timer(void) · 1092 unmodified lines | ||
| 1483 | 1483 | BUG(); |
| 1484 | 1484 | cpumask_copy(cpu_stat_off, cpu_online_mask); |
| 1485 | 1485 | |
| 1486 | + vmstat_wq = alloc_workqueue("vmstat", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0); | |
| 1486 | 1487 | schedule_delayed_work(&shepherd, |
| 1487 | 1488 | round_jiffies_relative(sysctl_stat_interval)); |
| 1488 | 1489 | } |
| @@ -1550,7 +1551,6 @@ static int __init setup_vmstat(void) · 61 unmodified lines | ||
| 1550 | 1551 | |
| 1551 | 1552 | start_shepherd_timer(); |
| 1552 | 1553 | cpu_notifier_register_done(); |
| 1553 | − vmstat_wq = alloc_workqueue("vmstat", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0); | |
| 1554 | 1554 | #endif |
| 1555 | 1555 | #ifdef CONFIG_PROC_FS |
| 1556 | 1556 | proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); |
| @@ -541,6 +541,7 @@ static struct zswap_pool *zswap_pool_last_get(void) · 540 unmodified lines | ||
| 541 | 541 | return last; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | +/* type and compressor must be null-terminated */ | |
| 544 | 545 | static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) |
| 545 | 546 | { |
| 546 | 547 | struct zswap_pool *pool; |
| @@ -548,10 +549,9 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) · 1 unmodified line | ||
| 548 | 549 | assert_spin_locked(&zswap_pools_lock); |
| 549 | 550 | |
| 550 | 551 | list_for_each_entry_rcu(pool, &zswap_pools, list) { |
| 551 | − if (strncmp(pool->tfm_name, compressor, sizeof(pool->tfm_name))) | |
| 552 | + if (strcmp(pool->tfm_name, compressor)) | |
| 552 | 553 | continue; |
| 553 | − if (strncmp(zpool_get_type(pool->zpool), type, | |
| 554 | − sizeof(zswap_zpool_type))) | |
| 554 | + if (strcmp(zpool_get_type(pool->zpool), type)) | |
| 555 | 555 | continue; |
| 556 | 556 | /* if we can't get it, it's about to be destroyed */ |
| 557 | 557 | if (!zswap_pool_get(pool)) |
| @@ -805,6 +805,9 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol, · 804 unmodified lines | ||
| 805 | 805 | struct sock *sk; |
| 806 | 806 | ax25_cb *ax25; |
| 807 | 807 | |
| 808 | + if (protocol < 0 || protocol > SK_PROTOCOL_MAX) | |
| 809 | + return -EINVAL; | |
| 810 | + | |
| 808 | 811 | if (!net_eq(net, &init_net)) |
| 809 | 812 | return -EAFNOSUPPORT; |
| 810 | 813 | |
| @@ -566,6 +566,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) · 565 unmodified lines | ||
| 566 | 566 | int select; |
| 567 | 567 | batadv_dat_addr_t last_max = BATADV_DAT_ADDR_MAX, ip_key; |
| 568 | 568 | struct batadv_dat_candidate *res; |
| 569 | + struct batadv_dat_entry dat; | |
| 569 | 570 | |
| 570 | 571 | if (!bat_priv->orig_hash) |
| 571 | 572 | return NULL; |
| @@ -575,7 +576,9 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) · 3 unmodified lines | ||
| 575 | 576 | if (!res) |
| 576 | 577 | return NULL; |
| 577 | 578 | |
| 578 | − ip_key = (batadv_dat_addr_t)batadv_hash_dat(&ip_dst, | |
| 579 | + dat.ip = ip_dst; | |
| 580 | + dat.vid = 0; | |
| 581 | + ip_key = (batadv_dat_addr_t)batadv_hash_dat(&dat, | |
| 579 | 582 | BATADV_DAT_ADDR_MAX); |
| 580 | 583 | |
| 581 | 584 | batadv_dbg(BATADV_DBG_DAT, bat_priv, |
| @@ -836,6 +836,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, · 835 unmodified lines | ||
| 836 | 836 | u8 *orig_addr; |
| 837 | 837 | struct batadv_orig_node *orig_node = NULL; |
| 838 | 838 | int check, hdr_size = sizeof(*unicast_packet); |
| 839 | + enum batadv_subtype subtype; | |
| 839 | 840 | bool is4addr; |
| 840 | 841 | |
| 841 | 842 | unicast_packet = (struct batadv_unicast_packet *)skb->data; |
| @@ -863,10 +864,20 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, · 21 unmodified lines | ||
| 863 | 864 | /* packet for me */ |
| 864 | 865 | if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) { |
| 865 | 866 | if (is4addr) { |
| 866 | − batadv_dat_inc_counter(bat_priv, | |
| 867 | − unicast_4addr_packet->subtype); | |
| 868 | − orig_addr = unicast_4addr_packet->src; | |
| 869 | − orig_node = batadv_orig_hash_find(bat_priv, orig_addr); | |
| 867 | + subtype = unicast_4addr_packet->subtype; | |
| 868 | + batadv_dat_inc_counter(bat_priv, subtype); | |
| 869 | + | |
| 870 | + /* Only payload data should be considered for speedy | |
| 871 | + * join. For example, DAT also uses unicast 4addr | |
| 872 | + * types, but those packets should not be considered | |
| 873 | + * for speedy join, since the clients do not actually | |
| 874 | + * reside at the sending originator. | |
| 875 | + */ | |
| 876 | + if (subtype == BATADV_P_DATA) { | |
| 877 | + orig_addr = unicast_4addr_packet->src; | |
| 878 | + orig_node = batadv_orig_hash_find(bat_priv, | |
| 879 | + orig_addr); | |
| 880 | + } | |
| 870 | 881 | } |
| 871 | 882 | |
| 872 | 883 | if (batadv_dat_snoop_incoming_arp_request(bat_priv, skb, |
| @@ -68,13 +68,15 @@ static void batadv_tt_global_del(struct batadv_priv *bat_priv, · 67 unmodified lines | ||
| 68 | 68 | unsigned short vid, const char *message, |
| 69 | 69 | bool roaming); |
| 70 | 70 | |
| 71 | −/* returns 1 if they are the same mac addr */ | |
| 71 | +/* returns 1 if they are the same mac addr and vid */ | |
| 72 | 72 | static int batadv_compare_tt(const struct hlist_node *node, const void *data2) |
| 73 | 73 | { |
| 74 | 74 | const void *data1 = container_of(node, struct batadv_tt_common_entry, |
| 75 | 75 | hash_entry); |
| 76 | + const struct batadv_tt_common_entry *tt1 = data1; | |
| 77 | + const struct batadv_tt_common_entry *tt2 = data2; | |
| 76 | 78 | |
| 77 | − return batadv_compare_eth(data1, data2); | |
| 79 | + return (tt1->vid == tt2->vid) && batadv_compare_eth(data1, data2); | |
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | /** |
| @@ -1427,9 +1429,15 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv, · 1346 unmodified lines | ||
| 1427 | 1429 | } |
| 1428 | 1430 | |
| 1429 | 1431 | /* if the client was temporary added before receiving the first |
| 1430 | − * OGM announcing it, we have to clear the TEMP flag | |
| 1432 | + * OGM announcing it, we have to clear the TEMP flag. Also, | |
| 1433 | + * remove the previous temporary orig node and re-add it | |
| 1434 | + * if required. If the orig entry changed, the new one which | |
| 1435 | + * is a non-temporary entry is preferred. | |
| 1431 | 1436 | */ |
| 1432 | − common->flags &= ~BATADV_TT_CLIENT_TEMP; | |
| 1437 | + if (common->flags & BATADV_TT_CLIENT_TEMP) { | |
| 1438 | + batadv_tt_global_del_orig_list(tt_global_entry); | |
| 1439 | + common->flags &= ~BATADV_TT_CLIENT_TEMP; | |
| 1440 | + } | |
| 1433 | 1441 | |
| 1434 | 1442 | /* the change can carry possible "attribute" flags like the |
| 1435 | 1443 | * TT_CLIENT_WIFI, therefore they have to be copied in the |
| @@ -526,6 +526,9 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, · 525 unmodified lines | ||
| 526 | 526 | if (!addr || addr->sa_family != AF_BLUETOOTH) |
| 527 | 527 | return -EINVAL; |
| 528 | 528 | |
| 529 | + if (addr_len < sizeof(struct sockaddr_sco)) | |
| 530 | + return -EINVAL; | |
| 531 | + | |
| 529 | 532 | lock_sock(sk); |
| 530 | 533 | |
| 531 | 534 | if (sk->sk_state != BT_OPEN) { |
| @@ -39,7 +39,7 @@ void br_init_port(struct net_bridge_port *p) · 38 unmodified lines | ||
| 39 | 39 | struct switchdev_attr attr = { |
| 40 | 40 | .id = SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, |
| 41 | 41 | .flags = SWITCHDEV_F_SKIP_EOPNOTSUPP | SWITCHDEV_F_DEFER, |
| 42 | − .u.ageing_time = p->br->ageing_time, | |
| 42 | + .u.ageing_time = jiffies_to_clock_t(p->br->ageing_time), | |
| 43 | 43 | }; |
| 44 | 44 | int err; |
| 45 | 45 | |
| @@ -142,7 +142,10 @@ static void br_stp_start(struct net_bridge *br) · 96 unmodified lines | ||
| 142 | 142 | char *envp[] = { NULL }; |
| 143 | 143 | struct net_bridge_port *p; |
| 144 | 144 | |
| 145 | − r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC); | |
| 145 | + if (net_eq(dev_net(br->dev), &init_net)) | |
| 146 | + r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC); | |
| 147 | + else | |
| 148 | + r = -ENOENT; | |
| 146 | 149 | |
| 147 | 150 | spin_lock_bh(&br->lock); |
| 148 | 151 | |
| @@ -301,12 +301,13 @@ void dst_release(struct dst_entry *dst) · 300 unmodified lines | ||
| 301 | 301 | { |
| 302 | 302 | if (dst) { |
| 303 | 303 | int newrefcnt; |
| 304 | + unsigned short nocache = dst->flags & DST_NOCACHE; | |
| 304 | 305 | |
| 305 | 306 | newrefcnt = atomic_dec_return(&dst->__refcnt); |
| 306 | 307 | if (unlikely(newrefcnt < 0)) |
| 307 | 308 | net_warn_ratelimited("%s: dst:%p refcnt:%d\n", |
| 308 | 309 | __func__, dst, newrefcnt); |
| 309 | − if (!newrefcnt && unlikely(dst->flags & DST_NOCACHE)) | |
| 310 | + if (!newrefcnt && unlikely(nocache)) | |
| 310 | 311 | call_rcu(&dst->rcu_head, dst_destroy_rcu); |
| 311 | 312 | } |
| 312 | 313 | } |
| @@ -3643,7 +3643,8 @@ static void __skb_complete_tx_timestamp(struct sk_buff *skb, · 3642 unmodified lines | ||
| 3643 | 3643 | serr->ee.ee_info = tstype; |
| 3644 | 3644 | if (sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID) { |
| 3645 | 3645 | serr->ee.ee_data = skb_shinfo(skb)->tskey; |
| 3646 | − if (sk->sk_protocol == IPPROTO_TCP) | |
| 3646 | + if (sk->sk_protocol == IPPROTO_TCP && | |
| 3647 | + sk->sk_type == SOCK_STREAM) | |
| 3647 | 3648 | serr->ee.ee_data -= sk->sk_tskey; |
| 3648 | 3649 | } |
| 3649 | 3650 | |
| @@ -4268,7 +4269,7 @@ static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb) · 618 unmodified lines | ||
| 4268 | 4269 | return NULL; |
| 4269 | 4270 | } |
| 4270 | 4271 | |
| 4271 | − memmove(skb->data - ETH_HLEN, skb->data - skb->mac_len, | |
| 4272 | + memmove(skb->data - ETH_HLEN, skb->data - skb->mac_len - VLAN_HLEN, | |
| 4272 | 4273 | 2 * ETH_ALEN); |
| 4273 | 4274 | skb->mac_header += VLAN_HLEN; |
| 4274 | 4275 | return skb; |
| @@ -433,8 +433,6 @@ static bool sock_needs_netstamp(const struct sock *sk) · 432 unmodified lines | ||
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | −#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)) | |
| 437 | − | |
| 438 | 436 | static void sock_disable_timestamp(struct sock *sk, unsigned long flags) |
| 439 | 437 | { |
| 440 | 438 | if (sk->sk_flags & flags) { |
| @@ -874,7 +872,8 @@ set_rcvbuf: · 433 unmodified lines | ||
| 874 | 872 | |
| 875 | 873 | if (val & SOF_TIMESTAMPING_OPT_ID && |
| 876 | 874 | !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) { |
| 877 | − if (sk->sk_protocol == IPPROTO_TCP) { | |
| 875 | + if (sk->sk_protocol == IPPROTO_TCP && | |
| 876 | + sk->sk_type == SOCK_STREAM) { | |
| 878 | 877 | if (sk->sk_state != TCP_ESTABLISHED) { |
| 879 | 878 | ret = -EINVAL; |
| 880 | 879 | break; |
| @@ -1552,7 +1551,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) · 671 unmodified lines | ||
| 1552 | 1551 | */ |
| 1553 | 1552 | is_charged = sk_filter_charge(newsk, filter); |
| 1554 | 1553 | |
| 1555 | − if (unlikely(!is_charged || xfrm_sk_clone_policy(newsk))) { | |
| 1554 | + if (unlikely(!is_charged || xfrm_sk_clone_policy(newsk, sk))) { | |
| 1556 | 1555 | /* It is still raw copy of parent, so invalidate |
| 1557 | 1556 | * destructor and make plain sk_free() */ |
| 1558 | 1557 | newsk->sk_destruct = NULL; |
| @@ -678,6 +678,9 @@ static int dn_create(struct net *net, struct socket *sock, int protocol, · 677 unmodified lines | ||
| 678 | 678 | { |
| 679 | 679 | struct sock *sk; |
| 680 | 680 | |
| 681 | + if (protocol < 0 || protocol > SK_PROTOCOL_MAX) | |
| 682 | + return -EINVAL; | |
| 683 | + | |
| 681 | 684 | if (!net_eq(net, &init_net)) |
| 682 | 685 | return -EAFNOSUPPORT; |
| 683 | 686 | |
| @@ -257,6 +257,9 @@ static int inet_create(struct net *net, struct socket *sock, int protocol, · 256 unmodified lines | ||
| 257 | 257 | int try_loading_module = 0; |
| 258 | 258 | int err; |
| 259 | 259 | |
| 260 | + if (protocol < 0 || protocol >= IPPROTO_MAX) | |
| 261 | + return -EINVAL; | |
| 262 | + | |
| 260 | 263 | sock->state = SS_UNCONNECTED; |
| 261 | 264 | |
| 262 | 265 | /* Look for the requested type/protocol pair. */ |
| @@ -1155,6 +1155,7 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event, · 1154 unmodified lines | ||
| 1155 | 1155 | static int fib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) |
| 1156 | 1156 | { |
| 1157 | 1157 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
| 1158 | + struct netdev_notifier_changeupper_info *info; | |
| 1158 | 1159 | struct in_device *in_dev; |
| 1159 | 1160 | struct net *net = dev_net(dev); |
| 1160 | 1161 | unsigned int flags; |
| @@ -1193,6 +1194,14 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo · 32 unmodified lines | ||
| 1193 | 1194 | case NETDEV_CHANGEMTU: |
| 1194 | 1195 | rt_cache_flush(net); |
| 1195 | 1196 | break; |
| 1197 | + case NETDEV_CHANGEUPPER: | |
| 1198 | + info = ptr; | |
| 1199 | + /* flush all routes if dev is linked to or unlinked from | |
| 1200 | + * an L3 master device (e.g., VRF) | |
| 1201 | + */ | |
| 1202 | + if (info->upper_dev && netif_is_l3_master(info->upper_dev)) | |
| 1203 | + fib_disable_ip(dev, NETDEV_DOWN, true); | |
| 1204 | + break; | |
| 1196 | 1205 | } |
| 1197 | 1206 | return NOTIFY_DONE; |
| 1198 | 1207 | } |
| @@ -24,6 +24,7 @@ struct fou { · 23 unmodified lines | ||
| 24 | 24 | u16 type; |
| 25 | 25 | struct udp_offload udp_offloads; |
| 26 | 26 | struct list_head list; |
| 27 | + struct rcu_head rcu; | |
| 27 | 28 | }; |
| 28 | 29 | |
| 29 | 30 | #define FOU_F_REMCSUM_NOPARTIAL BIT(0) |
| @@ -417,7 +418,7 @@ static void fou_release(struct fou *fou) · 387 unmodified lines | ||
| 417 | 418 | list_del(&fou->list); |
| 418 | 419 | udp_tunnel_sock_release(sock); |
| 419 | 420 | |
| 420 | − kfree(fou); | |
| 421 | + kfree_rcu(fou, rcu); | |
| 421 | 422 | } |
| 422 | 423 | |
| 423 | 424 | static int fou_encap_init(struct sock *sk, struct fou *fou, struct fou_cfg *cfg) |
| @@ -253,9 +253,6 @@ ipip_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) · 252 unmodified lines | ||
| 253 | 253 | |
| 254 | 254 | p.i_key = p.o_key = 0; |
| 255 | 255 | p.i_flags = p.o_flags = 0; |
| 256 | − if (p.iph.ttl) | |
| 257 | − p.iph.frag_off |= htons(IP_DF); | |
| 258 | − | |
| 259 | 256 | err = ip_tunnel_ioctl(dev, &p, cmd); |
| 260 | 257 | if (err) |
| 261 | 258 | return err; |
| @@ -60,6 +60,7 @@ config NFT_REJECT_IPV4 · 59 unmodified lines | ||
| 60 | 60 | |
| 61 | 61 | config NFT_DUP_IPV4 |
| 62 | 62 | tristate "IPv4 nf_tables packet duplication support" |
| 63 | + depends on !NF_CONNTRACK || NF_CONNTRACK | |
| 63 | 64 | select NF_DUP_IPV4 |
| 64 | 65 | help |
| 65 | 66 | This module enables IPv4 packet duplication support for nf_tables. |
| @@ -601,8 +601,11 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · 600 unmodified lines | ||
| 601 | 601 | (inet->hdrincl ? FLOWI_FLAG_KNOWN_NH : 0), |
| 602 | 602 | daddr, saddr, 0, 0); |
| 603 | 603 | |
| 604 | − if (!saddr && ipc.oif) | |
| 605 | − l3mdev_get_saddr(net, ipc.oif, &fl4); | |
| 604 | + if (!saddr && ipc.oif) { | |
| 605 | + err = l3mdev_get_saddr(net, ipc.oif, &fl4); | |
| 606 | + if (err < 0) | |
| 607 | + goto done; | |
| 608 | + } | |
| 606 | 609 | |
| 607 | 610 | if (!inet->hdrincl) { |
| 608 | 611 | rfv.msg = msg; |
| @@ -2478,6 +2478,9 @@ static void tcp_cwnd_reduction(struct sock *sk, const int prior_unsacked, · 2477 unmodified lines | ||
| 2478 | 2478 | int newly_acked_sacked = prior_unsacked - |
| 2479 | 2479 | (tp->packets_out - tp->sacked_out); |
| 2480 | 2480 | |
| 2481 | + if (newly_acked_sacked <= 0 || WARN_ON_ONCE(!tp->prior_cwnd)) | |
| 2482 | + return; | |
| 2483 | + | |
| 2481 | 2484 | tp->prr_delivered += newly_acked_sacked; |
| 2482 | 2485 | if (delta < 0) { |
| 2483 | 2486 | u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered + |
| @@ -1493,7 +1493,7 @@ bool tcp_prequeue(struct sock *sk, struct sk_buff *skb) · 1492 unmodified lines | ||
| 1493 | 1493 | if (likely(sk->sk_rx_dst)) |
| 1494 | 1494 | skb_dst_drop(skb); |
| 1495 | 1495 | else |
| 1496 | − skb_dst_force(skb); | |
| 1496 | + skb_dst_force_safe(skb); | |
| 1497 | 1497 | |
| 1498 | 1498 | __skb_queue_tail(&tp->ucopy.prequeue, skb); |
| 1499 | 1499 | tp->ucopy.memory += skb->truesize; |
| @@ -1721,8 +1721,7 @@ void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) · 221 unmodified lines | ||
| 1721 | 1721 | { |
| 1722 | 1722 | struct dst_entry *dst = skb_dst(skb); |
| 1723 | 1723 | |
| 1724 | − if (dst) { | |
| 1725 | − dst_hold(dst); | |
| 1724 | + if (dst && dst_hold_safe(dst)) { | |
| 1726 | 1725 | sk->sk_rx_dst = dst; |
| 1727 | 1726 | inet_sk(sk)->rx_dst_ifindex = skb->skb_iif; |
| 1728 | 1727 | } |
| @@ -3150,7 +3150,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn) · 3149 unmodified lines | ||
| 3150 | 3150 | { |
| 3151 | 3151 | struct tcp_sock *tp = tcp_sk(sk); |
| 3152 | 3152 | struct tcp_fastopen_request *fo = tp->fastopen_req; |
| 3153 | − int syn_loss = 0, space, err = 0, copied; | |
| 3153 | + int syn_loss = 0, space, err = 0; | |
| 3154 | 3154 | unsigned long last_syn_loss = 0; |
| 3155 | 3155 | struct sk_buff *syn_data; |
| 3156 | 3156 | |
| @@ -3188,17 +3188,18 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn) · 31 unmodified lines | ||
| 3188 | 3188 | goto fallback; |
| 3189 | 3189 | syn_data->ip_summed = CHECKSUM_PARTIAL; |
| 3190 | 3190 | memcpy(syn_data->cb, syn->cb, sizeof(syn->cb)); |
| 3191 | − copied = copy_from_iter(skb_put(syn_data, space), space, | |
| 3192 | − &fo->data->msg_iter); | |
| 3193 | − if (unlikely(!copied)) { | |
| 3194 | − kfree_skb(syn_data); | |
| 3195 | − goto fallback; | |
| 3196 | − } | |
| 3197 | − if (copied != space) { | |
| 3198 | − skb_trim(syn_data, copied); | |
| 3199 | − space = copied; | |
| 3191 | + if (space) { | |
| 3192 | + int copied = copy_from_iter(skb_put(syn_data, space), space, | |
| 3193 | + &fo->data->msg_iter); | |
| 3194 | + if (unlikely(!copied)) { | |
| 3195 | + kfree_skb(syn_data); | |
| 3196 | + goto fallback; | |
| 3197 | + } | |
| 3198 | + if (copied != space) { | |
| 3199 | + skb_trim(syn_data, copied); | |
| 3200 | + space = copied; | |
| 3201 | + } | |
| 3200 | 3202 | } |
| 3201 | − | |
| 3202 | 3203 | /* No more data pending in inet_wait_for_connect() */ |
| 3203 | 3204 | if (space == fo->size) |
| 3204 | 3205 | fo->data = NULL; |
| @@ -1025,8 +1025,11 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · 1024 unmodified lines | ||
| 1025 | 1025 | flow_flags, |
| 1026 | 1026 | faddr, saddr, dport, inet->inet_sport); |
| 1027 | 1027 | |
| 1028 | − if (!saddr && ipc.oif) | |
| 1029 | − l3mdev_get_saddr(net, ipc.oif, fl4); | |
| 1028 | + if (!saddr && ipc.oif) { | |
| 1029 | + err = l3mdev_get_saddr(net, ipc.oif, fl4); | |
| 1030 | + if (err < 0) | |
| 1031 | + goto out; | |
| 1032 | + } | |
| 1030 | 1033 | |
| 1031 | 1034 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); |
| 1032 | 1035 | rt = ip_route_output_flow(net, fl4, sk); |
| @@ -259,7 +259,7 @@ static void xfrm4_dst_ifdown(struct dst_entry *dst, struct net_device *dev, · 258 unmodified lines | ||
| 259 | 259 | xfrm_dst_ifdown(dst, dev); |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | −static struct dst_ops xfrm4_dst_ops = { | |
| 262 | +static struct dst_ops xfrm4_dst_ops_template = { | |
| 263 | 263 | .family = AF_INET, |
| 264 | 264 | .gc = xfrm4_garbage_collect, |
| 265 | 265 | .update_pmtu = xfrm4_update_pmtu, |
| @@ -273,7 +273,7 @@ static struct dst_ops xfrm4_dst_ops = { · 7 unmodified lines | ||
| 273 | 273 | |
| 274 | 274 | static struct xfrm_policy_afinfo xfrm4_policy_afinfo = { |
| 275 | 275 | .family = AF_INET, |
| 276 | − .dst_ops = &xfrm4_dst_ops, | |
| 276 | + .dst_ops = &xfrm4_dst_ops_template, | |
| 277 | 277 | .dst_lookup = xfrm4_dst_lookup, |
| 278 | 278 | .get_saddr = xfrm4_get_saddr, |
| 279 | 279 | .decode_session = _decode_session4, |
| @@ -295,7 +295,7 @@ static struct ctl_table xfrm4_policy_table[] = { · 15 unmodified lines | ||
| 295 | 295 | { } |
| 296 | 296 | }; |
| 297 | 297 | |
| 298 | −static int __net_init xfrm4_net_init(struct net *net) | |
| 298 | +static int __net_init xfrm4_net_sysctl_init(struct net *net) | |
| 299 | 299 | { |
| 300 | 300 | struct ctl_table *table; |
| 301 | 301 | struct ctl_table_header *hdr; |
| @@ -323,7 +323,7 @@ err_alloc: · 21 unmodified lines | ||
| 323 | 323 | return -ENOMEM; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | −static void __net_exit xfrm4_net_exit(struct net *net) | |
| 326 | +static void __net_exit xfrm4_net_sysctl_exit(struct net *net) | |
| 327 | 327 | { |
| 328 | 328 | struct ctl_table *table; |
| 329 | 329 | |
| @@ -335,12 +335,44 @@ static void __net_exit xfrm4_net_exit(struct net *net) · 5 unmodified lines | ||
| 335 | 335 | if (!net_eq(net, &init_net)) |
| 336 | 336 | kfree(table); |
| 337 | 337 | } |
| 338 | +#else /* CONFIG_SYSCTL */ | |
| 339 | +static int inline xfrm4_net_sysctl_init(struct net *net) | |
| 340 | +{ | |
| 341 | + return 0; | |
| 342 | +} | |
| 343 | + | |
| 344 | +static void inline xfrm4_net_sysctl_exit(struct net *net) | |
| 345 | +{ | |
| 346 | +} | |
| 347 | +#endif | |
| 348 | + | |
| 349 | +static int __net_init xfrm4_net_init(struct net *net) | |
| 350 | +{ | |
| 351 | + int ret; | |
| 352 | + | |
| 353 | + memcpy(&net->xfrm.xfrm4_dst_ops, &xfrm4_dst_ops_template, | |
| 354 | + sizeof(xfrm4_dst_ops_template)); | |
| 355 | + ret = dst_entries_init(&net->xfrm.xfrm4_dst_ops); | |
| 356 | + if (ret) | |
| 357 | + return ret; | |
| 358 | + | |
| 359 | + ret = xfrm4_net_sysctl_init(net); | |
| 360 | + if (ret) | |
| 361 | + dst_entries_destroy(&net->xfrm.xfrm4_dst_ops); | |
| 362 | + | |
| 363 | + return ret; | |
| 364 | +} | |
| 365 | + | |
| 366 | +static void __net_exit xfrm4_net_exit(struct net *net) | |
| 367 | +{ | |
| 368 | + xfrm4_net_sysctl_exit(net); | |
| 369 | + dst_entries_destroy(&net->xfrm.xfrm4_dst_ops); | |
| 370 | +} | |
| 338 | 371 | |
| 339 | 372 | static struct pernet_operations __net_initdata xfrm4_net_ops = { |
| 340 | 373 | .init = xfrm4_net_init, |
| 341 | 374 | .exit = xfrm4_net_exit, |
| 342 | 375 | }; |
| 343 | −#endif | |
| 344 | 376 | |
| 345 | 377 | static void __init xfrm4_policy_init(void) |
| 346 | 378 | { |
| @@ -349,13 +381,9 @@ static void __init xfrm4_policy_init(void) · 2 unmodified lines | ||
| 349 | 381 | |
| 350 | 382 | void __init xfrm4_init(void) |
| 351 | 383 | { |
| 352 | − dst_entries_init(&xfrm4_dst_ops); | |
| 353 | − | |
| 354 | 384 | xfrm4_state_init(); |
| 355 | 385 | xfrm4_policy_init(); |
| 356 | 386 | xfrm4_protocol_init(); |
| 357 | −#ifdef CONFIG_SYSCTL | |
| 358 | 387 | register_pernet_subsys(&xfrm4_net_ops); |
| 359 | −#endif | |
| 360 | 388 | } |
| 361 | 389 | |
| @@ -350,6 +350,12 @@ static struct inet6_dev *ipv6_add_dev(struct net_device *dev) · 349 unmodified lines | ||
| 350 | 350 | setup_timer(&ndev->rs_timer, addrconf_rs_timer, |
| 351 | 351 | (unsigned long)ndev); |
| 352 | 352 | memcpy(&ndev->cnf, dev_net(dev)->ipv6.devconf_dflt, sizeof(ndev->cnf)); |
| 353 | + | |
| 354 | + if (ndev->cnf.stable_secret.initialized) | |
| 355 | + ndev->addr_gen_mode = IN6_ADDR_GEN_MODE_STABLE_PRIVACY; | |
| 356 | + else | |
| 357 | + ndev->addr_gen_mode = IN6_ADDR_GEN_MODE_EUI64; | |
| 358 | + | |
| 353 | 359 | ndev->cnf.mtu6 = dev->mtu; |
| 354 | 360 | ndev->cnf.sysctl = NULL; |
| 355 | 361 | ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl); |
| @@ -2455,7 +2461,7 @@ ok: · 2099 unmodified lines | ||
| 2455 | 2461 | #ifdef CONFIG_IPV6_OPTIMISTIC_DAD |
| 2456 | 2462 | if (in6_dev->cnf.optimistic_dad && |
| 2457 | 2463 | !net->ipv6.devconf_all->forwarding && sllao) |
| 2458 | − addr_flags = IFA_F_OPTIMISTIC; | |
| 2464 | + addr_flags |= IFA_F_OPTIMISTIC; | |
| 2459 | 2465 | #endif |
| 2460 | 2466 | |
| 2461 | 2467 | /* Do not allow to create too much of autoconfigured |
| @@ -5363,13 +5369,10 @@ static int addrconf_sysctl_stable_secret(struct ctl_table *ctl, int write, · 2901 unmodified lines | ||
| 5363 | 5369 | goto out; |
| 5364 | 5370 | } |
| 5365 | 5371 | |
| 5366 | − if (!write) { | |
| 5367 | − err = snprintf(str, sizeof(str), "%pI6", | |
| 5368 | − &secret->secret); | |
| 5369 | − if (err >= sizeof(str)) { | |
| 5370 | − err = -EIO; | |
| 5371 | − goto out; | |
| 5372 | − } | |
| 5372 | + err = snprintf(str, sizeof(str), "%pI6", &secret->secret); | |
| 5373 | + if (err >= sizeof(str)) { | |
| 5374 | + err = -EIO; | |
| 5375 | + goto out; | |
| 5373 | 5376 | } |
| 5374 | 5377 | |
| 5375 | 5378 | err = proc_dostring(&lctl, write, buffer, lenp, ppos); |
| @@ -552,7 +552,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh) · 551 unmodified lines | ||
| 552 | 552 | |
| 553 | 553 | rcu_read_lock(); |
| 554 | 554 | p = __ipv6_addr_label(net, addr, ipv6_addr_type(addr), ifal->ifal_index); |
| 555 | − if (p && ip6addrlbl_hold(p)) | |
| 555 | + if (p && !ip6addrlbl_hold(p)) | |
| 556 | 556 | p = NULL; |
| 557 | 557 | lseq = ip6addrlbl_table.seq; |
| 558 | 558 | rcu_read_unlock(); |
| @@ -109,6 +109,9 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol, · 108 unmodified lines | ||
| 109 | 109 | int try_loading_module = 0; |
| 110 | 110 | int err; |
| 111 | 111 | |
| 112 | + if (protocol < 0 || protocol >= IPPROTO_MAX) | |
| 113 | + return -EINVAL; | |
| 114 | + | |
| 112 | 115 | /* Look for the requested type/protocol pair. */ |
| 113 | 116 | lookup_protocol: |
| 114 | 117 | err = -ESOCKTNOSUPPORT; |
| @@ -1571,13 +1571,11 @@ static int ip6gre_changelink(struct net_device *dev, struct nlattr *tb[], · 1570 unmodified lines | ||
| 1571 | 1571 | return -EEXIST; |
| 1572 | 1572 | } else { |
| 1573 | 1573 | t = nt; |
| 1574 | − | |
| 1575 | − ip6gre_tunnel_unlink(ign, t); | |
| 1576 | − ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]); | |
| 1577 | − ip6gre_tunnel_link(ign, t); | |
| 1578 | − netdev_state_change(dev); | |
| 1579 | 1574 | } |
| 1580 | 1575 | |
| 1576 | + ip6gre_tunnel_unlink(ign, t); | |
| 1577 | + ip6gre_tnl_change(t, &p, !tb[IFLA_MTU]); | |
| 1578 | + ip6gre_tunnel_link(ign, t); | |
| 1581 | 1579 | return 0; |
| 1582 | 1580 | } |
| 1583 | 1581 | |
| @@ -1183,7 +1183,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) · 1182 unmodified lines | ||
| 1183 | 1183 | */ |
| 1184 | 1184 | if (!in6_dev->cnf.accept_ra_from_local && |
| 1185 | 1185 | ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr, |
| 1186 | − NULL, 0)) { | |
| 1186 | + in6_dev->dev, 0)) { | |
| 1187 | 1187 | ND_PRINTK(2, info, |
| 1188 | 1188 | "RA from local address detected on dev: %s: default router ignored\n", |
| 1189 | 1189 | skb->dev->name); |
| @@ -1337,7 +1337,7 @@ skip_linkparms: · 147 unmodified lines | ||
| 1337 | 1337 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 1338 | 1338 | if (!in6_dev->cnf.accept_ra_from_local && |
| 1339 | 1339 | ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr, |
| 1340 | − NULL, 0)) { | |
| 1340 | + in6_dev->dev, 0)) { | |
| 1341 | 1341 | ND_PRINTK(2, info, |
| 1342 | 1342 | "RA from local address detected on dev: %s: router info ignored.\n", |
| 1343 | 1343 | skb->dev->name); |
| @@ -49,6 +49,7 @@ config NFT_REJECT_IPV6 · 48 unmodified lines | ||
| 49 | 49 | |
| 50 | 50 | config NFT_DUP_IPV6 |
| 51 | 51 | tristate "IPv6 nf_tables packet duplication support" |
| 52 | + depends on !NF_CONNTRACK || NF_CONNTRACK | |
| 52 | 53 | select NF_DUP_IPV6 |
| 53 | 54 | help |
| 54 | 55 | This module enables IPv6 packet duplication support for nf_tables. |
| @@ -93,10 +93,9 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) · 92 unmodified lines | ||
| 93 | 93 | { |
| 94 | 94 | struct dst_entry *dst = skb_dst(skb); |
| 95 | 95 | |
| 96 | − if (dst) { | |
| 96 | + if (dst && dst_hold_safe(dst)) { | |
| 97 | 97 | const struct rt6_info *rt = (const struct rt6_info *)dst; |
| 98 | 98 | |
| 99 | − dst_hold(dst); | |
| 100 | 99 | sk->sk_rx_dst = dst; |
| 101 | 100 | inet_sk(sk)->rx_dst_ifindex = skb->skb_iif; |
| 102 | 101 | inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt); |
| @@ -279,7 +279,7 @@ static void xfrm6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, · 278 unmodified lines | ||
| 279 | 279 | xfrm_dst_ifdown(dst, dev); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | −static struct dst_ops xfrm6_dst_ops = { | |
| 282 | +static struct dst_ops xfrm6_dst_ops_template = { | |
| 283 | 283 | .family = AF_INET6, |
| 284 | 284 | .gc = xfrm6_garbage_collect, |
| 285 | 285 | .update_pmtu = xfrm6_update_pmtu, |
| @@ -293,7 +293,7 @@ static struct dst_ops xfrm6_dst_ops = { · 7 unmodified lines | ||
| 293 | 293 | |
| 294 | 294 | static struct xfrm_policy_afinfo xfrm6_policy_afinfo = { |
| 295 | 295 | .family = AF_INET6, |
| 296 | − .dst_ops = &xfrm6_dst_ops, | |
| 296 | + .dst_ops = &xfrm6_dst_ops_template, | |
| 297 | 297 | .dst_lookup = xfrm6_dst_lookup, |
| 298 | 298 | .get_saddr = xfrm6_get_saddr, |
| 299 | 299 | .decode_session = _decode_session6, |
| @@ -325,7 +325,7 @@ static struct ctl_table xfrm6_policy_table[] = { · 25 unmodified lines | ||
| 325 | 325 | { } |
| 326 | 326 | }; |
| 327 | 327 | |
| 328 | −static int __net_init xfrm6_net_init(struct net *net) | |
| 328 | +static int __net_init xfrm6_net_sysctl_init(struct net *net) | |
| 329 | 329 | { |
| 330 | 330 | struct ctl_table *table; |
| 331 | 331 | struct ctl_table_header *hdr; |
| @@ -353,7 +353,7 @@ err_alloc: · 21 unmodified lines | ||
| 353 | 353 | return -ENOMEM; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | −static void __net_exit xfrm6_net_exit(struct net *net) | |
| 356 | +static void __net_exit xfrm6_net_sysctl_exit(struct net *net) | |
| 357 | 357 | { |
| 358 | 358 | struct ctl_table *table; |
| 359 | 359 | |
| @@ -365,24 +365,52 @@ static void __net_exit xfrm6_net_exit(struct net *net) · 5 unmodified lines | ||
| 365 | 365 | if (!net_eq(net, &init_net)) |
| 366 | 366 | kfree(table); |
| 367 | 367 | } |
| 368 | +#else /* CONFIG_SYSCTL */ | |
| 369 | +static int inline xfrm6_net_sysctl_init(struct net *net) | |
| 370 | +{ | |
| 371 | + return 0; | |
| 372 | +} | |
| 373 | + | |
| 374 | +static void inline xfrm6_net_sysctl_exit(struct net *net) | |
| 375 | +{ | |
| 376 | +} | |
| 377 | +#endif | |
| 378 | + | |
| 379 | +static int __net_init xfrm6_net_init(struct net *net) | |
| 380 | +{ | |
| 381 | + int ret; | |
| 382 | + | |
| 383 | + memcpy(&net->xfrm.xfrm6_dst_ops, &xfrm6_dst_ops_template, | |
| 384 | + sizeof(xfrm6_dst_ops_template)); | |
| 385 | + ret = dst_entries_init(&net->xfrm.xfrm6_dst_ops); | |
| 386 | + if (ret) | |
| 387 | + return ret; | |
| 388 | + | |
| 389 | + ret = xfrm6_net_sysctl_init(net); | |
| 390 | + if (ret) | |
| 391 | + dst_entries_destroy(&net->xfrm.xfrm6_dst_ops); | |
| 392 | + | |
| 393 | + return ret; | |
| 394 | +} | |
| 395 | + | |
| 396 | +static void __net_exit xfrm6_net_exit(struct net *net) | |
| 397 | +{ | |
| 398 | + xfrm6_net_sysctl_exit(net); | |
| 399 | + dst_entries_destroy(&net->xfrm.xfrm6_dst_ops); | |
| 400 | +} | |
| 368 | 401 | |
| 369 | 402 | static struct pernet_operations xfrm6_net_ops = { |
| 370 | 403 | .init = xfrm6_net_init, |
| 371 | 404 | .exit = xfrm6_net_exit, |
| 372 | 405 | }; |
| 373 | −#endif | |
| 374 | 406 | |
| 375 | 407 | int __init xfrm6_init(void) |
| 376 | 408 | { |
| 377 | 409 | int ret; |
| 378 | 410 | |
| 379 | − dst_entries_init(&xfrm6_dst_ops); | |
| 380 | − | |
| 381 | 411 | ret = xfrm6_policy_init(); |
| 382 | − if (ret) { | |
| 383 | − dst_entries_destroy(&xfrm6_dst_ops); | |
| 412 | + if (ret) | |
| 384 | 413 | goto out; |
| 385 | − } | |
| 386 | 414 | ret = xfrm6_state_init(); |
| 387 | 415 | if (ret) |
| 388 | 416 | goto out_policy; |
| @@ -391,9 +419,7 @@ int __init xfrm6_init(void) · 2 unmodified lines | ||
| 391 | 419 | if (ret) |
| 392 | 420 | goto out_state; |
| 393 | 421 | |
| 394 | −#ifdef CONFIG_SYSCTL | |
| 395 | 422 | register_pernet_subsys(&xfrm6_net_ops); |
| 396 | −#endif | |
| 397 | 423 | out: |
| 398 | 424 | return ret; |
| 399 | 425 | out_state: |
| @@ -405,11 +431,8 @@ out_policy: · 5 unmodified lines | ||
| 405 | 431 | |
| 406 | 432 | void xfrm6_fini(void) |
| 407 | 433 | { |
| 408 | −#ifdef CONFIG_SYSCTL | |
| 409 | 434 | unregister_pernet_subsys(&xfrm6_net_ops); |
| 410 | −#endif | |
| 411 | 435 | xfrm6_protocol_fini(); |
| 412 | 436 | xfrm6_policy_fini(); |
| 413 | 437 | xfrm6_state_fini(); |
| 414 | − dst_entries_destroy(&xfrm6_dst_ops); | |
| 415 | 438 | } |
| @@ -1086,6 +1086,9 @@ static int irda_create(struct net *net, struct socket *sock, int protocol, · 1085 unmodified lines | ||
| 1086 | 1086 | struct sock *sk; |
| 1087 | 1087 | struct irda_sock *self; |
| 1088 | 1088 | |
| 1089 | + if (protocol < 0 || protocol > SK_PROTOCOL_MAX) | |
| 1090 | + return -EINVAL; | |
| 1091 | + | |
| 1089 | 1092 | if (net != &init_net) |
| 1090 | 1093 | return -EAFNOSUPPORT; |
| 1091 | 1094 | |
| @@ -1169,8 +1169,7 @@ static int sta_apply_parameters(struct ieee80211_local *local, · 1168 unmodified lines | ||
| 1169 | 1169 | * rc isn't initialized here yet, so ignore it |
| 1170 | 1170 | */ |
| 1171 | 1171 | __ieee80211_vht_handle_opmode(sdata, sta, |
| 1172 | − params->opmode_notif, | |
| 1173 | − band, false); | |
| 1172 | + params->opmode_notif, band); | |
| 1174 | 1173 | } |
| 1175 | 1174 | |
| 1176 | 1175 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
| @@ -1709,10 +1709,10 @@ enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta); · 1708 unmodified lines | ||
| 1709 | 1709 | void ieee80211_sta_set_rx_nss(struct sta_info *sta); |
| 1710 | 1710 | u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, |
| 1711 | 1711 | struct sta_info *sta, u8 opmode, |
| 1712 | − enum ieee80211_band band, bool nss_only); | |
| 1712 | + enum ieee80211_band band); | |
| 1713 | 1713 | void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, |
| 1714 | 1714 | struct sta_info *sta, u8 opmode, |
| 1715 | − enum ieee80211_band band, bool nss_only); | |
| 1715 | + enum ieee80211_band band); | |
| 1716 | 1716 | void ieee80211_apply_vhtcap_overrides(struct ieee80211_sub_if_data *sdata, |
| 1717 | 1717 | struct ieee80211_sta_vht_cap *vht_cap); |
| 1718 | 1718 | void ieee80211_get_vht_mask_from_cap(__le16 vht_cap, |
| @@ -1379,21 +1379,26 @@ static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, · 1378 unmodified lines | ||
| 1379 | 1379 | */ |
| 1380 | 1380 | if (has_80211h_pwr && |
| 1381 | 1381 | (!has_cisco_pwr || pwr_level_80211h <= pwr_level_cisco)) { |
| 1382 | + new_ap_level = pwr_level_80211h; | |
| 1383 | + | |
| 1384 | + if (sdata->ap_power_level == new_ap_level) | |
| 1385 | + return 0; | |
| 1386 | + | |
| 1382 | 1387 | sdata_dbg(sdata, |
| 1383 | 1388 | "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n", |
| 1384 | 1389 | pwr_level_80211h, chan_pwr, pwr_reduction_80211h, |
| 1385 | 1390 | sdata->u.mgd.bssid); |
| 1386 | − new_ap_level = pwr_level_80211h; | |
| 1387 | 1391 | } else { /* has_cisco_pwr is always true here. */ |
| 1392 | + new_ap_level = pwr_level_cisco; | |
| 1393 | + | |
| 1394 | + if (sdata->ap_power_level == new_ap_level) | |
| 1395 | + return 0; | |
| 1396 | + | |
| 1388 | 1397 | sdata_dbg(sdata, |
| 1389 | 1398 | "Limiting TX power to %d dBm as advertised by %pM\n", |
| 1390 | 1399 | pwr_level_cisco, sdata->u.mgd.bssid); |
| 1391 | − new_ap_level = pwr_level_cisco; | |
| 1392 | 1400 | } |
| 1393 | 1401 | |
| 1394 | − if (sdata->ap_power_level == new_ap_level) | |
| 1395 | − return 0; | |
| 1396 | − | |
| 1397 | 1402 | sdata->ap_power_level = new_ap_level; |
| 1398 | 1403 | if (__ieee80211_recalc_txpower(sdata)) |
| 1399 | 1404 | return BSS_CHANGED_TXPOWER; |
| @@ -3575,7 +3580,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, · 2175 unmodified lines | ||
| 3575 | 3580 | |
| 3576 | 3581 | if (sta && elems.opmode_notif) |
| 3577 | 3582 | ieee80211_vht_handle_opmode(sdata, sta, *elems.opmode_notif, |
| 3578 | − rx_status->band, true); | |
| 3583 | + rx_status->band); | |
| 3579 | 3584 | mutex_unlock(&local->sta_mtx); |
| 3580 | 3585 | |
| 3581 | 3586 | changed |= ieee80211_handle_pwr_constr(sdata, chan, mgmt, |
| @@ -2736,8 +2736,7 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) · 2735 unmodified lines | ||
| 2736 | 2736 | opmode = mgmt->u.action.u.vht_opmode_notif.operating_mode; |
| 2737 | 2737 | |
| 2738 | 2738 | ieee80211_vht_handle_opmode(rx->sdata, rx->sta, |
| 2739 | − opmode, status->band, | |
| 2740 | − false); | |
| 2739 | + opmode, status->band); | |
| 2741 | 2740 | goto handled; |
| 2742 | 2741 | } |
| 2743 | 2742 | default: |
| @@ -1641,6 +1641,29 @@ void ieee80211_stop_device(struct ieee80211_local *local) · 1640 unmodified lines | ||
| 1641 | 1641 | drv_stop(local); |
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | +static void ieee80211_flush_completed_scan(struct ieee80211_local *local, | |
| 1645 | + bool aborted) | |
| 1646 | +{ | |
| 1647 | + /* It's possible that we don't handle the scan completion in | |
| 1648 | + * time during suspend, so if it's still marked as completed | |
| 1649 | + * here, queue the work and flush it to clean things up. | |
| 1650 | + * Instead of calling the worker function directly here, we | |
| 1651 | + * really queue it to avoid potential races with other flows | |
| 1652 | + * scheduling the same work. | |
| 1653 | + */ | |
| 1654 | + if (test_bit(SCAN_COMPLETED, &local->scanning)) { | |
| 1655 | + /* If coming from reconfiguration failure, abort the scan so | |
| 1656 | + * we don't attempt to continue a partial HW scan - which is | |
| 1657 | + * possible otherwise if (e.g.) the 2.4 GHz portion was the | |
| 1658 | + * completed scan, and a 5 GHz portion is still pending. | |
| 1659 | + */ | |
| 1660 | + if (aborted) | |
| 1661 | + set_bit(SCAN_ABORTED, &local->scanning); | |
| 1662 | + ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); | |
| 1663 | + flush_delayed_work(&local->scan_work); | |
| 1664 | + } | |
| 1665 | +} | |
| 1666 | + | |
| 1644 | 1667 | static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local) |
| 1645 | 1668 | { |
| 1646 | 1669 | struct ieee80211_sub_if_data *sdata; |
| @@ -1660,6 +1683,8 @@ static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local) · 13 unmodified lines | ||
| 1660 | 1683 | local->suspended = false; |
| 1661 | 1684 | local->in_reconfig = false; |
| 1662 | 1685 | |
| 1686 | + ieee80211_flush_completed_scan(local, true); | |
| 1687 | + | |
| 1663 | 1688 | /* scheduled scan clearly can't be running any more, but tell |
| 1664 | 1689 | * cfg80211 and clear local state |
| 1665 | 1690 | */ |
| @@ -1698,6 +1723,27 @@ static void ieee80211_assign_chanctx(struct ieee80211_local *local, · 32 unmodified lines | ||
| 1698 | 1723 | mutex_unlock(&local->chanctx_mtx); |
| 1699 | 1724 | } |
| 1700 | 1725 | |
| 1726 | +static void ieee80211_reconfig_stations(struct ieee80211_sub_if_data *sdata) | |
| 1727 | +{ | |
| 1728 | + struct ieee80211_local *local = sdata->local; | |
| 1729 | + struct sta_info *sta; | |
| 1730 | + | |
| 1731 | + /* add STAs back */ | |
| 1732 | + mutex_lock(&local->sta_mtx); | |
| 1733 | + list_for_each_entry(sta, &local->sta_list, list) { | |
| 1734 | + enum ieee80211_sta_state state; | |
| 1735 | + | |
| 1736 | + if (!sta->uploaded || sta->sdata != sdata) | |
| 1737 | + continue; | |
| 1738 | + | |
| 1739 | + for (state = IEEE80211_STA_NOTEXIST; | |
| 1740 | + state < sta->sta_state; state++) | |
| 1741 | + WARN_ON(drv_sta_state(local, sta->sdata, sta, state, | |
| 1742 | + state + 1)); | |
| 1743 | + } | |
| 1744 | + mutex_unlock(&local->sta_mtx); | |
| 1745 | +} | |
| 1746 | + | |
| 1701 | 1747 | int ieee80211_reconfig(struct ieee80211_local *local) |
| 1702 | 1748 | { |
| 1703 | 1749 | struct ieee80211_hw *hw = &local->hw; |
| @@ -1833,50 +1879,11 @@ int ieee80211_reconfig(struct ieee80211_local *local) · 129 unmodified lines | ||
| 1833 | 1879 | WARN_ON(drv_add_chanctx(local, ctx)); |
| 1834 | 1880 | mutex_unlock(&local->chanctx_mtx); |
| 1835 | 1881 | |
| 1836 | − list_for_each_entry(sdata, &local->interfaces, list) { | |
| 1837 | − if (!ieee80211_sdata_running(sdata)) | |
| 1838 | − continue; | |
| 1839 | − ieee80211_assign_chanctx(local, sdata); | |
| 1840 | − } | |
| 1841 | − | |
| 1842 | 1882 | sdata = rtnl_dereference(local->monitor_sdata); |
| 1843 | 1883 | if (sdata && ieee80211_sdata_running(sdata)) |
| 1844 | 1884 | ieee80211_assign_chanctx(local, sdata); |
| 1845 | 1885 | } |
| 1846 | 1886 | |
| 1847 | − /* add STAs back */ | |
| 1848 | − mutex_lock(&local->sta_mtx); | |
| 1849 | − list_for_each_entry(sta, &local->sta_list, list) { | |
| 1850 | − enum ieee80211_sta_state state; | |
| 1851 | − | |
| 1852 | − if (!sta->uploaded) | |
| 1853 | − continue; | |
| 1854 | − | |
| 1855 | − /* AP-mode stations will be added later */ | |
| 1856 | − if (sta->sdata->vif.type == NL80211_IFTYPE_AP) | |
| 1857 | − continue; | |
| 1858 | − | |
| 1859 | − for (state = IEEE80211_STA_NOTEXIST; | |
| 1860 | − state < sta->sta_state; state++) | |
| 1861 | − WARN_ON(drv_sta_state(local, sta->sdata, sta, state, | |
| 1862 | − state + 1)); | |
| 1863 | − } | |
| 1864 | − mutex_unlock(&local->sta_mtx); | |
| 1865 | − | |
| 1866 | − /* reconfigure tx conf */ | |
| 1867 | − if (hw->queues >= IEEE80211_NUM_ACS) { | |
| 1868 | − list_for_each_entry(sdata, &local->interfaces, list) { | |
| 1869 | − if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN || | |
| 1870 | − sdata->vif.type == NL80211_IFTYPE_MONITOR || | |
| 1871 | − !ieee80211_sdata_running(sdata)) | |
| 1872 | − continue; | |
| 1873 | − | |
| 1874 | − for (i = 0; i < IEEE80211_NUM_ACS; i++) | |
| 1875 | − drv_conf_tx(local, sdata, i, | |
| 1876 | − &sdata->tx_conf[i]); | |
| 1877 | − } | |
| 1878 | − } | |
| 1879 | − | |
| 1880 | 1887 | /* reconfigure hardware */ |
| 1881 | 1888 | ieee80211_hw_config(local, ~0); |
| 1882 | 1889 | |
| @@ -1889,6 +1896,22 @@ int ieee80211_reconfig(struct ieee80211_local *local) · 6 unmodified lines | ||
| 1889 | 1896 | if (!ieee80211_sdata_running(sdata)) |
| 1890 | 1897 | continue; |
| 1891 | 1898 | |
| 1899 | + ieee80211_assign_chanctx(local, sdata); | |
| 1900 | + | |
| 1901 | + switch (sdata->vif.type) { | |
| 1902 | + case NL80211_IFTYPE_AP_VLAN: | |
| 1903 | + case NL80211_IFTYPE_MONITOR: | |
| 1904 | + break; | |
| 1905 | + default: | |
| 1906 | + ieee80211_reconfig_stations(sdata); | |
| 1907 | + /* fall through */ | |
| 1908 | + case NL80211_IFTYPE_AP: /* AP stations are handled later */ | |
| 1909 | + for (i = 0; i < IEEE80211_NUM_ACS; i++) | |
| 1910 | + drv_conf_tx(local, sdata, i, | |
| 1911 | + &sdata->tx_conf[i]); | |
| 1912 | + break; | |
| 1913 | + } | |
| 1914 | + | |
| 1892 | 1915 | /* common change flags for all interface types */ |
| 1893 | 1916 | changed = BSS_CHANGED_ERP_CTS_PROT | |
| 1894 | 1917 | BSS_CHANGED_ERP_PREAMBLE | |
| @@ -2074,17 +2097,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) · 179 unmodified lines | ||
| 2074 | 2097 | mb(); |
| 2075 | 2098 | local->resuming = false; |
| 2076 | 2099 | |
| 2077 | − /* It's possible that we don't handle the scan completion in | |
| 2078 | − * time during suspend, so if it's still marked as completed | |
| 2079 | − * here, queue the work and flush it to clean things up. | |
| 2080 | − * Instead of calling the worker function directly here, we | |
| 2081 | − * really queue it to avoid potential races with other flows | |
| 2082 | − * scheduling the same work. | |
| 2083 | − */ | |
| 2084 | − if (test_bit(SCAN_COMPLETED, &local->scanning)) { | |
| 2085 | − ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0); | |
| 2086 | − flush_delayed_work(&local->scan_work); | |
| 2087 | − } | |
| 2100 | + ieee80211_flush_completed_scan(local, false); | |
| 2088 | 2101 | |
| 2089 | 2102 | if (local->open_count && !reconfig_due_to_wowlan) |
| 2090 | 2103 | drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_SUSPEND); |
| @@ -378,7 +378,7 @@ void ieee80211_sta_set_rx_nss(struct sta_info *sta) · 377 unmodified lines | ||
| 378 | 378 | |
| 379 | 379 | u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, |
| 380 | 380 | struct sta_info *sta, u8 opmode, |
| 381 | − enum ieee80211_band band, bool nss_only) | |
| 381 | + enum ieee80211_band band) | |
| 382 | 382 | { |
| 383 | 383 | struct ieee80211_local *local = sdata->local; |
| 384 | 384 | struct ieee80211_supported_band *sband; |
| @@ -401,9 +401,6 @@ u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, · 16 unmodified lines | ||
| 401 | 401 | changed |= IEEE80211_RC_NSS_CHANGED; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | − if (nss_only) | |
| 405 | − return changed; | |
| 406 | − | |
| 407 | 404 | switch (opmode & IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK) { |
| 408 | 405 | case IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: |
| 409 | 406 | sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_20; |
| @@ -430,13 +427,12 @@ u32 __ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, · 20 unmodified lines | ||
| 430 | 427 | |
| 431 | 428 | void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, |
| 432 | 429 | struct sta_info *sta, u8 opmode, |
| 433 | − enum ieee80211_band band, bool nss_only) | |
| 430 | + enum ieee80211_band band) | |
| 434 | 431 | { |
| 435 | 432 | struct ieee80211_local *local = sdata->local; |
| 436 | 433 | struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band]; |
| 437 | 434 | |
| 438 | − u32 changed = __ieee80211_vht_handle_opmode(sdata, sta, opmode, | |
| 439 | − band, nss_only); | |
| 435 | + u32 changed = __ieee80211_vht_handle_opmode(sdata, sta, opmode, band); | |
| 440 | 436 | |
| 441 | 437 | if (changed > 0) |
| 442 | 438 | rate_control_rate_update(local, sband, sta, changed); |
| @@ -27,6 +27,8 @@ · 26 unmodified lines | ||
| 27 | 27 | */ |
| 28 | 28 | #define MAX_MP_SELECT_LABELS 4 |
| 29 | 29 | |
| 30 | +#define MPLS_NEIGH_TABLE_UNSPEC (NEIGH_LINK_TABLE + 1) | |
| 31 | + | |
| 30 | 32 | static int zero = 0; |
| 31 | 33 | static int label_limit = (1 << 20) - 1; |
| 32 | 34 | |
| @@ -317,7 +319,13 @@ static int mpls_forward(struct sk_buff *skb, struct net_device *dev, · 284 unmodified lines | ||
| 317 | 319 | } |
| 318 | 320 | } |
| 319 | 321 | |
| 320 | − err = neigh_xmit(nh->nh_via_table, out_dev, mpls_nh_via(rt, nh), skb); | |
| 322 | + /* If via wasn't specified then send out using device address */ | |
| 323 | + if (nh->nh_via_table == MPLS_NEIGH_TABLE_UNSPEC) | |
| 324 | + err = neigh_xmit(NEIGH_LINK_TABLE, out_dev, | |
| 325 | + out_dev->dev_addr, skb); | |
| 326 | + else | |
| 327 | + err = neigh_xmit(nh->nh_via_table, out_dev, | |
| 328 | + mpls_nh_via(rt, nh), skb); | |
| 321 | 329 | if (err) |
| 322 | 330 | net_dbg_ratelimited("%s: packet transmission failed: %d\n", |
| 323 | 331 | __func__, err); |
| @@ -534,6 +542,10 @@ static int mpls_nh_assign_dev(struct net *net, struct mpls_route *rt, · 210 unmodified lines | ||
| 534 | 542 | if (!mpls_dev_get(dev)) |
| 535 | 543 | goto errout; |
| 536 | 544 | |
| 545 | + if ((nh->nh_via_table == NEIGH_LINK_TABLE) && | |
| 546 | + (dev->addr_len != nh->nh_via_alen)) | |
| 547 | + goto errout; | |
| 548 | + | |
| 537 | 549 | RCU_INIT_POINTER(nh->nh_dev, dev); |
| 538 | 550 | |
| 539 | 551 | return 0; |
| @@ -592,10 +604,14 @@ static int mpls_nh_build(struct net *net, struct mpls_route *rt, · 52 unmodified lines | ||
| 592 | 604 | goto errout; |
| 593 | 605 | } |
| 594 | 606 | |
| 595 | − err = nla_get_via(via, &nh->nh_via_alen, &nh->nh_via_table, | |
| 596 | − __mpls_nh_via(rt, nh)); | |
| 597 | − if (err) | |
| 598 | − goto errout; | |
| 607 | + if (via) { | |
| 608 | + err = nla_get_via(via, &nh->nh_via_alen, &nh->nh_via_table, | |
| 609 | + __mpls_nh_via(rt, nh)); | |
| 610 | + if (err) | |
| 611 | + goto errout; | |
| 612 | + } else { | |
| 613 | + nh->nh_via_table = MPLS_NEIGH_TABLE_UNSPEC; | |
| 614 | + } | |
| 599 | 615 | |
| 600 | 616 | err = mpls_nh_assign_dev(net, rt, nh, oif); |
| 601 | 617 | if (err) |
| @@ -677,9 +693,6 @@ static int mpls_nh_build_multi(struct mpls_route_config *cfg, · 75 unmodified lines | ||
| 677 | 693 | nla_newdst = nla_find(attrs, attrlen, RTA_NEWDST); |
| 678 | 694 | } |
| 679 | 695 | |
| 680 | − if (!nla_via) | |
| 681 | − goto errout; | |
| 682 | − | |
| 683 | 696 | err = mpls_nh_build(cfg->rc_nlinfo.nl_net, rt, nh, |
| 684 | 697 | rtnh->rtnh_ifindex, nla_via, |
| 685 | 698 | nla_newdst); |
| @@ -1118,6 +1131,7 @@ static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh, · 432 unmodified lines | ||
| 1118 | 1131 | |
| 1119 | 1132 | cfg->rc_label = LABEL_NOT_SPECIFIED; |
| 1120 | 1133 | cfg->rc_protocol = rtm->rtm_protocol; |
| 1134 | + cfg->rc_via_table = MPLS_NEIGH_TABLE_UNSPEC; | |
| 1121 | 1135 | cfg->rc_nlflags = nlh->nlmsg_flags; |
| 1122 | 1136 | cfg->rc_nlinfo.portid = NETLINK_CB(skb).portid; |
| 1123 | 1137 | cfg->rc_nlinfo.nlh = nlh; |
| @@ -1231,7 +1245,8 @@ static int mpls_dump_route(struct sk_buff *skb, u32 portid, u32 seq, int event, · 107 unmodified lines | ||
| 1231 | 1245 | nla_put_labels(skb, RTA_NEWDST, nh->nh_labels, |
| 1232 | 1246 | nh->nh_label)) |
| 1233 | 1247 | goto nla_put_failure; |
| 1234 | − if (nla_put_via(skb, nh->nh_via_table, mpls_nh_via(rt, nh), | |
| 1248 | + if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC && | |
| 1249 | + nla_put_via(skb, nh->nh_via_table, mpls_nh_via(rt, nh), | |
| 1235 | 1250 | nh->nh_via_alen)) |
| 1236 | 1251 | goto nla_put_failure; |
| 1237 | 1252 | dev = rtnl_dereference(nh->nh_dev); |
| @@ -1257,7 +1272,8 @@ static int mpls_dump_route(struct sk_buff *skb, u32 portid, u32 seq, int event, · 19 unmodified lines | ||
| 1257 | 1272 | nh->nh_labels, |
| 1258 | 1273 | nh->nh_label)) |
| 1259 | 1274 | goto nla_put_failure; |
| 1260 | − if (nla_put_via(skb, nh->nh_via_table, | |
| 1275 | + if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC && | |
| 1276 | + nla_put_via(skb, nh->nh_via_table, | |
| 1261 | 1277 | mpls_nh_via(rt, nh), |
| 1262 | 1278 | nh->nh_via_alen)) |
| 1263 | 1279 | goto nla_put_failure; |
| @@ -1319,7 +1335,8 @@ static inline size_t lfib_nlmsg_size(struct mpls_route *rt) · 55 unmodified lines | ||
| 1319 | 1335 | |
| 1320 | 1336 | if (nh->nh_dev) |
| 1321 | 1337 | payload += nla_total_size(4); /* RTA_OIF */ |
| 1322 | − payload += nla_total_size(2 + nh->nh_via_alen); /* RTA_VIA */ | |
| 1338 | + if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC) /* RTA_VIA */ | |
| 1339 | + payload += nla_total_size(2 + nh->nh_via_alen); | |
| 1323 | 1340 | if (nh->nh_labels) /* RTA_NEWDST */ |
| 1324 | 1341 | payload += nla_total_size(nh->nh_labels * 4); |
| 1325 | 1342 | } else { |
| @@ -1328,7 +1345,9 @@ static inline size_t lfib_nlmsg_size(struct mpls_route *rt) · 2 unmodified lines | ||
| 1328 | 1345 | |
| 1329 | 1346 | for_nexthops(rt) { |
| 1330 | 1347 | nhsize += nla_total_size(sizeof(struct rtnexthop)); |
| 1331 | − nhsize += nla_total_size(2 + nh->nh_via_alen); | |
| 1348 | + /* RTA_VIA */ | |
| 1349 | + if (nh->nh_via_table != MPLS_NEIGH_TABLE_UNSPEC) | |
| 1350 | + nhsize += nla_total_size(2 + nh->nh_via_alen); | |
| 1332 | 1351 | if (nh->nh_labels) |
| 1333 | 1352 | nhsize += nla_total_size(nh->nh_labels * 4); |
| 1334 | 1353 | } endfor_nexthops(rt); |
| @@ -54,10 +54,10 @@ int mpls_output(struct net *net, struct sock *sk, struct sk_buff *skb) · 53 unmodified lines | ||
| 54 | 54 | unsigned int ttl; |
| 55 | 55 | |
| 56 | 56 | /* Obtain the ttl */ |
| 57 | − if (skb->protocol == htons(ETH_P_IP)) { | |
| 57 | + if (dst->ops->family == AF_INET) { | |
| 58 | 58 | ttl = ip_hdr(skb)->ttl; |
| 59 | 59 | rt = (struct rtable *)dst; |
| 60 | − } else if (skb->protocol == htons(ETH_P_IPV6)) { | |
| 60 | + } else if (dst->ops->family == AF_INET6) { | |
| 61 | 61 | ttl = ipv6_hdr(skb)->hop_limit; |
| 62 | 62 | rt6 = (struct rt6_info *)dst; |
| 63 | 63 | } else { |
| @@ -89,6 +89,7 @@ nf_tables_afinfo_lookup(struct net *net, int family, bool autoload) · 88 unmodified lines | ||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | static void nft_ctx_init(struct nft_ctx *ctx, |
| 92 | + struct net *net, | |
| 92 | 93 | const struct sk_buff *skb, |
| 93 | 94 | const struct nlmsghdr *nlh, |
| 94 | 95 | struct nft_af_info *afi, |
| @@ -96,7 +97,7 @@ static void nft_ctx_init(struct nft_ctx *ctx, · 1 unmodified line | ||
| 96 | 97 | struct nft_chain *chain, |
| 97 | 98 | const struct nlattr * const *nla) |
| 98 | 99 | { |
| 99 | − ctx->net = sock_net(skb->sk); | |
| 100 | + ctx->net = net; | |
| 100 | 101 | ctx->afi = afi; |
| 101 | 102 | ctx->table = table; |
| 102 | 103 | ctx->chain = chain; |
| @@ -672,15 +673,14 @@ err: · 569 unmodified lines | ||
| 672 | 673 | return ret; |
| 673 | 674 | } |
| 674 | 675 | |
| 675 | −static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb, | |
| 676 | − const struct nlmsghdr *nlh, | |
| 676 | +static int nf_tables_newtable(struct net *net, struct sock *nlsk, | |
| 677 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 677 | 678 | const struct nlattr * const nla[]) |
| 678 | 679 | { |
| 679 | 680 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 680 | 681 | const struct nlattr *name; |
| 681 | 682 | struct nft_af_info *afi; |
| 682 | 683 | struct nft_table *table; |
| 683 | − struct net *net = sock_net(skb->sk); | |
| 684 | 684 | int family = nfmsg->nfgen_family; |
| 685 | 685 | u32 flags = 0; |
| 686 | 686 | struct nft_ctx ctx; |
| @@ -706,7 +706,7 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb, · 19 unmodified lines | ||
| 706 | 706 | if (nlh->nlmsg_flags & NLM_F_REPLACE) |
| 707 | 707 | return -EOPNOTSUPP; |
| 708 | 708 | |
| 709 | − nft_ctx_init(&ctx, skb, nlh, afi, table, NULL, nla); | |
| 709 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, NULL, nla); | |
| 710 | 710 | return nf_tables_updtable(&ctx); |
| 711 | 711 | } |
| 712 | 712 | |
| @@ -730,7 +730,7 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb, · 17 unmodified lines | ||
| 730 | 730 | INIT_LIST_HEAD(&table->sets); |
| 731 | 731 | table->flags = flags; |
| 732 | 732 | |
| 733 | − nft_ctx_init(&ctx, skb, nlh, afi, table, NULL, nla); | |
| 733 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, NULL, nla); | |
| 734 | 734 | err = nft_trans_table_add(&ctx, NFT_MSG_NEWTABLE); |
| 735 | 735 | if (err < 0) |
| 736 | 736 | goto err3; |
| @@ -810,18 +810,17 @@ out: · 73 unmodified lines | ||
| 810 | 810 | return err; |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | −static int nf_tables_deltable(struct sock *nlsk, struct sk_buff *skb, | |
| 814 | − const struct nlmsghdr *nlh, | |
| 813 | +static int nf_tables_deltable(struct net *net, struct sock *nlsk, | |
| 814 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 815 | 815 | const struct nlattr * const nla[]) |
| 816 | 816 | { |
| 817 | 817 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 818 | 818 | struct nft_af_info *afi; |
| 819 | 819 | struct nft_table *table; |
| 820 | − struct net *net = sock_net(skb->sk); | |
| 821 | 820 | int family = nfmsg->nfgen_family; |
| 822 | 821 | struct nft_ctx ctx; |
| 823 | 822 | |
| 824 | − nft_ctx_init(&ctx, skb, nlh, NULL, NULL, NULL, nla); | |
| 823 | + nft_ctx_init(&ctx, net, skb, nlh, NULL, NULL, NULL, nla); | |
| 825 | 824 | if (family == AF_UNSPEC || nla[NFTA_TABLE_NAME] == NULL) |
| 826 | 825 | return nft_flush(&ctx, family); |
| 827 | 826 | |
| @@ -1221,8 +1220,8 @@ static void nf_tables_chain_destroy(struct nft_chain *chain) · 393 unmodified lines | ||
| 1221 | 1220 | } |
| 1222 | 1221 | } |
| 1223 | 1222 | |
| 1224 | −static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, | |
| 1225 | − const struct nlmsghdr *nlh, | |
| 1223 | +static int nf_tables_newchain(struct net *net, struct sock *nlsk, | |
| 1224 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 1226 | 1225 | const struct nlattr * const nla[]) |
| 1227 | 1226 | { |
| 1228 | 1227 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| @@ -1232,7 +1231,6 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, · 3 unmodified lines | ||
| 1232 | 1231 | struct nft_chain *chain; |
| 1233 | 1232 | struct nft_base_chain *basechain = NULL; |
| 1234 | 1233 | struct nlattr *ha[NFTA_HOOK_MAX + 1]; |
| 1235 | − struct net *net = sock_net(skb->sk); | |
| 1236 | 1234 | int family = nfmsg->nfgen_family; |
| 1237 | 1235 | struct net_device *dev = NULL; |
| 1238 | 1236 | u8 policy = NF_ACCEPT; |
| @@ -1313,7 +1311,7 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, · 74 unmodified lines | ||
| 1313 | 1311 | return PTR_ERR(stats); |
| 1314 | 1312 | } |
| 1315 | 1313 | |
| 1316 | − nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla); | |
| 1314 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, chain, nla); | |
| 1317 | 1315 | trans = nft_trans_alloc(&ctx, NFT_MSG_NEWCHAIN, |
| 1318 | 1316 | sizeof(struct nft_trans_chain)); |
| 1319 | 1317 | if (trans == NULL) { |
| @@ -1461,7 +1459,7 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, · 141 unmodified lines | ||
| 1461 | 1459 | if (err < 0) |
| 1462 | 1460 | goto err1; |
| 1463 | 1461 | |
| 1464 | − nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla); | |
| 1462 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, chain, nla); | |
| 1465 | 1463 | err = nft_trans_chain_add(&ctx, NFT_MSG_NEWCHAIN); |
| 1466 | 1464 | if (err < 0) |
| 1467 | 1465 | goto err2; |
| @@ -1476,15 +1474,14 @@ err1: · 8 unmodified lines | ||
| 1476 | 1474 | return err; |
| 1477 | 1475 | } |
| 1478 | 1476 | |
| 1479 | −static int nf_tables_delchain(struct sock *nlsk, struct sk_buff *skb, | |
| 1480 | − const struct nlmsghdr *nlh, | |
| 1477 | +static int nf_tables_delchain(struct net *net, struct sock *nlsk, | |
| 1478 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 1481 | 1479 | const struct nlattr * const nla[]) |
| 1482 | 1480 | { |
| 1483 | 1481 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 1484 | 1482 | struct nft_af_info *afi; |
| 1485 | 1483 | struct nft_table *table; |
| 1486 | 1484 | struct nft_chain *chain; |
| 1487 | − struct net *net = sock_net(skb->sk); | |
| 1488 | 1485 | int family = nfmsg->nfgen_family; |
| 1489 | 1486 | struct nft_ctx ctx; |
| 1490 | 1487 | |
| @@ -1506,7 +1503,7 @@ static int nf_tables_delchain(struct sock *nlsk, struct sk_buff *skb, · 15 unmodified lines | ||
| 1506 | 1503 | if (chain->use > 0) |
| 1507 | 1504 | return -EBUSY; |
| 1508 | 1505 | |
| 1509 | − nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla); | |
| 1506 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, chain, nla); | |
| 1510 | 1507 | |
| 1511 | 1508 | return nft_delchain(&ctx); |
| 1512 | 1509 | } |
| @@ -2010,13 +2007,12 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx, · 497 unmodified lines | ||
| 2010 | 2007 | |
| 2011 | 2008 | static struct nft_expr_info *info; |
| 2012 | 2009 | |
| 2013 | −static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb, | |
| 2014 | − const struct nlmsghdr *nlh, | |
| 2010 | +static int nf_tables_newrule(struct net *net, struct sock *nlsk, | |
| 2011 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 2015 | 2012 | const struct nlattr * const nla[]) |
| 2016 | 2013 | { |
| 2017 | 2014 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 2018 | 2015 | struct nft_af_info *afi; |
| 2019 | − struct net *net = sock_net(skb->sk); | |
| 2020 | 2016 | struct nft_table *table; |
| 2021 | 2017 | struct nft_chain *chain; |
| 2022 | 2018 | struct nft_rule *rule, *old_rule = NULL; |
| @@ -2075,7 +2071,7 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb, · 52 unmodified lines | ||
| 2075 | 2071 | return PTR_ERR(old_rule); |
| 2076 | 2072 | } |
| 2077 | 2073 | |
| 2078 | − nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla); | |
| 2074 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, chain, nla); | |
| 2079 | 2075 | |
| 2080 | 2076 | n = 0; |
| 2081 | 2077 | size = 0; |
| @@ -2176,13 +2172,12 @@ err1: · 94 unmodified lines | ||
| 2176 | 2172 | return err; |
| 2177 | 2173 | } |
| 2178 | 2174 | |
| 2179 | −static int nf_tables_delrule(struct sock *nlsk, struct sk_buff *skb, | |
| 2180 | − const struct nlmsghdr *nlh, | |
| 2175 | +static int nf_tables_delrule(struct net *net, struct sock *nlsk, | |
| 2176 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 2181 | 2177 | const struct nlattr * const nla[]) |
| 2182 | 2178 | { |
| 2183 | 2179 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 2184 | 2180 | struct nft_af_info *afi; |
| 2185 | − struct net *net = sock_net(skb->sk); | |
| 2186 | 2181 | struct nft_table *table; |
| 2187 | 2182 | struct nft_chain *chain = NULL; |
| 2188 | 2183 | struct nft_rule *rule; |
| @@ -2205,7 +2200,7 @@ static int nf_tables_delrule(struct sock *nlsk, struct sk_buff *skb, · 16 unmodified lines | ||
| 2205 | 2200 | return PTR_ERR(chain); |
| 2206 | 2201 | } |
| 2207 | 2202 | |
| 2208 | − nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla); | |
| 2203 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, chain, nla); | |
| 2209 | 2204 | |
| 2210 | 2205 | if (chain) { |
| 2211 | 2206 | if (nla[NFTA_RULE_HANDLE]) { |
| @@ -2344,12 +2339,11 @@ static const struct nla_policy nft_set_desc_policy[NFTA_SET_DESC_MAX + 1] = { · 132 unmodified lines | ||
| 2344 | 2339 | [NFTA_SET_DESC_SIZE] = { .type = NLA_U32 }, |
| 2345 | 2340 | }; |
| 2346 | 2341 | |
| 2347 | −static int nft_ctx_init_from_setattr(struct nft_ctx *ctx, | |
| 2342 | +static int nft_ctx_init_from_setattr(struct nft_ctx *ctx, struct net *net, | |
| 2348 | 2343 | const struct sk_buff *skb, |
| 2349 | 2344 | const struct nlmsghdr *nlh, |
| 2350 | 2345 | const struct nlattr * const nla[]) |
| 2351 | 2346 | { |
| 2352 | − struct net *net = sock_net(skb->sk); | |
| 2353 | 2347 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 2354 | 2348 | struct nft_af_info *afi = NULL; |
| 2355 | 2349 | struct nft_table *table = NULL; |
| @@ -2371,7 +2365,7 @@ static int nft_ctx_init_from_setattr(struct nft_ctx *ctx, · 15 unmodified lines | ||
| 2371 | 2365 | return -ENOENT; |
| 2372 | 2366 | } |
| 2373 | 2367 | |
| 2374 | − nft_ctx_init(ctx, skb, nlh, afi, table, NULL, nla); | |
| 2368 | + nft_ctx_init(ctx, net, skb, nlh, afi, table, NULL, nla); | |
| 2375 | 2369 | return 0; |
| 2376 | 2370 | } |
| 2377 | 2371 | |
| @@ -2623,6 +2617,7 @@ static int nf_tables_getset(struct sock *nlsk, struct sk_buff *skb, · 245 unmodified lines | ||
| 2623 | 2617 | const struct nlmsghdr *nlh, |
| 2624 | 2618 | const struct nlattr * const nla[]) |
| 2625 | 2619 | { |
| 2620 | + struct net *net = sock_net(skb->sk); | |
| 2626 | 2621 | const struct nft_set *set; |
| 2627 | 2622 | struct nft_ctx ctx; |
| 2628 | 2623 | struct sk_buff *skb2; |
| @@ -2630,7 +2625,7 @@ static int nf_tables_getset(struct sock *nlsk, struct sk_buff *skb, · 1 unmodified line | ||
| 2630 | 2625 | int err; |
| 2631 | 2626 | |
| 2632 | 2627 | /* Verify existence before starting dump */ |
| 2633 | − err = nft_ctx_init_from_setattr(&ctx, skb, nlh, nla); | |
| 2628 | + err = nft_ctx_init_from_setattr(&ctx, net, skb, nlh, nla); | |
| 2634 | 2629 | if (err < 0) |
| 2635 | 2630 | return err; |
| 2636 | 2631 | |
| @@ -2693,14 +2688,13 @@ static int nf_tables_set_desc_parse(const struct nft_ctx *ctx, · 56 unmodified lines | ||
| 2693 | 2688 | return 0; |
| 2694 | 2689 | } |
| 2695 | 2690 | |
| 2696 | −static int nf_tables_newset(struct sock *nlsk, struct sk_buff *skb, | |
| 2697 | − const struct nlmsghdr *nlh, | |
| 2691 | +static int nf_tables_newset(struct net *net, struct sock *nlsk, | |
| 2692 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 2698 | 2693 | const struct nlattr * const nla[]) |
| 2699 | 2694 | { |
| 2700 | 2695 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 2701 | 2696 | const struct nft_set_ops *ops; |
| 2702 | 2697 | struct nft_af_info *afi; |
| 2703 | − struct net *net = sock_net(skb->sk); | |
| 2704 | 2698 | struct nft_table *table; |
| 2705 | 2699 | struct nft_set *set; |
| 2706 | 2700 | struct nft_ctx ctx; |
| @@ -2798,7 +2792,7 @@ static int nf_tables_newset(struct sock *nlsk, struct sk_buff *skb, · 91 unmodified lines | ||
| 2798 | 2792 | if (IS_ERR(table)) |
| 2799 | 2793 | return PTR_ERR(table); |
| 2800 | 2794 | |
| 2801 | − nft_ctx_init(&ctx, skb, nlh, afi, table, NULL, nla); | |
| 2795 | + nft_ctx_init(&ctx, net, skb, nlh, afi, table, NULL, nla); | |
| 2802 | 2796 | |
| 2803 | 2797 | set = nf_tables_set_lookup(table, nla[NFTA_SET_NAME]); |
| 2804 | 2798 | if (IS_ERR(set)) { |
| @@ -2882,8 +2876,8 @@ static void nf_tables_set_destroy(const struct nft_ctx *ctx, struct nft_set *set · 77 unmodified lines | ||
| 2882 | 2876 | nft_set_destroy(set); |
| 2883 | 2877 | } |
| 2884 | 2878 | |
| 2885 | −static int nf_tables_delset(struct sock *nlsk, struct sk_buff *skb, | |
| 2886 | − const struct nlmsghdr *nlh, | |
| 2879 | +static int nf_tables_delset(struct net *net, struct sock *nlsk, | |
| 2880 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 2887 | 2881 | const struct nlattr * const nla[]) |
| 2888 | 2882 | { |
| 2889 | 2883 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| @@ -2896,7 +2890,7 @@ static int nf_tables_delset(struct sock *nlsk, struct sk_buff *skb, · 6 unmodified lines | ||
| 2896 | 2890 | if (nla[NFTA_SET_TABLE] == NULL) |
| 2897 | 2891 | return -EINVAL; |
| 2898 | 2892 | |
| 2899 | − err = nft_ctx_init_from_setattr(&ctx, skb, nlh, nla); | |
| 2893 | + err = nft_ctx_init_from_setattr(&ctx, net, skb, nlh, nla); | |
| 2900 | 2894 | if (err < 0) |
| 2901 | 2895 | return err; |
| 2902 | 2896 | |
| @@ -3024,7 +3018,7 @@ static const struct nla_policy nft_set_elem_list_policy[NFTA_SET_ELEM_LIST_MAX + · 121 unmodified lines | ||
| 3024 | 3018 | [NFTA_SET_ELEM_LIST_SET_ID] = { .type = NLA_U32 }, |
| 3025 | 3019 | }; |
| 3026 | 3020 | |
| 3027 | −static int nft_ctx_init_from_elemattr(struct nft_ctx *ctx, | |
| 3021 | +static int nft_ctx_init_from_elemattr(struct nft_ctx *ctx, struct net *net, | |
| 3028 | 3022 | const struct sk_buff *skb, |
| 3029 | 3023 | const struct nlmsghdr *nlh, |
| 3030 | 3024 | const struct nlattr * const nla[], |
| @@ -3033,7 +3027,6 @@ static int nft_ctx_init_from_elemattr(struct nft_ctx *ctx, · 2 unmodified lines | ||
| 3033 | 3027 | const struct nfgenmsg *nfmsg = nlmsg_data(nlh); |
| 3034 | 3028 | struct nft_af_info *afi; |
| 3035 | 3029 | struct nft_table *table; |
| 3036 | − struct net *net = sock_net(skb->sk); | |
| 3037 | 3030 | |
| 3038 | 3031 | afi = nf_tables_afinfo_lookup(net, nfmsg->nfgen_family, false); |
| 3039 | 3032 | if (IS_ERR(afi)) |
| @@ -3045,7 +3038,7 @@ static int nft_ctx_init_from_elemattr(struct nft_ctx *ctx, · 5 unmodified lines | ||
| 3045 | 3038 | if (!trans && (table->flags & NFT_TABLE_INACTIVE)) |
| 3046 | 3039 | return -ENOENT; |
| 3047 | 3040 | |
| 3048 | − nft_ctx_init(ctx, skb, nlh, afi, table, NULL, nla); | |
| 3041 | + nft_ctx_init(ctx, net, skb, nlh, afi, table, NULL, nla); | |
| 3049 | 3042 | return 0; |
| 3050 | 3043 | } |
| 3051 | 3044 | |
| @@ -3135,6 +3128,7 @@ static int nf_tables_dump_setelem(const struct nft_ctx *ctx, · 83 unmodified lines | ||
| 3135 | 3128 | |
| 3136 | 3129 | static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb) |
| 3137 | 3130 | { |
| 3131 | + struct net *net = sock_net(skb->sk); | |
| 3138 | 3132 | const struct nft_set *set; |
| 3139 | 3133 | struct nft_set_dump_args args; |
| 3140 | 3134 | struct nft_ctx ctx; |
| @@ -3150,8 +3144,8 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb) · 9 unmodified lines | ||
| 3150 | 3144 | if (err < 0) |
| 3151 | 3145 | return err; |
| 3152 | 3146 | |
| 3153 | − err = nft_ctx_init_from_elemattr(&ctx, cb->skb, cb->nlh, (void *)nla, | |
| 3154 | − false); | |
| 3147 | + err = nft_ctx_init_from_elemattr(&ctx, net, cb->skb, cb->nlh, | |
| 3148 | + (void *)nla, false); | |
| 3155 | 3149 | if (err < 0) |
| 3156 | 3150 | return err; |
| 3157 | 3151 | |
| @@ -3212,11 +3206,12 @@ static int nf_tables_getsetelem(struct sock *nlsk, struct sk_buff *skb, · 54 unmodified lines | ||
| 3212 | 3206 | const struct nlmsghdr *nlh, |
| 3213 | 3207 | const struct nlattr * const nla[]) |
| 3214 | 3208 | { |
| 3209 | + struct net *net = sock_net(skb->sk); | |
| 3215 | 3210 | const struct nft_set *set; |
| 3216 | 3211 | struct nft_ctx ctx; |
| 3217 | 3212 | int err; |
| 3218 | 3213 | |
| 3219 | − err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, false); | |
| 3214 | + err = nft_ctx_init_from_elemattr(&ctx, net, skb, nlh, nla, false); | |
| 3220 | 3215 | if (err < 0) |
| 3221 | 3216 | return err; |
| 3222 | 3217 | |
| @@ -3528,11 +3523,10 @@ err1: · 305 unmodified lines | ||
| 3528 | 3523 | return err; |
| 3529 | 3524 | } |
| 3530 | 3525 | |
| 3531 | −static int nf_tables_newsetelem(struct sock *nlsk, struct sk_buff *skb, | |
| 3532 | − const struct nlmsghdr *nlh, | |
| 3526 | +static int nf_tables_newsetelem(struct net *net, struct sock *nlsk, | |
| 3527 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 3533 | 3528 | const struct nlattr * const nla[]) |
| 3534 | 3529 | { |
| 3535 | − struct net *net = sock_net(skb->sk); | |
| 3536 | 3530 | const struct nlattr *attr; |
| 3537 | 3531 | struct nft_set *set; |
| 3538 | 3532 | struct nft_ctx ctx; |
| @@ -3541,7 +3535,7 @@ static int nf_tables_newsetelem(struct sock *nlsk, struct sk_buff *skb, · 2 unmodified lines | ||
| 3541 | 3535 | if (nla[NFTA_SET_ELEM_LIST_ELEMENTS] == NULL) |
| 3542 | 3536 | return -EINVAL; |
| 3543 | 3537 | |
| 3544 | − err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, true); | |
| 3538 | + err = nft_ctx_init_from_elemattr(&ctx, net, skb, nlh, nla, true); | |
| 3545 | 3539 | if (err < 0) |
| 3546 | 3540 | return err; |
| 3547 | 3541 | |
| @@ -3623,8 +3617,8 @@ err1: · 75 unmodified lines | ||
| 3623 | 3617 | return err; |
| 3624 | 3618 | } |
| 3625 | 3619 | |
| 3626 | −static int nf_tables_delsetelem(struct sock *nlsk, struct sk_buff *skb, | |
| 3627 | − const struct nlmsghdr *nlh, | |
| 3620 | +static int nf_tables_delsetelem(struct net *net, struct sock *nlsk, | |
| 3621 | + struct sk_buff *skb, const struct nlmsghdr *nlh, | |
| 3628 | 3622 | const struct nlattr * const nla[]) |
| 3629 | 3623 | { |
| 3630 | 3624 | const struct nlattr *attr; |
| @@ -3635,7 +3629,7 @@ static int nf_tables_delsetelem(struct sock *nlsk, struct sk_buff *skb, · 4 unmodified lines | ||
| 3635 | 3629 | if (nla[NFTA_SET_ELEM_LIST_ELEMENTS] == NULL) |
| 3636 | 3630 | return -EINVAL; |
| 3637 | 3631 | |
| 3638 | − err = nft_ctx_init_from_elemattr(&ctx, skb, nlh, nla, false); | |
| 3632 | + err = nft_ctx_init_from_elemattr(&ctx, net, skb, nlh, nla, false); | |
| 3639 | 3633 | if (err < 0) |
| 3640 | 3634 | return err; |
| 3641 | 3635 | |
| @@ -4030,7 +4024,8 @@ static int nf_tables_abort(struct sk_buff *skb) · 388 unmodified lines | ||
| 4030 | 4024 | struct nft_trans *trans, *next; |
| 4031 | 4025 | struct nft_trans_elem *te; |
| 4032 | 4026 | |
| 4033 | − list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { | |
| 4027 | + list_for_each_entry_safe_reverse(trans, next, &net->nft.commit_list, | |
| 4028 | + list) { | |
| 4034 | 4029 | switch (trans->msg_type) { |
| 4035 | 4030 | case NFT_MSG_NEWTABLE: |
| 4036 | 4031 | if (nft_trans_table_update(trans)) { |
| @@ -94,7 +94,7 @@ nft_do_chain_netdev(void *priv, struct sk_buff *skb, · 93 unmodified lines | ||
| 94 | 94 | { |
| 95 | 95 | struct nft_pktinfo pkt; |
| 96 | 96 | |
| 97 | − switch (eth_hdr(skb)->h_proto) { | |
| 97 | + switch (skb->protocol) { | |
| 98 | 98 | case htons(ETH_P_IP): |
| 99 | 99 | nft_netdev_set_pktinfo_ipv4(&pkt, skb, state); |
| 100 | 100 | break; |
| @@ -295,8 +295,6 @@ replay: · 294 unmodified lines | ||
| 295 | 295 | if (!skb) |
| 296 | 296 | return netlink_ack(oskb, nlh, -ENOMEM); |
| 297 | 297 | |
| 298 | − skb->sk = oskb->sk; | |
| 299 | − | |
| 300 | 298 | nfnl_lock(subsys_id); |
| 301 | 299 | ss = rcu_dereference_protected(table[subsys_id].subsys, |
| 302 | 300 | lockdep_is_held(&table[subsys_id].mutex)); |
| @@ -381,7 +379,7 @@ replay: · 78 unmodified lines | ||
| 381 | 379 | goto ack; |
| 382 | 380 | |
| 383 | 381 | if (nc->call_batch) { |
| 384 | − err = nc->call_batch(net->nfnl, skb, nlh, | |
| 382 | + err = nc->call_batch(net, net->nfnl, skb, nlh, | |
| 385 | 383 | (const struct nlattr **)cda); |
| 386 | 384 | } |
| 387 | 385 | |
| @@ -365,8 +365,9 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, · 364 unmodified lines | ||
| 365 | 365 | break; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | + nfnl_ct = rcu_dereference(nfnl_ct_hook); | |
| 369 | + | |
| 368 | 370 | if (queue->flags & NFQA_CFG_F_CONNTRACK) { |
| 369 | − nfnl_ct = rcu_dereference(nfnl_ct_hook); | |
| 370 | 371 | if (nfnl_ct != NULL) { |
| 371 | 372 | ct = nfnl_ct->get_ct(entskb, &ctinfo); |
| 372 | 373 | if (ct != NULL) |
| @@ -1064,9 +1065,10 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb, · 691 unmodified lines | ||
| 1064 | 1065 | if (entry == NULL) |
| 1065 | 1066 | return -ENOENT; |
| 1066 | 1067 | |
| 1068 | + /* rcu lock already held from nfnl->call_rcu. */ | |
| 1069 | + nfnl_ct = rcu_dereference(nfnl_ct_hook); | |
| 1070 | + | |
| 1067 | 1071 | if (nfqa[NFQA_CT]) { |
| 1068 | − /* rcu lock already held from nfnl->call_rcu. */ | |
| 1069 | − nfnl_ct = rcu_dereference(nfnl_ct_hook); | |
| 1070 | 1072 | if (nfnl_ct != NULL) |
| 1071 | 1073 | ct = nfqnl_ct_parse(nfnl_ct, nlh, nfqa, entry, &ctinfo); |
| 1072 | 1074 | } |
| @@ -1417,6 +1419,7 @@ static int __init nfnetlink_queue_init(void) · 344 unmodified lines | ||
| 1417 | 1419 | |
| 1418 | 1420 | cleanup_netlink_notifier: |
| 1419 | 1421 | netlink_unregister_notifier(&nfqnl_rtnl_notifier); |
| 1422 | + unregister_pernet_subsys(&nfnl_queue_net_ops); | |
| 1420 | 1423 | out: |
| 1421 | 1424 | return status; |
| 1422 | 1425 | } |
| @@ -366,6 +366,7 @@ static int nft_ct_get_dump(struct sk_buff *skb, const struct nft_expr *expr) · 365 unmodified lines | ||
| 366 | 366 | goto nla_put_failure; |
| 367 | 367 | |
| 368 | 368 | switch (priv->key) { |
| 369 | + case NFT_CT_L3PROTOCOL: | |
| 369 | 370 | case NFT_CT_PROTOCOL: |
| 370 | 371 | case NFT_CT_SRC: |
| 371 | 372 | case NFT_CT_DST: |
| @@ -53,6 +53,8 @@ struct ovs_conntrack_info { · 52 unmodified lines | ||
| 53 | 53 | struct md_labels labels; |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | +static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info); | |
| 57 | + | |
| 56 | 58 | static u16 key_to_nfproto(const struct sw_flow_key *key) |
| 57 | 59 | { |
| 58 | 60 | switch (ntohs(key->eth.type)) { |
| @@ -141,6 +143,7 @@ static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state, · 82 unmodified lines | ||
| 141 | 143 | * previously sent the packet to conntrack via the ct action. |
| 142 | 144 | */ |
| 143 | 145 | static void ovs_ct_update_key(const struct sk_buff *skb, |
| 146 | + const struct ovs_conntrack_info *info, | |
| 144 | 147 | struct sw_flow_key *key, bool post_ct) |
| 145 | 148 | { |
| 146 | 149 | const struct nf_conntrack_zone *zone = &nf_ct_zone_dflt; |
| @@ -158,13 +161,15 @@ static void ovs_ct_update_key(const struct sk_buff *skb, · 11 unmodified lines | ||
| 158 | 161 | zone = nf_ct_zone(ct); |
| 159 | 162 | } else if (post_ct) { |
| 160 | 163 | state = OVS_CS_F_TRACKED | OVS_CS_F_INVALID; |
| 164 | + if (info) | |
| 165 | + zone = &info->zone; | |
| 161 | 166 | } |
| 162 | 167 | __ovs_ct_update_key(key, state, zone, ct); |
| 163 | 168 | } |
| 164 | 169 | |
| 165 | 170 | void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key) |
| 166 | 171 | { |
| 167 | − ovs_ct_update_key(skb, key, false); | |
| 172 | + ovs_ct_update_key(skb, NULL, key, false); | |
| 168 | 173 | } |
| 169 | 174 | |
| 170 | 175 | int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb) |
| @@ -418,7 +423,7 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, · 247 unmodified lines | ||
| 418 | 423 | } |
| 419 | 424 | } |
| 420 | 425 | |
| 421 | − ovs_ct_update_key(skb, key, true); | |
| 426 | + ovs_ct_update_key(skb, info, key, true); | |
| 422 | 427 | |
| 423 | 428 | return 0; |
| 424 | 429 | } |
| @@ -693,6 +698,10 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr, · 268 unmodified lines | ||
| 693 | 698 | OVS_NLERR(log, "Failed to allocate conntrack template"); |
| 694 | 699 | return -ENOMEM; |
| 695 | 700 | } |
| 701 | + | |
| 702 | + __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); | |
| 703 | + nf_conntrack_get(&ct_info.ct->ct_general); | |
| 704 | + | |
| 696 | 705 | if (helper) { |
| 697 | 706 | err = ovs_ct_add_helper(&ct_info, helper, key, log); |
| 698 | 707 | if (err) |
| @@ -704,11 +713,9 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr, · 5 unmodified lines | ||
| 704 | 713 | if (err) |
| 705 | 714 | goto err_free_ct; |
| 706 | 715 | |
| 707 | − __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); | |
| 708 | − nf_conntrack_get(&ct_info.ct->ct_general); | |
| 709 | 716 | return 0; |
| 710 | 717 | err_free_ct: |
| 711 | − nf_conntrack_free(ct_info.ct); | |
| 718 | + __ovs_ct_free_action(&ct_info); | |
| 712 | 719 | return err; |
| 713 | 720 | } |
| 714 | 721 | |
| @@ -750,6 +757,11 @@ void ovs_ct_free_action(const struct nlattr *a) · 35 unmodified lines | ||
| 750 | 757 | { |
| 751 | 758 | struct ovs_conntrack_info *ct_info = nla_data(a); |
| 752 | 759 | |
| 760 | + __ovs_ct_free_action(ct_info); | |
| 761 | +} | |
| 762 | + | |
| 763 | +static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info) | |
| 764 | +{ | |
| 753 | 765 | if (ct_info->helper) |
| 754 | 766 | module_put(ct_info->helper->me); |
| 755 | 767 | if (ct_info->ct) |
| @@ -2434,7 +2434,10 @@ static int set_action_to_attr(const struct nlattr *a, struct sk_buff *skb) · 2433 unmodified lines | ||
| 2434 | 2434 | if (!start) |
| 2435 | 2435 | return -EMSGSIZE; |
| 2436 | 2436 | |
| 2437 | − err = ovs_nla_put_tunnel_info(skb, tun_info); | |
| 2437 | + err = ip_tun_to_nlattr(skb, &tun_info->key, | |
| 2438 | + ip_tunnel_info_opts(tun_info), | |
| 2439 | + tun_info->options_len, | |
| 2440 | + ip_tunnel_info_af(tun_info)); | |
| 2438 | 2441 | if (err) |
| 2439 | 2442 | return err; |
| 2440 | 2443 | nla_nest_end(skb, start); |
| @@ -49,7 +49,6 @@ · 48 unmodified lines | ||
| 49 | 49 | struct rfkill { |
| 50 | 50 | spinlock_t lock; |
| 51 | 51 | |
| 52 | − const char *name; | |
| 53 | 52 | enum rfkill_type type; |
| 54 | 53 | |
| 55 | 54 | unsigned long state; |
| @@ -73,6 +72,7 @@ struct rfkill { · 17 unmodified lines | ||
| 73 | 72 | struct delayed_work poll_work; |
| 74 | 73 | struct work_struct uevent_work; |
| 75 | 74 | struct work_struct sync_work; |
| 75 | + char name[]; | |
| 76 | 76 | }; |
| 77 | 77 | #define to_rfkill(d) container_of(d, struct rfkill, dev) |
| 78 | 78 | |
| @@ -876,14 +876,14 @@ struct rfkill * __must_check rfkill_alloc(const char *name, · 797 unmodified lines | ||
| 876 | 876 | if (WARN_ON(type == RFKILL_TYPE_ALL || type >= NUM_RFKILL_TYPES)) |
| 877 | 877 | return NULL; |
| 878 | 878 | |
| 879 | − rfkill = kzalloc(sizeof(*rfkill), GFP_KERNEL); | |
| 879 | + rfkill = kzalloc(sizeof(*rfkill) + strlen(name) + 1, GFP_KERNEL); | |
| 880 | 880 | if (!rfkill) |
| 881 | 881 | return NULL; |
| 882 | 882 | |
| 883 | 883 | spin_lock_init(&rfkill->lock); |
| 884 | 884 | INIT_LIST_HEAD(&rfkill->node); |
| 885 | 885 | rfkill->type = type; |
| 886 | − rfkill->name = name; | |
| 886 | + strcpy(rfkill->name, name); | |
| 887 | 887 | rfkill->ops = ops; |
| 888 | 888 | rfkill->data = ops_data; |
| 889 | 889 | |
| @@ -950,7 +950,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, · 949 unmodified lines | ||
| 950 | 950 | } |
| 951 | 951 | lockdep_set_class(qdisc_lock(sch), &qdisc_tx_lock); |
| 952 | 952 | if (!netif_is_multiqueue(dev)) |
| 953 | − sch->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; | |
| 953 | + sch->flags |= TCQ_F_ONETXQUEUE; | |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | sch->handle = handle; |
| @@ -658,8 +658,10 @@ static void qdisc_rcu_free(struct rcu_head *head) · 657 unmodified lines | ||
| 658 | 658 | { |
| 659 | 659 | struct Qdisc *qdisc = container_of(head, struct Qdisc, rcu_head); |
| 660 | 660 | |
| 661 | − if (qdisc_is_percpu_stats(qdisc)) | |
| 661 | + if (qdisc_is_percpu_stats(qdisc)) { | |
| 662 | 662 | free_percpu(qdisc->cpu_bstats); |
| 663 | + free_percpu(qdisc->cpu_qstats); | |
| 664 | + } | |
| 663 | 665 | |
| 664 | 666 | kfree((char *) qdisc - qdisc->padded); |
| 665 | 667 | } |
| @@ -323,14 +323,13 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr, · 322 unmodified lines | ||
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | − rcu_read_unlock(); | |
| 327 | − | |
| 328 | 326 | if (baddr) { |
| 329 | 327 | fl6->saddr = baddr->v6.sin6_addr; |
| 330 | 328 | fl6->fl6_sport = baddr->v6.sin6_port; |
| 331 | 329 | final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &final); |
| 332 | 330 | dst = ip6_dst_lookup_flow(sk, fl6, final_p); |
| 333 | 331 | } |
| 332 | + rcu_read_unlock(); | |
| 334 | 333 | |
| 335 | 334 | out: |
| 336 | 335 | if (!IS_ERR_OR_NULL(dst)) { |
| @@ -642,6 +641,7 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk, · 305 unmodified lines | ||
| 642 | 641 | struct sock *newsk; |
| 643 | 642 | struct ipv6_pinfo *newnp, *np = inet6_sk(sk); |
| 644 | 643 | struct sctp6_sock *newsctp6sk; |
| 644 | + struct ipv6_txoptions *opt; | |
| 645 | 645 | |
| 646 | 646 | newsk = sk_alloc(sock_net(sk), PF_INET6, GFP_KERNEL, sk->sk_prot, 0); |
| 647 | 647 | if (!newsk) |
| @@ -661,6 +661,13 @@ static struct sock *sctp_v6_create_accept_sk(struct sock *sk, · 13 unmodified lines | ||
| 661 | 661 | |
| 662 | 662 | memcpy(newnp, np, sizeof(struct ipv6_pinfo)); |
| 663 | 663 | |
| 664 | + rcu_read_lock(); | |
| 665 | + opt = rcu_dereference(np->opt); | |
| 666 | + if (opt) | |
| 667 | + opt = ipv6_dup_options(newsk, opt); | |
| 668 | + RCU_INIT_POINTER(newnp->opt, opt); | |
| 669 | + rcu_read_unlock(); | |
| 670 | + | |
| 664 | 671 | /* Initialize sk's sport, dport, rcv_saddr and daddr for getsockname() |
| 665 | 672 | * and getpeername(). |
| 666 | 673 | */ |
| @@ -324,6 +324,7 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk) · 323 unmodified lines | ||
| 324 | 324 | sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) : |
| 325 | 325 | "illegal chunk"); |
| 326 | 326 | |
| 327 | + sctp_chunk_hold(chunk); | |
| 327 | 328 | sctp_outq_tail_data(q, chunk); |
| 328 | 329 | if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) |
| 329 | 330 | SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS); |
| @@ -1251,6 +1252,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk) · 921 unmodified lines | ||
| 1251 | 1252 | */ |
| 1252 | 1253 | |
| 1253 | 1254 | sack_a_rwnd = ntohl(sack->a_rwnd); |
| 1255 | + asoc->peer.zero_window_announced = !sack_a_rwnd; | |
| 1254 | 1256 | outstanding = q->outstanding_bytes; |
| 1255 | 1257 | |
| 1256 | 1258 | if (outstanding < sack_a_rwnd) |
| @@ -1652,7 +1652,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep, · 1651 unmodified lines | ||
| 1652 | 1652 | |
| 1653 | 1653 | /* Set an expiration time for the cookie. */ |
| 1654 | 1654 | cookie->c.expiration = ktime_add(asoc->cookie_life, |
| 1655 | − ktime_get()); | |
| 1655 | + ktime_get_real()); | |
| 1656 | 1656 | |
| 1657 | 1657 | /* Copy the peer's init packet. */ |
| 1658 | 1658 | memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr, |
| @@ -1780,7 +1780,7 @@ no_hmac: · 121 unmodified lines | ||
| 1780 | 1780 | if (sock_flag(ep->base.sk, SOCK_TIMESTAMP)) |
| 1781 | 1781 | kt = skb_get_ktime(skb); |
| 1782 | 1782 | else |
| 1783 | − kt = ktime_get(); | |
| 1783 | + kt = ktime_get_real(); | |
| 1784 | 1784 | |
| 1785 | 1785 | if (!asoc && ktime_before(bear_cookie->expiration, kt)) { |
| 1786 | 1786 | /* |
| @@ -4829,7 +4829,8 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort( · 4828 unmodified lines | ||
| 4829 | 4829 | |
| 4830 | 4830 | retval = SCTP_DISPOSITION_CONSUME; |
| 4831 | 4831 | |
| 4832 | − sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | |
| 4832 | + if (abort) | |
| 4833 | + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | |
| 4833 | 4834 | |
| 4834 | 4835 | /* Even if we can't send the ABORT due to low memory delete the |
| 4835 | 4836 | * TCB. This is a departure from our typical NOMEM handling. |
| @@ -4966,7 +4967,8 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort( · 130 unmodified lines | ||
| 4966 | 4967 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); |
| 4967 | 4968 | retval = SCTP_DISPOSITION_CONSUME; |
| 4968 | 4969 | |
| 4969 | − sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | |
| 4970 | + if (abort) | |
| 4971 | + sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | |
| 4970 | 4972 | |
| 4971 | 4973 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
| 4972 | 4974 | SCTP_STATE(SCTP_STATE_CLOSED)); |
| @@ -5412,7 +5414,8 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(struct net *net, · 439 unmodified lines | ||
| 5412 | 5414 | SCTP_INC_STATS(net, SCTP_MIB_T3_RTX_EXPIREDS); |
| 5413 | 5415 | |
| 5414 | 5416 | if (asoc->overall_error_count >= asoc->max_retrans) { |
| 5415 | − if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { | |
| 5417 | + if (asoc->peer.zero_window_announced && | |
| 5418 | + asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { | |
| 5416 | 5419 | /* |
| 5417 | 5420 | * We are here likely because the receiver had its rwnd |
| 5418 | 5421 | * closed for a while and we have not been able to |
| @@ -1301,8 +1301,9 @@ static int __sctp_setsockopt_connectx(struct sock *sk, · 1300 unmodified lines | ||
| 1301 | 1301 | int addrs_size, |
| 1302 | 1302 | sctp_assoc_t *assoc_id) |
| 1303 | 1303 | { |
| 1304 | − int err = 0; | |
| 1305 | 1304 | struct sockaddr *kaddrs; |
| 1305 | + gfp_t gfp = GFP_KERNEL; | |
| 1306 | + int err = 0; | |
| 1306 | 1307 | |
| 1307 | 1308 | pr_debug("%s: sk:%p addrs:%p addrs_size:%d\n", |
| 1308 | 1309 | __func__, sk, addrs, addrs_size); |
| @@ -1315,7 +1316,9 @@ static int __sctp_setsockopt_connectx(struct sock *sk, · 6 unmodified lines | ||
| 1315 | 1316 | return -EFAULT; |
| 1316 | 1317 | |
| 1317 | 1318 | /* Alloc space for the address array in kernel memory. */ |
| 1318 | − kaddrs = kmalloc(addrs_size, GFP_KERNEL); | |
| 1319 | + if (sk->sk_socket->file) | |
| 1320 | + gfp = GFP_USER | __GFP_NOWARN; | |
| 1321 | + kaddrs = kmalloc(addrs_size, gfp); | |
| 1319 | 1322 | if (unlikely(!kaddrs)) |
| 1320 | 1323 | return -ENOMEM; |
| 1321 | 1324 | |
| @@ -1513,8 +1516,7 @@ static void sctp_close(struct sock *sk, long timeout) · 191 unmodified lines | ||
| 1513 | 1516 | struct sctp_chunk *chunk; |
| 1514 | 1517 | |
| 1515 | 1518 | chunk = sctp_make_abort_user(asoc, NULL, 0); |
| 1516 | − if (chunk) | |
| 1517 | − sctp_primitive_ABORT(net, asoc, chunk); | |
| 1519 | + sctp_primitive_ABORT(net, asoc, chunk); | |
| 1518 | 1520 | } else |
| 1519 | 1521 | sctp_primitive_SHUTDOWN(net, asoc, NULL); |
| 1520 | 1522 | } |
| @@ -1952,8 +1954,6 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) · 431 unmodified lines | ||
| 1952 | 1954 | |
| 1953 | 1955 | /* Now send the (possibly) fragmented message. */ |
| 1954 | 1956 | list_for_each_entry(chunk, &datamsg->chunks, frag_list) { |
| 1955 | − sctp_chunk_hold(chunk); | |
| 1956 | − | |
| 1957 | 1957 | /* Do accounting for the write space. */ |
| 1958 | 1958 | sctp_set_owner_w(chunk); |
| 1959 | 1959 | |
| @@ -1966,15 +1966,13 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) · 6 unmodified lines | ||
| 1966 | 1966 | * breaks. |
| 1967 | 1967 | */ |
| 1968 | 1968 | err = sctp_primitive_SEND(net, asoc, datamsg); |
| 1969 | + sctp_datamsg_put(datamsg); | |
| 1969 | 1970 | /* Did the lower layer accept the chunk? */ |
| 1970 | − if (err) { | |
| 1971 | − sctp_datamsg_free(datamsg); | |
| 1971 | + if (err) | |
| 1972 | 1972 | goto out_free; |
| 1973 | − } | |
| 1974 | 1973 | |
| 1975 | 1974 | pr_debug("%s: we sent primitively\n", __func__); |
| 1976 | 1975 | |
| 1977 | − sctp_datamsg_put(datamsg); | |
| 1978 | 1976 | err = msg_len; |
| 1979 | 1977 | |
| 1980 | 1978 | if (unlikely(wait_connect)) { |
| @@ -5777,7 +5775,7 @@ static int sctp_getsockopt_assoc_ids(struct sock *sk, int len, · 3796 unmodified lines | ||
| 5777 | 5775 | |
| 5778 | 5776 | len = sizeof(struct sctp_assoc_ids) + sizeof(sctp_assoc_t) * num; |
| 5779 | 5777 | |
| 5780 | − ids = kmalloc(len, GFP_KERNEL); | |
| 5778 | + ids = kmalloc(len, GFP_USER | __GFP_NOWARN); | |
| 5781 | 5779 | if (unlikely(!ids)) |
| 5782 | 5780 | return -ENOMEM; |
| 5783 | 5781 | |
| @@ -7167,6 +7165,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, · 1383 unmodified lines | ||
| 7167 | 7165 | newsk->sk_type = sk->sk_type; |
| 7168 | 7166 | newsk->sk_bound_dev_if = sk->sk_bound_dev_if; |
| 7169 | 7167 | newsk->sk_flags = sk->sk_flags; |
| 7168 | + newsk->sk_tsflags = sk->sk_tsflags; | |
| 7170 | 7169 | newsk->sk_no_check_tx = sk->sk_no_check_tx; |
| 7171 | 7170 | newsk->sk_no_check_rx = sk->sk_no_check_rx; |
| 7172 | 7171 | newsk->sk_reuse = sk->sk_reuse; |
| @@ -7199,6 +7198,11 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, · 26 unmodified lines | ||
| 7199 | 7198 | newinet->mc_ttl = 1; |
| 7200 | 7199 | newinet->mc_index = 0; |
| 7201 | 7200 | newinet->mc_list = NULL; |
| 7201 | + | |
| 7202 | + if (newsk->sk_flags & SK_FLAGS_TIMESTAMP) | |
| 7203 | + net_enable_timestamp(); | |
| 7204 | + | |
| 7205 | + security_sk_clone(sk, newsk); | |
| 7202 | 7206 | } |
| 7203 | 7207 | |
| 7204 | 7208 | static inline void sctp_copy_descendant(struct sock *sk_to, |
| @@ -257,6 +257,7 @@ static struct inode *sock_alloc_inode(struct super_block *sb) · 256 unmodified lines | ||
| 257 | 257 | } |
| 258 | 258 | init_waitqueue_head(&wq->wait); |
| 259 | 259 | wq->fasync_list = NULL; |
| 260 | + wq->flags = 0; | |
| 260 | 261 | RCU_INIT_POINTER(ei->socket.wq, wq); |
| 261 | 262 | |
| 262 | 263 | ei->socket.state = SS_UNCONNECTED; |
| @@ -1695,6 +1696,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size, · 1432 unmodified lines | ||
| 1695 | 1696 | msg.msg_name = addr ? (struct sockaddr *)&address : NULL; |
| 1696 | 1697 | /* We assume all kernel code knows the size of sockaddr_storage */ |
| 1697 | 1698 | msg.msg_namelen = 0; |
| 1699 | + msg.msg_iocb = NULL; | |
| 1698 | 1700 | if (sock->file->f_flags & O_NONBLOCK) |
| 1699 | 1701 | flags |= MSG_DONTWAIT; |
| 1700 | 1702 | err = sock_recvmsg(sock, &msg, iov_iter_count(&msg.msg_iter), flags); |
| @@ -953,32 +953,20 @@ fail: · 952 unmodified lines | ||
| 953 | 953 | return NULL; |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | −static int unix_mknod(const char *sun_path, umode_t mode, struct path *res) | |
| 956 | +static int unix_mknod(struct dentry *dentry, struct path *path, umode_t mode, | |
| 957 | + struct path *res) | |
| 957 | 958 | { |
| 958 | − struct dentry *dentry; | |
| 959 | − struct path path; | |
| 960 | − int err = 0; | |
| 961 | − /* | |
| 962 | − * Get the parent directory, calculate the hash for last | |
| 963 | − * component. | |
| 964 | − */ | |
| 965 | − dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); | |
| 966 | − err = PTR_ERR(dentry); | |
| 967 | − if (IS_ERR(dentry)) | |
| 968 | − return err; | |
| 959 | + int err; | |
| 969 | 960 | |
| 970 | − /* | |
| 971 | − * All right, let's create it. | |
| 972 | − */ | |
| 973 | − err = security_path_mknod(&path, dentry, mode, 0); | |
| 961 | + err = security_path_mknod(path, dentry, mode, 0); | |
| 974 | 962 | if (!err) { |
| 975 | − err = vfs_mknod(d_inode(path.dentry), dentry, mode, 0); | |
| 963 | + err = vfs_mknod(d_inode(path->dentry), dentry, mode, 0); | |
| 976 | 964 | if (!err) { |
| 977 | − res->mnt = mntget(path.mnt); | |
| 965 | + res->mnt = mntget(path->mnt); | |
| 978 | 966 | res->dentry = dget(dentry); |
| 979 | 967 | } |
| 980 | 968 | } |
| 981 | − done_path_create(&path, dentry); | |
| 969 | + | |
| 982 | 970 | return err; |
| 983 | 971 | } |
| 984 | 972 | |
| @@ -989,10 +977,12 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 4 unmodified lines | ||
| 989 | 977 | struct unix_sock *u = unix_sk(sk); |
| 990 | 978 | struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr; |
| 991 | 979 | char *sun_path = sunaddr->sun_path; |
| 992 | − int err; | |
| 980 | + int err, name_err; | |
| 993 | 981 | unsigned int hash; |
| 994 | 982 | struct unix_address *addr; |
| 995 | 983 | struct hlist_head *list; |
| 984 | + struct path path; | |
| 985 | + struct dentry *dentry; | |
| 996 | 986 | |
| 997 | 987 | err = -EINVAL; |
| 998 | 988 | if (sunaddr->sun_family != AF_UNIX) |
| @@ -1008,14 +998,34 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 9 unmodified lines | ||
| 1008 | 998 | goto out; |
| 1009 | 999 | addr_len = err; |
| 1010 | 1000 | |
| 1001 | + name_err = 0; | |
| 1002 | + dentry = NULL; | |
| 1003 | + if (sun_path[0]) { | |
| 1004 | + /* Get the parent directory, calculate the hash for last | |
| 1005 | + * component. | |
| 1006 | + */ | |
| 1007 | + dentry = kern_path_create(AT_FDCWD, sun_path, &path, 0); | |
| 1008 | + | |
| 1009 | + if (IS_ERR(dentry)) { | |
| 1010 | + /* delay report until after 'already bound' check */ | |
| 1011 | + name_err = PTR_ERR(dentry); | |
| 1012 | + dentry = NULL; | |
| 1013 | + } | |
| 1014 | + } | |
| 1015 | + | |
| 1011 | 1016 | err = mutex_lock_interruptible(&u->readlock); |
| 1012 | 1017 | if (err) |
| 1013 | − goto out; | |
| 1018 | + goto out_path; | |
| 1014 | 1019 | |
| 1015 | 1020 | err = -EINVAL; |
| 1016 | 1021 | if (u->addr) |
| 1017 | 1022 | goto out_up; |
| 1018 | 1023 | |
| 1024 | + if (name_err) { | |
| 1025 | + err = name_err == -EEXIST ? -EADDRINUSE : name_err; | |
| 1026 | + goto out_up; | |
| 1027 | + } | |
| 1028 | + | |
| 1019 | 1029 | err = -ENOMEM; |
| 1020 | 1030 | addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL); |
| 1021 | 1031 | if (!addr) |
| @@ -1026,11 +1036,11 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 4 unmodified lines | ||
| 1026 | 1036 | addr->hash = hash ^ sk->sk_type; |
| 1027 | 1037 | atomic_set(&addr->refcnt, 1); |
| 1028 | 1038 | |
| 1029 | − if (sun_path[0]) { | |
| 1030 | − struct path path; | |
| 1039 | + if (dentry) { | |
| 1040 | + struct path u_path; | |
| 1031 | 1041 | umode_t mode = S_IFSOCK | |
| 1032 | 1042 | (SOCK_INODE(sock)->i_mode & ~current_umask()); |
| 1033 | − err = unix_mknod(sun_path, mode, &path); | |
| 1043 | + err = unix_mknod(dentry, &path, mode, &u_path); | |
| 1034 | 1044 | if (err) { |
| 1035 | 1045 | if (err == -EEXIST) |
| 1036 | 1046 | err = -EADDRINUSE; |
| @@ -1038,9 +1048,9 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 1 unmodified line | ||
| 1038 | 1048 | goto out_up; |
| 1039 | 1049 | } |
| 1040 | 1050 | addr->hash = UNIX_HASH_SIZE; |
| 1041 | − hash = d_backing_inode(path.dentry)->i_ino & (UNIX_HASH_SIZE-1); | |
| 1051 | + hash = d_backing_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1); | |
| 1042 | 1052 | spin_lock(&unix_table_lock); |
| 1043 | − u->path = path; | |
| 1053 | + u->path = u_path; | |
| 1044 | 1054 | list = &unix_socket_table[hash]; |
| 1045 | 1055 | } else { |
| 1046 | 1056 | spin_lock(&unix_table_lock); |
| @@ -1063,6 +1073,10 @@ out_unlock: · 16 unmodified lines | ||
| 1063 | 1073 | spin_unlock(&unix_table_lock); |
| 1064 | 1074 | out_up: |
| 1065 | 1075 | mutex_unlock(&u->readlock); |
| 1076 | +out_path: | |
| 1077 | + if (dentry) | |
| 1078 | + done_path_create(&path, dentry); | |
| 1079 | + | |
| 1066 | 1080 | out: |
| 1067 | 1081 | return err; |
| 1068 | 1082 | } |
| @@ -2256,14 +2270,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) · 1187 unmodified lines | ||
| 2256 | 2270 | /* Lock the socket to prevent queue disordering |
| 2257 | 2271 | * while sleeps in memcpy_tomsg |
| 2258 | 2272 | */ |
| 2259 | − err = mutex_lock_interruptible(&u->readlock); | |
| 2260 | − if (unlikely(err)) { | |
| 2261 | − /* recvmsg() in non blocking mode is supposed to return -EAGAIN | |
| 2262 | − * sk_rcvtimeo is not honored by mutex_lock_interruptible() | |
| 2263 | − */ | |
| 2264 | − err = noblock ? -EAGAIN : -ERESTARTSYS; | |
| 2265 | − goto out; | |
| 2266 | − } | |
| 2273 | + mutex_lock(&u->readlock); | |
| 2267 | 2274 | |
| 2268 | 2275 | if (flags & MSG_PEEK) |
| 2269 | 2276 | skip = sk_peek_offset(sk, flags); |
| @@ -2307,12 +2314,12 @@ again: · 37 unmodified lines | ||
| 2307 | 2314 | timeo = unix_stream_data_wait(sk, timeo, last, |
| 2308 | 2315 | last_len); |
| 2309 | 2316 | |
| 2310 | − if (signal_pending(current) || | |
| 2311 | − mutex_lock_interruptible(&u->readlock)) { | |
| 2317 | + if (signal_pending(current)) { | |
| 2312 | 2318 | err = sock_intr_errno(timeo); |
| 2313 | 2319 | goto out; |
| 2314 | 2320 | } |
| 2315 | 2321 | |
| 2322 | + mutex_lock(&u->readlock); | |
| 2316 | 2323 | continue; |
| 2317 | 2324 | unlock: |
| 2318 | 2325 | unix_state_unlock(sk); |
| @@ -7941,8 +7941,10 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) · 7940 unmodified lines | ||
| 7941 | 7941 | if (nla_get_flag(info->attrs[NL80211_ATTR_USE_RRM])) { |
| 7942 | 7942 | if (!(rdev->wiphy.features & |
| 7943 | 7943 | NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES) || |
| 7944 | − !(rdev->wiphy.features & NL80211_FEATURE_QUIET)) | |
| 7944 | + !(rdev->wiphy.features & NL80211_FEATURE_QUIET)) { | |
| 7945 | + kzfree(connkeys); | |
| 7945 | 7946 | return -EINVAL; |
| 7947 | + } | |
| 7946 | 7948 | connect.flags |= ASSOC_REQ_USE_RRM; |
| 7947 | 7949 | } |
| 7948 | 7950 | |
| @@ -9503,6 +9505,7 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) · 1554 unmodified lines | ||
| 9503 | 9505 | if (new_triggers.tcp && new_triggers.tcp->sock) |
| 9504 | 9506 | sock_release(new_triggers.tcp->sock); |
| 9505 | 9507 | kfree(new_triggers.tcp); |
| 9508 | + kfree(new_triggers.nd_config); | |
| 9506 | 9509 | return err; |
| 9507 | 9510 | } |
| 9508 | 9511 | #endif |
| @@ -3029,6 +3029,7 @@ int set_regdom(const struct ieee80211_regdomain *rd, · 3028 unmodified lines | ||
| 3029 | 3029 | break; |
| 3030 | 3030 | default: |
| 3031 | 3031 | WARN(1, "invalid initiator %d\n", lr->initiator); |
| 3032 | + kfree(rd); | |
| 3032 | 3033 | return -EINVAL; |
| 3033 | 3034 | } |
| 3034 | 3035 | |
| @@ -3221,8 +3222,10 @@ int __init regulatory_init(void) · 186 unmodified lines | ||
| 3221 | 3222 | /* We always try to get an update for the static regdomain */ |
| 3222 | 3223 | err = regulatory_hint_core(cfg80211_world_regdom->alpha2); |
| 3223 | 3224 | if (err) { |
| 3224 | − if (err == -ENOMEM) | |
| 3225 | + if (err == -ENOMEM) { | |
| 3226 | + platform_device_unregister(reg_pdev); | |
| 3225 | 3227 | return err; |
| 3228 | + } | |
| 3226 | 3229 | /* |
| 3227 | 3230 | * N.B. kobject_uevent_env() can fail mainly for when we're out |
| 3228 | 3231 | * memory which is handled and propagated appropriately above |
| @@ -303,6 +303,14 @@ struct xfrm_policy *xfrm_policy_alloc(struct net *net, gfp_t gfp) · 302 unmodified lines | ||
| 303 | 303 | } |
| 304 | 304 | EXPORT_SYMBOL(xfrm_policy_alloc); |
| 305 | 305 | |
| 306 | +static void xfrm_policy_destroy_rcu(struct rcu_head *head) | |
| 307 | +{ | |
| 308 | + struct xfrm_policy *policy = container_of(head, struct xfrm_policy, rcu); | |
| 309 | + | |
| 310 | + security_xfrm_policy_free(policy->security); | |
| 311 | + kfree(policy); | |
| 312 | +} | |
| 313 | + | |
| 306 | 314 | /* Destroy xfrm_policy: descendant resources must be released to this moment. */ |
| 307 | 315 | |
| 308 | 316 | void xfrm_policy_destroy(struct xfrm_policy *policy) |
| @@ -312,8 +320,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy) · 3 unmodified lines | ||
| 312 | 320 | if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer)) |
| 313 | 321 | BUG(); |
| 314 | 322 | |
| 315 | − security_xfrm_policy_free(policy->security); | |
| 316 | − kfree(policy); | |
| 323 | + call_rcu(&policy->rcu, xfrm_policy_destroy_rcu); | |
| 317 | 324 | } |
| 318 | 325 | EXPORT_SYMBOL(xfrm_policy_destroy); |
| 319 | 326 | |
| @@ -1214,8 +1221,10 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir, · 894 unmodified lines | ||
| 1214 | 1221 | struct xfrm_policy *pol; |
| 1215 | 1222 | struct net *net = sock_net(sk); |
| 1216 | 1223 | |
| 1224 | + rcu_read_lock(); | |
| 1217 | 1225 | read_lock_bh(&net->xfrm.xfrm_policy_lock); |
| 1218 | − if ((pol = sk->sk_policy[dir]) != NULL) { | |
| 1226 | + pol = rcu_dereference(sk->sk_policy[dir]); | |
| 1227 | + if (pol != NULL) { | |
| 1219 | 1228 | bool match = xfrm_selector_match(&pol->selector, fl, |
| 1220 | 1229 | sk->sk_family); |
| 1221 | 1230 | int err = 0; |
| @@ -1239,6 +1248,7 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir, · 17 unmodified lines | ||
| 1239 | 1248 | } |
| 1240 | 1249 | out: |
| 1241 | 1250 | read_unlock_bh(&net->xfrm.xfrm_policy_lock); |
| 1251 | + rcu_read_unlock(); | |
| 1242 | 1252 | return pol; |
| 1243 | 1253 | } |
| 1244 | 1254 | |
| @@ -1307,13 +1317,14 @@ int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol) · 62 unmodified lines | ||
| 1307 | 1317 | #endif |
| 1308 | 1318 | |
| 1309 | 1319 | write_lock_bh(&net->xfrm.xfrm_policy_lock); |
| 1310 | − old_pol = sk->sk_policy[dir]; | |
| 1311 | − sk->sk_policy[dir] = pol; | |
| 1320 | + old_pol = rcu_dereference_protected(sk->sk_policy[dir], | |
| 1321 | + lockdep_is_held(&net->xfrm.xfrm_policy_lock)); | |
| 1312 | 1322 | if (pol) { |
| 1313 | 1323 | pol->curlft.add_time = get_seconds(); |
| 1314 | 1324 | pol->index = xfrm_gen_index(net, XFRM_POLICY_MAX+dir, 0); |
| 1315 | 1325 | xfrm_sk_policy_link(pol, dir); |
| 1316 | 1326 | } |
| 1327 | + rcu_assign_pointer(sk->sk_policy[dir], pol); | |
| 1317 | 1328 | if (old_pol) { |
| 1318 | 1329 | if (pol) |
| 1319 | 1330 | xfrm_policy_requeue(old_pol, pol); |
| @@ -1361,17 +1372,26 @@ static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir) · 41 unmodified lines | ||
| 1361 | 1372 | return newp; |
| 1362 | 1373 | } |
| 1363 | 1374 | |
| 1364 | −int __xfrm_sk_clone_policy(struct sock *sk) | |
| 1375 | +int __xfrm_sk_clone_policy(struct sock *sk, const struct sock *osk) | |
| 1365 | 1376 | { |
| 1366 | − struct xfrm_policy *p0 = sk->sk_policy[0], | |
| 1367 | − *p1 = sk->sk_policy[1]; | |
| 1377 | + const struct xfrm_policy *p; | |
| 1378 | + struct xfrm_policy *np; | |
| 1379 | + int i, ret = 0; | |
| 1368 | 1380 | |
| 1369 | − sk->sk_policy[0] = sk->sk_policy[1] = NULL; | |
| 1370 | − if (p0 && (sk->sk_policy[0] = clone_policy(p0, 0)) == NULL) | |
| 1371 | − return -ENOMEM; | |
| 1372 | − if (p1 && (sk->sk_policy[1] = clone_policy(p1, 1)) == NULL) | |
| 1373 | − return -ENOMEM; | |
| 1374 | − return 0; | |
| 1381 | + rcu_read_lock(); | |
| 1382 | + for (i = 0; i < 2; i++) { | |
| 1383 | + p = rcu_dereference(osk->sk_policy[i]); | |
| 1384 | + if (p) { | |
| 1385 | + np = clone_policy(p, i); | |
| 1386 | + if (unlikely(!np)) { | |
| 1387 | + ret = -ENOMEM; | |
| 1388 | + break; | |
| 1389 | + } | |
| 1390 | + rcu_assign_pointer(sk->sk_policy[i], np); | |
| 1391 | + } | |
| 1392 | + } | |
| 1393 | + rcu_read_unlock(); | |
| 1394 | + return ret; | |
| 1375 | 1395 | } |
| 1376 | 1396 | |
| 1377 | 1397 | static int |
| @@ -2198,6 +2218,7 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, · 820 unmodified lines | ||
| 2198 | 2218 | xdst = NULL; |
| 2199 | 2219 | route = NULL; |
| 2200 | 2220 | |
| 2221 | + sk = sk_const_to_full_sk(sk); | |
| 2201 | 2222 | if (sk && sk->sk_policy[XFRM_POLICY_OUT]) { |
| 2202 | 2223 | num_pols = 1; |
| 2203 | 2224 | pols[0] = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl); |
| @@ -2477,6 +2498,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, · 273 unmodified lines | ||
| 2477 | 2498 | } |
| 2478 | 2499 | |
| 2479 | 2500 | pol = NULL; |
| 2501 | + sk = sk_to_full_sk(sk); | |
| 2480 | 2502 | if (sk && sk->sk_policy[dir]) { |
| 2481 | 2503 | pol = xfrm_sk_policy_lookup(sk, dir, &fl); |
| 2482 | 2504 | if (IS_ERR(pol)) { |
| @@ -2804,7 +2826,6 @@ static struct neighbour *xfrm_neigh_lookup(const struct dst_entry *dst, · 321 unmodified lines | ||
| 2804 | 2826 | |
| 2805 | 2827 | int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) |
| 2806 | 2828 | { |
| 2807 | − struct net *net; | |
| 2808 | 2829 | int err = 0; |
| 2809 | 2830 | if (unlikely(afinfo == NULL)) |
| 2810 | 2831 | return -EINVAL; |
| @@ -2835,26 +2856,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) · 24 unmodified lines | ||
| 2835 | 2856 | } |
| 2836 | 2857 | spin_unlock(&xfrm_policy_afinfo_lock); |
| 2837 | 2858 | |
| 2838 | − rtnl_lock(); | |
| 2839 | − for_each_net(net) { | |
| 2840 | − struct dst_ops *xfrm_dst_ops; | |
| 2841 | − | |
| 2842 | − switch (afinfo->family) { | |
| 2843 | − case AF_INET: | |
| 2844 | − xfrm_dst_ops = &net->xfrm.xfrm4_dst_ops; | |
| 2845 | − break; | |
| 2846 | −#if IS_ENABLED(CONFIG_IPV6) | |
| 2847 | − case AF_INET6: | |
| 2848 | − xfrm_dst_ops = &net->xfrm.xfrm6_dst_ops; | |
| 2849 | − break; | |
| 2850 | −#endif | |
| 2851 | − default: | |
| 2852 | − BUG(); | |
| 2853 | − } | |
| 2854 | − *xfrm_dst_ops = *afinfo->dst_ops; | |
| 2855 | − } | |
| 2856 | − rtnl_unlock(); | |
| 2857 | − | |
| 2858 | 2859 | return err; |
| 2859 | 2860 | } |
| 2860 | 2861 | EXPORT_SYMBOL(xfrm_policy_register_afinfo); |
| @@ -2890,22 +2891,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo) · 29 unmodified lines | ||
| 2890 | 2891 | } |
| 2891 | 2892 | EXPORT_SYMBOL(xfrm_policy_unregister_afinfo); |
| 2892 | 2893 | |
| 2893 | −static void __net_init xfrm_dst_ops_init(struct net *net) | |
| 2894 | −{ | |
| 2895 | − struct xfrm_policy_afinfo *afinfo; | |
| 2896 | − | |
| 2897 | − rcu_read_lock(); | |
| 2898 | − afinfo = rcu_dereference(xfrm_policy_afinfo[AF_INET]); | |
| 2899 | − if (afinfo) | |
| 2900 | − net->xfrm.xfrm4_dst_ops = *afinfo->dst_ops; | |
| 2901 | −#if IS_ENABLED(CONFIG_IPV6) | |
| 2902 | − afinfo = rcu_dereference(xfrm_policy_afinfo[AF_INET6]); | |
| 2903 | − if (afinfo) | |
| 2904 | − net->xfrm.xfrm6_dst_ops = *afinfo->dst_ops; | |
| 2905 | −#endif | |
| 2906 | − rcu_read_unlock(); | |
| 2907 | −} | |
| 2908 | − | |
| 2909 | 2894 | static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr) |
| 2910 | 2895 | { |
| 2911 | 2896 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
| @@ -3054,7 +3039,6 @@ static int __net_init xfrm_net_init(struct net *net) · 142 unmodified lines | ||
| 3054 | 3039 | rv = xfrm_policy_init(net); |
| 3055 | 3040 | if (rv < 0) |
| 3056 | 3041 | goto out_policy; |
| 3057 | − xfrm_dst_ops_init(net); | |
| 3058 | 3042 | rv = xfrm_sysctl_init(net); |
| 3059 | 3043 | if (rv < 0) |
| 3060 | 3044 | goto out_sysctl; |
| @@ -48,12 +48,17 @@ · 47 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | static int fd_map; /* File descriptor for file being modified. */ |
| 50 | 50 | static int mmap_failed; /* Boolean flag. */ |
| 51 | −static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */ | |
| 52 | 51 | static char gpfx; /* prefix for global symbol name (sometimes '_') */ |
| 53 | 52 | static struct stat sb; /* Remember .st_size, etc. */ |
| 54 | 53 | static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */ |
| 55 | 54 | static const char *altmcount; /* alternate mcount symbol name */ |
| 56 | 55 | static int warn_on_notrace_sect; /* warn when section has mcount not being recorded */ |
| 56 | +static void *file_map; /* pointer of the mapped file */ | |
| 57 | +static void *file_end; /* pointer to the end of the mapped file */ | |
| 58 | +static int file_updated; /* flag to state file was changed */ | |
| 59 | +static void *file_ptr; /* current file pointer location */ | |
| 60 | +static void *file_append; /* added to the end of the file */ | |
| 61 | +static size_t file_append_size; /* how much is added to end of file */ | |
| 57 | 62 | |
| 58 | 63 | /* setjmp() return values */ |
| 59 | 64 | enum { |
| @@ -67,10 +72,14 @@ static void · 7 unmodified lines | ||
| 67 | 72 | cleanup(void) |
| 68 | 73 | { |
| 69 | 74 | if (!mmap_failed) |
| 70 | − munmap(ehdr_curr, sb.st_size); | |
| 75 | + munmap(file_map, sb.st_size); | |
| 71 | 76 | else |
| 72 | − free(ehdr_curr); | |
| 73 | − close(fd_map); | |
| 77 | + free(file_map); | |
| 78 | + file_map = NULL; | |
| 79 | + free(file_append); | |
| 80 | + file_append = NULL; | |
| 81 | + file_append_size = 0; | |
| 82 | + file_updated = 0; | |
| 74 | 83 | } |
| 75 | 84 | |
| 76 | 85 | static void __attribute__((noreturn)) |
| @@ -92,12 +101,22 @@ succeed_file(void) · 15 unmodified lines | ||
| 92 | 101 | static off_t |
| 93 | 102 | ulseek(int const fd, off_t const offset, int const whence) |
| 94 | 103 | { |
| 95 | − off_t const w = lseek(fd, offset, whence); | |
| 96 | − if (w == (off_t)-1) { | |
| 97 | − perror("lseek"); | |
| 104 | + switch (whence) { | |
| 105 | + case SEEK_SET: | |
| 106 | + file_ptr = file_map + offset; | |
| 107 | + break; | |
| 108 | + case SEEK_CUR: | |
| 109 | + file_ptr += offset; | |
| 110 | + break; | |
| 111 | + case SEEK_END: | |
| 112 | + file_ptr = file_map + (sb.st_size - offset); | |
| 113 | + break; | |
| 114 | + } | |
| 115 | + if (file_ptr < file_map) { | |
| 116 | + fprintf(stderr, "lseek: seek before file\n"); | |
| 98 | 117 | fail_file(); |
| 99 | 118 | } |
| 100 | − return w; | |
| 119 | + return file_ptr - file_map; | |
| 101 | 120 | } |
| 102 | 121 | |
| 103 | 122 | static size_t |
| @@ -114,12 +133,38 @@ uread(int const fd, void *const buf, size_t const count) · 10 unmodified lines | ||
| 114 | 133 | static size_t |
| 115 | 134 | uwrite(int const fd, void const *const buf, size_t const count) |
| 116 | 135 | { |
| 117 | − size_t const n = write(fd, buf, count); | |
| 118 | − if (n != count) { | |
| 119 | − perror("write"); | |
| 120 | − fail_file(); | |
| 136 | + size_t cnt = count; | |
| 137 | + off_t idx = 0; | |
| 138 | + | |
| 139 | + file_updated = 1; | |
| 140 | + | |
| 141 | + if (file_ptr + count >= file_end) { | |
| 142 | + off_t aoffset = (file_ptr + count) - file_end; | |
| 143 | + | |
| 144 | + if (aoffset > file_append_size) { | |
| 145 | + file_append = realloc(file_append, aoffset); | |
| 146 | + file_append_size = aoffset; | |
| 147 | + } | |
| 148 | + if (!file_append) { | |
| 149 | + perror("write"); | |
| 150 | + fail_file(); | |
| 151 | + } | |
| 152 | + if (file_ptr < file_end) { | |
| 153 | + cnt = file_end - file_ptr; | |
| 154 | + } else { | |
| 155 | + cnt = 0; | |
| 156 | + idx = aoffset - count; | |
| 157 | + } | |
| 121 | 158 | } |
| 122 | − return n; | |
| 159 | + | |
| 160 | + if (cnt) | |
| 161 | + memcpy(file_ptr, buf, cnt); | |
| 162 | + | |
| 163 | + if (cnt < count) | |
| 164 | + memcpy(file_append + idx, buf + cnt, count - cnt); | |
| 165 | + | |
| 166 | + file_ptr += count; | |
| 167 | + return count; | |
| 123 | 168 | } |
| 124 | 169 | |
| 125 | 170 | static void * |
| @@ -192,9 +237,7 @@ static int make_nop_arm64(void *map, size_t const offset) · 66 unmodified lines | ||
| 192 | 237 | */ |
| 193 | 238 | static void *mmap_file(char const *fname) |
| 194 | 239 | { |
| 195 | − void *addr; | |
| 196 | − | |
| 197 | − fd_map = open(fname, O_RDWR); | |
| 240 | + fd_map = open(fname, O_RDONLY); | |
| 198 | 241 | if (fd_map < 0 || fstat(fd_map, &sb) < 0) { |
| 199 | 242 | perror(fname); |
| 200 | 243 | fail_file(); |
| @@ -203,15 +246,58 @@ static void *mmap_file(char const *fname) · 2 unmodified lines | ||
| 203 | 246 | fprintf(stderr, "not a regular file: %s\n", fname); |
| 204 | 247 | fail_file(); |
| 205 | 248 | } |
| 206 | − addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, | |
| 207 | − fd_map, 0); | |
| 249 | + file_map = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, | |
| 250 | + fd_map, 0); | |
| 208 | 251 | mmap_failed = 0; |
| 209 | − if (addr == MAP_FAILED) { | |
| 252 | + if (file_map == MAP_FAILED) { | |
| 210 | 253 | mmap_failed = 1; |
| 211 | − addr = umalloc(sb.st_size); | |
| 212 | − uread(fd_map, addr, sb.st_size); | |
| 254 | + file_map = umalloc(sb.st_size); | |
| 255 | + uread(fd_map, file_map, sb.st_size); | |
| 256 | + } | |
| 257 | + close(fd_map); | |
| 258 | + | |
| 259 | + file_end = file_map + sb.st_size; | |
| 260 | + | |
| 261 | + return file_map; | |
| 262 | +} | |
| 263 | + | |
| 264 | +static void write_file(const char *fname) | |
| 265 | +{ | |
| 266 | + char tmp_file[strlen(fname) + 4]; | |
| 267 | + size_t n; | |
| 268 | + | |
| 269 | + if (!file_updated) | |
| 270 | + return; | |
| 271 | + | |
| 272 | + sprintf(tmp_file, "%s.rc", fname); | |
| 273 | + | |
| 274 | + /* | |
| 275 | + * After reading the entire file into memory, delete it | |
| 276 | + * and write it back, to prevent weird side effects of modifying | |
| 277 | + * an object file in place. | |
| 278 | + */ | |
| 279 | + fd_map = open(tmp_file, O_WRONLY | O_TRUNC | O_CREAT, sb.st_mode); | |
| 280 | + if (fd_map < 0) { | |
| 281 | + perror(fname); | |
| 282 | + fail_file(); | |
| 283 | + } | |
| 284 | + n = write(fd_map, file_map, sb.st_size); | |
| 285 | + if (n != sb.st_size) { | |
| 286 | + perror("write"); | |
| 287 | + fail_file(); | |
| 288 | + } | |
| 289 | + if (file_append_size) { | |
| 290 | + n = write(fd_map, file_append, file_append_size); | |
| 291 | + if (n != file_append_size) { | |
| 292 | + perror("write"); | |
| 293 | + fail_file(); | |
| 294 | + } | |
| 295 | + } | |
| 296 | + close(fd_map); | |
| 297 | + if (rename(tmp_file, fname) < 0) { | |
| 298 | + perror(fname); | |
| 299 | + fail_file(); | |
| 213 | 300 | } |
| 214 | − return addr; | |
| 215 | 301 | } |
| 216 | 302 | |
| 217 | 303 | /* w8rev, w8nat, ...: Handle endianness. */ |
| @@ -318,7 +404,6 @@ do_file(char const *const fname) · 100 unmodified lines | ||
| 318 | 404 | Elf32_Ehdr *const ehdr = mmap_file(fname); |
| 319 | 405 | unsigned int reltype = 0; |
| 320 | 406 | |
| 321 | − ehdr_curr = ehdr; | |
| 322 | 407 | w = w4nat; |
| 323 | 408 | w2 = w2nat; |
| 324 | 409 | w8 = w8nat; |
| @@ -441,6 +526,7 @@ do_file(char const *const fname) · 116 unmodified lines | ||
| 441 | 526 | } |
| 442 | 527 | } /* end switch */ |
| 443 | 528 | |
| 529 | + write_file(fname); | |
| 444 | 530 | cleanup(); |
| 445 | 531 | } |
| 446 | 532 | |
| @@ -493,11 +579,14 @@ main(int argc, char *argv[]) · 46 unmodified lines | ||
| 493 | 579 | case SJ_SETJMP: /* normal sequence */ |
| 494 | 580 | /* Avoid problems if early cleanup() */ |
| 495 | 581 | fd_map = -1; |
| 496 | − ehdr_curr = NULL; | |
| 497 | 582 | mmap_failed = 1; |
| 583 | + file_map = NULL; | |
| 584 | + file_ptr = NULL; | |
| 585 | + file_updated = 0; | |
| 498 | 586 | do_file(file); |
| 499 | 587 | break; |
| 500 | 588 | case SJ_FAIL: /* error in do_file or below */ |
| 589 | + fprintf(stderr, "%s: failed\n", file); | |
| 501 | 590 | ++n_error; |
| 502 | 591 | break; |
| 503 | 592 | case SJ_SUCCEED: /* premature success */ |
| @@ -751,16 +751,16 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) · 750 unmodified lines | ||
| 751 | 751 | |
| 752 | 752 | /* the key is probably readable - now try to read it */ |
| 753 | 753 | can_read_key: |
| 754 | − ret = key_validate(key); | |
| 755 | − if (ret == 0) { | |
| 756 | − ret = -EOPNOTSUPP; | |
| 757 | − if (key->type->read) { | |
| 758 | − /* read the data with the semaphore held (since we | |
| 759 | − * might sleep) */ | |
| 760 | − down_read(&key->sem); | |
| 754 | + ret = -EOPNOTSUPP; | |
| 755 | + if (key->type->read) { | |
| 756 | + /* Read the data with the semaphore held (since we might sleep) | |
| 757 | + * to protect against the key being updated or revoked. | |
| 758 | + */ | |
| 759 | + down_read(&key->sem); | |
| 760 | + ret = key_validate(key); | |
| 761 | + if (ret == 0) | |
| 761 | 762 | ret = key->type->read(key, buffer, buflen); |
| 762 | − up_read(&key->sem); | |
| 763 | − } | |
| 763 | + up_read(&key->sem); | |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | error2: |
| @@ -954,6 +954,36 @@ static int azx_resume(struct device *dev) · 953 unmodified lines | ||
| 954 | 954 | } |
| 955 | 955 | #endif /* CONFIG_PM_SLEEP || SUPPORT_VGA_SWITCHEROO */ |
| 956 | 956 | |
| 957 | +#ifdef CONFIG_PM_SLEEP | |
| 958 | +/* put codec down to D3 at hibernation for Intel SKL+; | |
| 959 | + * otherwise BIOS may still access the codec and screw up the driver | |
| 960 | + */ | |
| 961 | +#define IS_SKL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa170) | |
| 962 | +#define IS_SKL_LP(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9d70) | |
| 963 | +#define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98) | |
| 964 | +#define IS_SKL_PLUS(pci) (IS_SKL(pci) || IS_SKL_LP(pci) || IS_BXT(pci)) | |
| 965 | + | |
| 966 | +static int azx_freeze_noirq(struct device *dev) | |
| 967 | +{ | |
| 968 | + struct pci_dev *pci = to_pci_dev(dev); | |
| 969 | + | |
| 970 | + if (IS_SKL_PLUS(pci)) | |
| 971 | + pci_set_power_state(pci, PCI_D3hot); | |
| 972 | + | |
| 973 | + return 0; | |
| 974 | +} | |
| 975 | + | |
| 976 | +static int azx_thaw_noirq(struct device *dev) | |
| 977 | +{ | |
| 978 | + struct pci_dev *pci = to_pci_dev(dev); | |
| 979 | + | |
| 980 | + if (IS_SKL_PLUS(pci)) | |
| 981 | + pci_set_power_state(pci, PCI_D0); | |
| 982 | + | |
| 983 | + return 0; | |
| 984 | +} | |
| 985 | +#endif /* CONFIG_PM_SLEEP */ | |
| 986 | + | |
| 957 | 987 | #ifdef CONFIG_PM |
| 958 | 988 | static int azx_runtime_suspend(struct device *dev) |
| 959 | 989 | { |
| @@ -1063,6 +1093,10 @@ static int azx_runtime_idle(struct device *dev) · 103 unmodified lines | ||
| 1063 | 1093 | |
| 1064 | 1094 | static const struct dev_pm_ops azx_pm = { |
| 1065 | 1095 | SET_SYSTEM_SLEEP_PM_OPS(azx_suspend, azx_resume) |
| 1096 | +#ifdef CONFIG_PM_SLEEP | |
| 1097 | + .freeze_noirq = azx_freeze_noirq, | |
| 1098 | + .thaw_noirq = azx_thaw_noirq, | |
| 1099 | +#endif | |
| 1066 | 1100 | SET_RUNTIME_PM_OPS(azx_runtime_suspend, azx_runtime_resume, azx_runtime_idle) |
| 1067 | 1101 | }; |
| 1068 | 1102 | |
| @@ -67,6 +67,10 @@ enum { · 66 unmodified lines | ||
| 67 | 67 | ALC_HEADSET_TYPE_OMTP, |
| 68 | 68 | }; |
| 69 | 69 | |
| 70 | +enum { | |
| 71 | + ALC_KEY_MICMUTE_INDEX, | |
| 72 | +}; | |
| 73 | + | |
| 70 | 74 | struct alc_customize_define { |
| 71 | 75 | unsigned int sku_cfg; |
| 72 | 76 | unsigned char port_connectivity; |
| @@ -111,6 +115,7 @@ struct alc_spec { · 38 unmodified lines | ||
| 111 | 115 | void (*power_hook)(struct hda_codec *codec); |
| 112 | 116 | #endif |
| 113 | 117 | void (*shutup)(struct hda_codec *codec); |
| 118 | + void (*reboot_notify)(struct hda_codec *codec); | |
| 114 | 119 | |
| 115 | 120 | int init_amp; |
| 116 | 121 | int codec_variant; /* flag for other variants */ |
| @@ -122,6 +127,7 @@ struct alc_spec { · 5 unmodified lines | ||
| 122 | 127 | unsigned int pll_coef_idx, pll_coef_bit; |
| 123 | 128 | unsigned int coef0; |
| 124 | 129 | struct input_dev *kb_dev; |
| 130 | + u8 alc_mute_keycode_map[1]; | |
| 125 | 131 | }; |
| 126 | 132 | |
| 127 | 133 | /* |
| @@ -773,6 +779,25 @@ static inline void alc_shutup(struct hda_codec *codec) · 645 unmodified lines | ||
| 773 | 779 | snd_hda_shutup_pins(codec); |
| 774 | 780 | } |
| 775 | 781 | |
| 782 | +static void alc_reboot_notify(struct hda_codec *codec) | |
| 783 | +{ | |
| 784 | + struct alc_spec *spec = codec->spec; | |
| 785 | + | |
| 786 | + if (spec && spec->reboot_notify) | |
| 787 | + spec->reboot_notify(codec); | |
| 788 | + else | |
| 789 | + alc_shutup(codec); | |
| 790 | +} | |
| 791 | + | |
| 792 | +/* power down codec to D3 at reboot/shutdown; set as reboot_notify ops */ | |
| 793 | +static void alc_d3_at_reboot(struct hda_codec *codec) | |
| 794 | +{ | |
| 795 | + snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3); | |
| 796 | + snd_hda_codec_write(codec, codec->core.afg, 0, | |
| 797 | + AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | |
| 798 | + msleep(10); | |
| 799 | +} | |
| 800 | + | |
| 776 | 801 | #define alc_free snd_hda_gen_free |
| 777 | 802 | |
| 778 | 803 | #ifdef CONFIG_PM |
| @@ -818,7 +843,7 @@ static const struct hda_codec_ops alc_patch_ops = { · 39 unmodified lines | ||
| 818 | 843 | .suspend = alc_suspend, |
| 819 | 844 | .check_power_status = snd_hda_gen_check_power_status, |
| 820 | 845 | #endif |
| 821 | − .reboot_notify = alc_shutup, | |
| 846 | + .reboot_notify = alc_reboot_notify, | |
| 822 | 847 | }; |
| 823 | 848 | |
| 824 | 849 | |
| @@ -1755,6 +1780,7 @@ enum { · 930 unmodified lines | ||
| 1755 | 1780 | ALC889_FIXUP_MBA11_VREF, |
| 1756 | 1781 | ALC889_FIXUP_MBA21_VREF, |
| 1757 | 1782 | ALC889_FIXUP_MP11_VREF, |
| 1783 | + ALC889_FIXUP_MP41_VREF, | |
| 1758 | 1784 | ALC882_FIXUP_INV_DMIC, |
| 1759 | 1785 | ALC882_FIXUP_NO_PRIMARY_HP, |
| 1760 | 1786 | ALC887_FIXUP_ASUS_BASS, |
| @@ -1843,7 +1869,7 @@ static void alc889_fixup_mbp_vref(struct hda_codec *codec, · 82 unmodified lines | ||
| 1843 | 1869 | const struct hda_fixup *fix, int action) |
| 1844 | 1870 | { |
| 1845 | 1871 | struct alc_spec *spec = codec->spec; |
| 1846 | − static hda_nid_t nids[2] = { 0x14, 0x15 }; | |
| 1872 | + static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 }; | |
| 1847 | 1873 | int i; |
| 1848 | 1874 | |
| 1849 | 1875 | if (action != HDA_FIXUP_ACT_INIT) |
| @@ -2133,6 +2159,12 @@ static const struct hda_fixup alc882_fixups[] = { · 283 unmodified lines | ||
| 2133 | 2159 | .chained = true, |
| 2134 | 2160 | .chain_id = ALC885_FIXUP_MACPRO_GPIO, |
| 2135 | 2161 | }, |
| 2162 | + [ALC889_FIXUP_MP41_VREF] = { | |
| 2163 | + .type = HDA_FIXUP_FUNC, | |
| 2164 | + .v.func = alc889_fixup_mbp_vref, | |
| 2165 | + .chained = true, | |
| 2166 | + .chain_id = ALC885_FIXUP_MACPRO_GPIO, | |
| 2167 | + }, | |
| 2136 | 2168 | [ALC882_FIXUP_INV_DMIC] = { |
| 2137 | 2169 | .type = HDA_FIXUP_FUNC, |
| 2138 | 2170 | .v.func = alc_fixup_inv_dmic, |
| @@ -2215,7 +2247,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { · 76 unmodified lines | ||
| 2215 | 2247 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 2216 | 2248 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 2217 | 2249 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
| 2218 | − SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), | |
| 2250 | + SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF), | |
| 2219 | 2251 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
| 2220 | 2252 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 2221 | 2253 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| @@ -3435,12 +3467,43 @@ static void gpio2_mic_hotkey_event(struct hda_codec *codec, · 1213 unmodified lines | ||
| 3435 | 3467 | |
| 3436 | 3468 | /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore |
| 3437 | 3469 | send both key on and key off event for every interrupt. */ |
| 3438 | − input_report_key(spec->kb_dev, KEY_MICMUTE, 1); | |
| 3470 | + input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1); | |
| 3439 | 3471 | input_sync(spec->kb_dev); |
| 3440 | − input_report_key(spec->kb_dev, KEY_MICMUTE, 0); | |
| 3472 | + input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0); | |
| 3441 | 3473 | input_sync(spec->kb_dev); |
| 3442 | 3474 | } |
| 3443 | 3475 | |
| 3476 | +static int alc_register_micmute_input_device(struct hda_codec *codec) | |
| 3477 | +{ | |
| 3478 | + struct alc_spec *spec = codec->spec; | |
| 3479 | + int i; | |
| 3480 | + | |
| 3481 | + spec->kb_dev = input_allocate_device(); | |
| 3482 | + if (!spec->kb_dev) { | |
| 3483 | + codec_err(codec, "Out of memory (input_allocate_device)\n"); | |
| 3484 | + return -ENOMEM; | |
| 3485 | + } | |
| 3486 | + | |
| 3487 | + spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE; | |
| 3488 | + | |
| 3489 | + spec->kb_dev->name = "Microphone Mute Button"; | |
| 3490 | + spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY); | |
| 3491 | + spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]); | |
| 3492 | + spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map); | |
| 3493 | + spec->kb_dev->keycode = spec->alc_mute_keycode_map; | |
| 3494 | + for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++) | |
| 3495 | + set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit); | |
| 3496 | + | |
| 3497 | + if (input_register_device(spec->kb_dev)) { | |
| 3498 | + codec_err(codec, "input_register_device failed\n"); | |
| 3499 | + input_free_device(spec->kb_dev); | |
| 3500 | + spec->kb_dev = NULL; | |
| 3501 | + return -ENOMEM; | |
| 3502 | + } | |
| 3503 | + | |
| 3504 | + return 0; | |
| 3505 | +} | |
| 3506 | + | |
| 3444 | 3507 | static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, |
| 3445 | 3508 | const struct hda_fixup *fix, int action) |
| 3446 | 3509 | { |
| @@ -3458,20 +3521,8 @@ static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, · 11 unmodified lines | ||
| 3458 | 3521 | struct alc_spec *spec = codec->spec; |
| 3459 | 3522 | |
| 3460 | 3523 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 3461 | − spec->kb_dev = input_allocate_device(); | |
| 3462 | − if (!spec->kb_dev) { | |
| 3463 | − codec_err(codec, "Out of memory (input_allocate_device)\n"); | |
| 3524 | + if (alc_register_micmute_input_device(codec) != 0) | |
| 3464 | 3525 | return; |
| 3465 | − } | |
| 3466 | − spec->kb_dev->name = "Microphone Mute Button"; | |
| 3467 | − spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY); | |
| 3468 | − spec->kb_dev->keybit[BIT_WORD(KEY_MICMUTE)] = BIT_MASK(KEY_MICMUTE); | |
| 3469 | − if (input_register_device(spec->kb_dev)) { | |
| 3470 | − codec_err(codec, "input_register_device failed\n"); | |
| 3471 | − input_free_device(spec->kb_dev); | |
| 3472 | − spec->kb_dev = NULL; | |
| 3473 | − return; | |
| 3474 | − } | |
| 3475 | 3526 | |
| 3476 | 3527 | snd_hda_add_verbs(codec, gpio_init); |
| 3477 | 3528 | snd_hda_codec_write_cache(codec, codec->core.afg, 0, |
| @@ -3501,6 +3552,47 @@ static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec, · 23 unmodified lines | ||
| 3501 | 3552 | } |
| 3502 | 3553 | } |
| 3503 | 3554 | |
| 3555 | +static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec, | |
| 3556 | + const struct hda_fixup *fix, int action) | |
| 3557 | +{ | |
| 3558 | + /* Line2 = mic mute hotkey | |
| 3559 | + GPIO2 = mic mute LED */ | |
| 3560 | + static const struct hda_verb gpio_init[] = { | |
| 3561 | + { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 }, | |
| 3562 | + { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 }, | |
| 3563 | + {} | |
| 3564 | + }; | |
| 3565 | + | |
| 3566 | + struct alc_spec *spec = codec->spec; | |
| 3567 | + | |
| 3568 | + if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
| 3569 | + if (alc_register_micmute_input_device(codec) != 0) | |
| 3570 | + return; | |
| 3571 | + | |
| 3572 | + snd_hda_add_verbs(codec, gpio_init); | |
| 3573 | + snd_hda_jack_detect_enable_callback(codec, 0x1b, | |
| 3574 | + gpio2_mic_hotkey_event); | |
| 3575 | + | |
| 3576 | + spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook; | |
| 3577 | + spec->gpio_led = 0; | |
| 3578 | + spec->mute_led_polarity = 0; | |
| 3579 | + spec->gpio_mic_led_mask = 0x04; | |
| 3580 | + return; | |
| 3581 | + } | |
| 3582 | + | |
| 3583 | + if (!spec->kb_dev) | |
| 3584 | + return; | |
| 3585 | + | |
| 3586 | + switch (action) { | |
| 3587 | + case HDA_FIXUP_ACT_PROBE: | |
| 3588 | + spec->init_amp = ALC_INIT_DEFAULT; | |
| 3589 | + break; | |
| 3590 | + case HDA_FIXUP_ACT_FREE: | |
| 3591 | + input_unregister_device(spec->kb_dev); | |
| 3592 | + spec->kb_dev = NULL; | |
| 3593 | + } | |
| 3594 | +} | |
| 3595 | + | |
| 3504 | 3596 | static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, |
| 3505 | 3597 | const struct hda_fixup *fix, int action) |
| 3506 | 3598 | { |
| @@ -4198,24 +4290,14 @@ static void alc_fixup_tpt440_dock(struct hda_codec *codec, · 691 unmodified lines | ||
| 4198 | 4290 | struct alc_spec *spec = codec->spec; |
| 4199 | 4291 | |
| 4200 | 4292 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 4293 | + spec->shutup = alc_no_shutup; /* reduce click noise */ | |
| 4294 | + spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */ | |
| 4201 | 4295 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 4202 | 4296 | codec->power_save_node = 0; /* avoid click noises */ |
| 4203 | 4297 | snd_hda_apply_pincfgs(codec, pincfgs); |
| 4204 | 4298 | } |
| 4205 | 4299 | } |
| 4206 | 4300 | |
| 4207 | −/* additional fixup for Thinkpad T440s noise problem */ | |
| 4208 | −static void alc_fixup_tpt440(struct hda_codec *codec, | |
| 4209 | − const struct hda_fixup *fix, int action) | |
| 4210 | −{ | |
| 4211 | − struct alc_spec *spec = codec->spec; | |
| 4212 | − | |
| 4213 | − if (action == HDA_FIXUP_ACT_PRE_PROBE) { | |
| 4214 | − spec->shutup = alc_no_shutup; /* reduce click noise */ | |
| 4215 | − spec->gen.mixer_nid = 0; /* reduce background noise */ | |
| 4216 | − } | |
| 4217 | −} | |
| 4218 | − | |
| 4219 | 4301 | static void alc_shutup_dell_xps13(struct hda_codec *codec) |
| 4220 | 4302 | { |
| 4221 | 4303 | struct alc_spec *spec = codec->spec; |
| @@ -4606,10 +4688,12 @@ enum { · 384 unmodified lines | ||
| 4606 | 4688 | ALC288_FIXUP_DISABLE_AAMIX, |
| 4607 | 4689 | ALC292_FIXUP_DELL_E7X, |
| 4608 | 4690 | ALC292_FIXUP_DISABLE_AAMIX, |
| 4691 | + ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, | |
| 4609 | 4692 | ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, |
| 4610 | 4693 | ALC275_FIXUP_DELL_XPS, |
| 4611 | 4694 | ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE, |
| 4612 | 4695 | ALC293_FIXUP_LENOVO_SPK_NOISE, |
| 4696 | + ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, | |
| 4613 | 4697 | }; |
| 4614 | 4698 | |
| 4615 | 4699 | static const struct hda_fixup alc269_fixups[] = { |
| @@ -5066,7 +5150,7 @@ static const struct hda_fixup alc269_fixups[] = { · 450 unmodified lines | ||
| 5066 | 5150 | }, |
| 5067 | 5151 | [ALC292_FIXUP_TPT440] = { |
| 5068 | 5152 | .type = HDA_FIXUP_FUNC, |
| 5069 | − .v.func = alc_fixup_tpt440, | |
| 5153 | + .v.func = alc_fixup_disable_aamix, | |
| 5070 | 5154 | .chained = true, |
| 5071 | 5155 | .chain_id = ALC292_FIXUP_TPT440_DOCK, |
| 5072 | 5156 | }, |
| @@ -5169,6 +5253,12 @@ static const struct hda_fixup alc269_fixups[] = { · 96 unmodified lines | ||
| 5169 | 5253 | .chained = true, |
| 5170 | 5254 | .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE |
| 5171 | 5255 | }, |
| 5256 | + [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = { | |
| 5257 | + .type = HDA_FIXUP_FUNC, | |
| 5258 | + .v.func = alc_fixup_disable_aamix, | |
| 5259 | + .chained = true, | |
| 5260 | + .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE | |
| 5261 | + }, | |
| 5172 | 5262 | [ALC292_FIXUP_DELL_E7X] = { |
| 5173 | 5263 | .type = HDA_FIXUP_FUNC, |
| 5174 | 5264 | .v.func = alc_fixup_dell_xps13, |
| @@ -5213,6 +5303,10 @@ static const struct hda_fixup alc269_fixups[] = { · 38 unmodified lines | ||
| 5213 | 5303 | .chained = true, |
| 5214 | 5304 | .chain_id = ALC269_FIXUP_THINKPAD_ACPI |
| 5215 | 5305 | }, |
| 5306 | + [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = { | |
| 5307 | + .type = HDA_FIXUP_FUNC, | |
| 5308 | + .v.func = alc233_fixup_lenovo_line2_mic_hotkey, | |
| 5309 | + }, | |
| 5216 | 5310 | }; |
| 5217 | 5311 | |
| 5218 | 5312 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
| @@ -5247,11 +5341,11 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 28 unmodified lines | ||
| 5247 | 5341 | SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5248 | 5342 | SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5249 | 5343 | SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5250 | − SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC292_FIXUP_DISABLE_AAMIX), | |
| 5251 | − SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC292_FIXUP_DISABLE_AAMIX), | |
| 5252 | − SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC292_FIXUP_DISABLE_AAMIX), | |
| 5253 | − SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC292_FIXUP_DISABLE_AAMIX), | |
| 5254 | − SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC292_FIXUP_DISABLE_AAMIX), | |
| 5344 | + SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), | |
| 5345 | + SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), | |
| 5346 | + SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), | |
| 5347 | + SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), | |
| 5348 | + SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK), | |
| 5255 | 5349 | SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), |
| 5256 | 5350 | SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5257 | 5351 | SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| @@ -5358,9 +5452,11 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 100 unmodified lines | ||
| 5358 | 5452 | SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK), |
| 5359 | 5453 | SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK), |
| 5360 | 5454 | SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
| 5455 | + SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK), | |
| 5361 | 5456 | SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK), |
| 5362 | 5457 | SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK), |
| 5363 | 5458 | SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE), |
| 5459 | + SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), | |
| 5364 | 5460 | SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), |
| 5365 | 5461 | SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP), |
| 5366 | 5462 | SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), |
| @@ -1537,7 +1537,7 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, · 1536 unmodified lines | ||
| 1537 | 1537 | bool reconfig; |
| 1538 | 1538 | unsigned int aif_tx_state, aif_rx_state; |
| 1539 | 1539 | |
| 1540 | − if (params_rate(params) % 8000) | |
| 1540 | + if (params_rate(params) % 4000) | |
| 1541 | 1541 | rates = &arizona_44k1_bclk_rates[0]; |
| 1542 | 1542 | else |
| 1543 | 1543 | rates = &arizona_48k_bclk_rates[0]; |
| @@ -85,7 +85,15 @@ static const DECLARE_TLV_DB_SCALE(pga_tlv, 0, 300, 0); · 84 unmodified lines | ||
| 85 | 85 | static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0); |
| 86 | 86 | static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 300, 0); |
| 87 | 87 | |
| 88 | −static const int deemph_settings[] = { 0, 32000, 44100, 48000 }; | |
| 88 | +static const struct { | |
| 89 | + int rate; | |
| 90 | + unsigned int val; | |
| 91 | +} deemph_settings[] = { | |
| 92 | + { 0, ES8328_DACCONTROL6_DEEMPH_OFF }, | |
| 93 | + { 32000, ES8328_DACCONTROL6_DEEMPH_32k }, | |
| 94 | + { 44100, ES8328_DACCONTROL6_DEEMPH_44_1k }, | |
| 95 | + { 48000, ES8328_DACCONTROL6_DEEMPH_48k }, | |
| 96 | +}; | |
| 89 | 97 | |
| 90 | 98 | static int es8328_set_deemph(struct snd_soc_codec *codec) |
| 91 | 99 | { |
| @@ -97,21 +105,22 @@ static int es8328_set_deemph(struct snd_soc_codec *codec) · 5 unmodified lines | ||
| 97 | 105 | * rate. |
| 98 | 106 | */ |
| 99 | 107 | if (es8328->deemph) { |
| 100 | − best = 1; | |
| 101 | − for (i = 2; i < ARRAY_SIZE(deemph_settings); i++) { | |
| 102 | − if (abs(deemph_settings[i] - es8328->playback_fs) < | |
| 103 | − abs(deemph_settings[best] - es8328->playback_fs)) | |
| 108 | + best = 0; | |
| 109 | + for (i = 1; i < ARRAY_SIZE(deemph_settings); i++) { | |
| 110 | + if (abs(deemph_settings[i].rate - es8328->playback_fs) < | |
| 111 | + abs(deemph_settings[best].rate - es8328->playback_fs)) | |
| 104 | 112 | best = i; |
| 105 | 113 | } |
| 106 | 114 | |
| 107 | − val = best << 1; | |
| 115 | + val = deemph_settings[best].val; | |
| 108 | 116 | } else { |
| 109 | − val = 0; | |
| 117 | + val = ES8328_DACCONTROL6_DEEMPH_OFF; | |
| 110 | 118 | } |
| 111 | 119 | |
| 112 | 120 | dev_dbg(codec->dev, "Set deemphasis %d\n", val); |
| 113 | 121 | |
| 114 | − return snd_soc_update_bits(codec, ES8328_DACCONTROL6, 0x6, val); | |
| 122 | + return snd_soc_update_bits(codec, ES8328_DACCONTROL6, | |
| 123 | + ES8328_DACCONTROL6_DEEMPH_MASK, val); | |
| 115 | 124 | } |
| 116 | 125 | |
| 117 | 126 | static int es8328_get_deemph(struct snd_kcontrol *kcontrol, |
| @@ -153,6 +153,7 @@ int es8328_probe(struct device *dev, struct regmap *regmap); · 152 unmodified lines | ||
| 153 | 153 | #define ES8328_DACCONTROL6_CLICKFREE (1 << 3) |
| 154 | 154 | #define ES8328_DACCONTROL6_DAC_INVR (1 << 4) |
| 155 | 155 | #define ES8328_DACCONTROL6_DAC_INVL (1 << 5) |
| 156 | +#define ES8328_DACCONTROL6_DEEMPH_MASK (3 << 6) | |
| 156 | 157 | #define ES8328_DACCONTROL6_DEEMPH_OFF (0 << 6) |
| 157 | 158 | #define ES8328_DACCONTROL6_DEEMPH_32k (1 << 6) |
| 158 | 159 | #define ES8328_DACCONTROL6_DEEMPH_44_1k (2 << 6) |
| @@ -1667,9 +1667,13 @@ static int rt5645_spk_event(struct snd_soc_dapm_widget *w, · 1666 unmodified lines | ||
| 1667 | 1667 | RT5645_PWR_CLS_D_L, |
| 1668 | 1668 | RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | |
| 1669 | 1669 | RT5645_PWR_CLS_D_L); |
| 1670 | + snd_soc_update_bits(codec, RT5645_GEN_CTRL3, | |
| 1671 | + RT5645_DET_CLK_MASK, RT5645_DET_CLK_MODE1); | |
| 1670 | 1672 | break; |
| 1671 | 1673 | |
| 1672 | 1674 | case SND_SOC_DAPM_PRE_PMD: |
| 1675 | + snd_soc_update_bits(codec, RT5645_GEN_CTRL3, | |
| 1676 | + RT5645_DET_CLK_MASK, RT5645_DET_CLK_DIS); | |
| 1673 | 1677 | snd_soc_write(codec, RT5645_EQ_CTRL2, 0); |
| 1674 | 1678 | snd_soc_update_bits(codec, RT5645_PWR_DIG1, |
| 1675 | 1679 | RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | |
| @@ -2122,6 +2122,10 @@ enum { · 2121 unmodified lines | ||
| 2122 | 2122 | /* General Control3 (0xfc) */ |
| 2123 | 2123 | #define RT5645_JD_PSV_MODE (0x1 << 12) |
| 2124 | 2124 | #define RT5645_IRQ_CLK_GATE_CTRL (0x1 << 11) |
| 2125 | +#define RT5645_DET_CLK_MASK (0x3 << 9) | |
| 2126 | +#define RT5645_DET_CLK_DIS (0x0 << 9) | |
| 2127 | +#define RT5645_DET_CLK_MODE1 (0x1 << 9) | |
| 2128 | +#define RT5645_DET_CLK_MODE2 (0x2 << 9) | |
| 2125 | 2129 | #define RT5645_MICINDET_MANU (0x1 << 7) |
| 2126 | 2130 | #define RT5645_RING2_SLEEVE_GND (0x1 << 5) |
| 2127 | 2131 | |
| @@ -189,6 +189,7 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, · 188 unmodified lines | ||
| 189 | 189 | case SND_SOC_DAPM_POST_PMU: |
| 190 | 190 | snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, |
| 191 | 191 | SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); |
| 192 | + msleep(400); | |
| 192 | 193 | break; |
| 193 | 194 | |
| 194 | 195 | case SND_SOC_DAPM_PRE_PMD: |
| @@ -574,6 +574,7 @@ static const struct regmap_config wm8974_regmap = { · 573 unmodified lines | ||
| 574 | 574 | .max_register = WM8974_MONOMIX, |
| 575 | 575 | .reg_defaults = wm8974_reg_defaults, |
| 576 | 576 | .num_reg_defaults = ARRAY_SIZE(wm8974_reg_defaults), |
| 577 | + .cache_type = REGCACHE_FLAT, | |
| 577 | 578 | }; |
| 578 | 579 | |
| 579 | 580 | static int wm8974_probe(struct snd_soc_codec *codec) |
| @@ -223,8 +223,8 @@ static void mcasp_start_tx(struct davinci_mcasp *mcasp) · 222 unmodified lines | ||
| 223 | 223 | |
| 224 | 224 | /* wait for XDATA to be cleared */ |
| 225 | 225 | cnt = 0; |
| 226 | − while (!(mcasp_get_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG) & | |
| 227 | − ~XRDATA) && (cnt < 100000)) | |
| 226 | + while ((mcasp_get_reg(mcasp, DAVINCI_MCASP_TXSTAT_REG) & XRDATA) && | |
| 227 | + (cnt < 100000)) | |
| 228 | 228 | cnt++; |
| 229 | 229 | |
| 230 | 230 | /* Release TX state machine */ |
| @@ -505,6 +505,24 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, · 504 unmodified lines | ||
| 505 | 505 | FSL_SAI_CSR_FR, FSL_SAI_CSR_FR); |
| 506 | 506 | regmap_update_bits(sai->regmap, FSL_SAI_RCSR, |
| 507 | 507 | FSL_SAI_CSR_FR, FSL_SAI_CSR_FR); |
| 508 | + | |
| 509 | + /* | |
| 510 | + * For sai master mode, after several open/close sai, | |
| 511 | + * there will be no frame clock, and can't recover | |
| 512 | + * anymore. Add software reset to fix this issue. | |
| 513 | + * This is a hardware bug, and will be fix in the | |
| 514 | + * next sai version. | |
| 515 | + */ | |
| 516 | + if (!sai->is_slave_mode) { | |
| 517 | + /* Software Reset for both Tx and Rx */ | |
| 518 | + regmap_write(sai->regmap, | |
| 519 | + FSL_SAI_TCSR, FSL_SAI_CSR_SR); | |
| 520 | + regmap_write(sai->regmap, | |
| 521 | + FSL_SAI_RCSR, FSL_SAI_CSR_SR); | |
| 522 | + /* Clear SR bit to finish the reset */ | |
| 523 | + regmap_write(sai->regmap, FSL_SAI_TCSR, 0); | |
| 524 | + regmap_write(sai->regmap, FSL_SAI_RCSR, 0); | |
| 525 | + } | |
| 508 | 526 | } |
| 509 | 527 | break; |
| 510 | 528 | default: |
| @@ -1240,7 +1240,6 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) · 1239 unmodified lines | ||
| 1240 | 1240 | */ |
| 1241 | 1241 | ret = snd_soc_tplg_component_load(&platform->component, |
| 1242 | 1242 | &skl_tplg_ops, fw, 0); |
| 1243 | − release_firmware(fw); | |
| 1244 | 1243 | if (ret < 0) { |
| 1245 | 1244 | dev_err(bus->dev, "tplg component load failed%d\n", ret); |
| 1246 | 1245 | return -EINVAL; |
| @@ -1249,5 +1248,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) · 2 unmodified lines | ||
| 1249 | 1248 | skl->resource.max_mcps = SKL_MAX_MCPS; |
| 1250 | 1249 | skl->resource.max_mem = SKL_FW_MAX_MEM; |
| 1251 | 1250 | |
| 1251 | + skl->tplg = fw; | |
| 1252 | + | |
| 1252 | 1253 | return 0; |
| 1253 | 1254 | } |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <linux/pci.h> |
| 26 | 26 | #include <linux/pm_runtime.h> |
| 27 | 27 | #include <linux/platform_device.h> |
| 28 | +#include <linux/firmware.h> | |
| 28 | 29 | #include <sound/pcm.h> |
| 29 | 30 | #include "skl.h" |
| 30 | 31 | |
| @@ -520,6 +521,9 @@ static void skl_remove(struct pci_dev *pci) · 489 unmodified lines | ||
| 520 | 521 | struct hdac_ext_bus *ebus = pci_get_drvdata(pci); |
| 521 | 522 | struct skl *skl = ebus_to_skl(ebus); |
| 522 | 523 | |
| 524 | + if (skl->tplg) | |
| 525 | + release_firmware(skl->tplg); | |
| 526 | + | |
| 523 | 527 | if (pci_dev_run_wake(pci)) |
| 524 | 528 | pm_runtime_get_noresume(&pci->dev); |
| 525 | 529 | pci_dev_put(pci); |
| @@ -68,6 +68,8 @@ struct skl { · 67 unmodified lines | ||
| 68 | 68 | struct skl_dsp_resource resource; |
| 69 | 69 | struct list_head ppl_list; |
| 70 | 70 | struct list_head dapm_path_list; |
| 71 | + | |
| 72 | + const struct firmware *tplg; | |
| 71 | 73 | }; |
| 72 | 74 | |
| 73 | 75 | #define skl_to_ebus(s) (&(s)->ebus) |
| @@ -152,8 +152,10 @@ static int rk_spdif_trigger(struct snd_pcm_substream *substream, · 151 unmodified lines | ||
| 152 | 152 | case SNDRV_PCM_TRIGGER_RESUME: |
| 153 | 153 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 154 | 154 | ret = regmap_update_bits(spdif->regmap, SPDIF_DMACR, |
| 155 | − SPDIF_DMACR_TDE_ENABLE, | |
| 156 | − SPDIF_DMACR_TDE_ENABLE); | |
| 155 | + SPDIF_DMACR_TDE_ENABLE | | |
| 156 | + SPDIF_DMACR_TDL_MASK, | |
| 157 | + SPDIF_DMACR_TDE_ENABLE | | |
| 158 | + SPDIF_DMACR_TDL(16)); | |
| 157 | 159 | |
| 158 | 160 | if (ret != 0) |
| 159 | 161 | return ret; |
| @@ -42,7 +42,7 @@ · 41 unmodified lines | ||
| 42 | 42 | |
| 43 | 43 | #define SPDIF_DMACR_TDL_SHIFT 0 |
| 44 | 44 | #define SPDIF_DMACR_TDL(x) ((x) << SPDIF_DMACR_TDL_SHIFT) |
| 45 | −#define SPDIF_DMACR_TDL_MASK (0x1f << SDPIF_DMACR_TDL_SHIFT) | |
| 45 | +#define SPDIF_DMACR_TDL_MASK (0x1f << SPDIF_DMACR_TDL_SHIFT) | |
| 46 | 46 | |
| 47 | 47 | /* |
| 48 | 48 | * XFER |
| @@ -1354,6 +1354,8 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, · 1353 unmodified lines | ||
| 1354 | 1354 | } |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | + snd_usb_mixer_fu_apply_quirk(state->mixer, cval, unitid, kctl); | |
| 1358 | + | |
| 1357 | 1359 | range = (cval->max - cval->min) / cval->res; |
| 1358 | 1360 | /* |
| 1359 | 1361 | * Are there devices with volume range more than 255? I use a bit more |
| @@ -348,13 +348,6 @@ static struct usbmix_name_map bose_companion5_map[] = { · 347 unmodified lines | ||
| 348 | 348 | { 0 } /* terminator */ |
| 349 | 349 | }; |
| 350 | 350 | |
| 351 | −/* Dragonfly DAC 1.2, the dB conversion factor is 1 instead of 256 */ | |
| 352 | −static struct usbmix_dB_map dragonfly_1_2_dB = {0, 5000}; | |
| 353 | −static struct usbmix_name_map dragonfly_1_2_map[] = { | |
| 354 | − { 7, NULL, .dB = &dragonfly_1_2_dB }, | |
| 355 | − { 0 } /* terminator */ | |
| 356 | −}; | |
| 357 | − | |
| 358 | 351 | /* |
| 359 | 352 | * Control map entries |
| 360 | 353 | */ |
| @@ -470,11 +463,6 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { · 109 unmodified lines | ||
| 470 | 463 | .id = USB_ID(0x05a7, 0x1020), |
| 471 | 464 | .map = bose_companion5_map, |
| 472 | 465 | }, |
| 473 | − { | |
| 474 | − /* Dragonfly DAC 1.2 */ | |
| 475 | − .id = USB_ID(0x21b4, 0x0081), | |
| 476 | − .map = dragonfly_1_2_map, | |
| 477 | − }, | |
| 478 | 466 | { 0 } /* terminator */ |
| 479 | 467 | }; |
| 480 | 468 | |
| @@ -37,6 +37,7 @@ · 36 unmodified lines | ||
| 37 | 37 | #include <sound/control.h> |
| 38 | 38 | #include <sound/hwdep.h> |
| 39 | 39 | #include <sound/info.h> |
| 40 | +#include <sound/tlv.h> | |
| 40 | 41 | |
| 41 | 42 | #include "usbaudio.h" |
| 42 | 43 | #include "mixer.h" |
| @@ -1825,3 +1826,39 @@ void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer, · 1782 unmodified lines | ||
| 1825 | 1826 | } |
| 1826 | 1827 | } |
| 1827 | 1828 | |
| 1829 | +static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer, | |
| 1830 | + struct snd_kcontrol *kctl) | |
| 1831 | +{ | |
| 1832 | + /* Approximation using 10 ranges based on output measurement on hw v1.2. | |
| 1833 | + * This seems close to the cubic mapping e.g. alsamixer uses. */ | |
| 1834 | + static const DECLARE_TLV_DB_RANGE(scale, | |
| 1835 | + 0, 1, TLV_DB_MINMAX_ITEM(-5300, -4970), | |
| 1836 | + 2, 5, TLV_DB_MINMAX_ITEM(-4710, -4160), | |
| 1837 | + 6, 7, TLV_DB_MINMAX_ITEM(-3884, -3710), | |
| 1838 | + 8, 14, TLV_DB_MINMAX_ITEM(-3443, -2560), | |
| 1839 | + 15, 16, TLV_DB_MINMAX_ITEM(-2475, -2324), | |
| 1840 | + 17, 19, TLV_DB_MINMAX_ITEM(-2228, -2031), | |
| 1841 | + 20, 26, TLV_DB_MINMAX_ITEM(-1910, -1393), | |
| 1842 | + 27, 31, TLV_DB_MINMAX_ITEM(-1322, -1032), | |
| 1843 | + 32, 40, TLV_DB_MINMAX_ITEM(-968, -490), | |
| 1844 | + 41, 50, TLV_DB_MINMAX_ITEM(-441, 0), | |
| 1845 | + ); | |
| 1846 | + | |
| 1847 | + usb_audio_info(mixer->chip, "applying DragonFly dB scale quirk\n"); | |
| 1848 | + kctl->tlv.p = scale; | |
| 1849 | + kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; | |
| 1850 | + kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; | |
| 1851 | +} | |
| 1852 | + | |
| 1853 | +void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, | |
| 1854 | + struct usb_mixer_elem_info *cval, int unitid, | |
| 1855 | + struct snd_kcontrol *kctl) | |
| 1856 | +{ | |
| 1857 | + switch (mixer->chip->usb_id) { | |
| 1858 | + case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ | |
| 1859 | + if (unitid == 7 && cval->min == 0 && cval->max == 50) | |
| 1860 | + snd_dragonfly_quirk_db_scale(mixer, kctl); | |
| 1861 | + break; | |
| 1862 | + } | |
| 1863 | +} | |
| 1864 | + | |
| @@ -9,5 +9,9 @@ void snd_emuusb_set_samplerate(struct snd_usb_audio *chip, · 8 unmodified lines | ||
| 9 | 9 | void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer, |
| 10 | 10 | int unitid); |
| 11 | 11 | |
| 12 | +void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer, | |
| 13 | + struct usb_mixer_elem_info *cval, int unitid, | |
| 14 | + struct snd_kcontrol *kctl); | |
| 15 | + | |
| 12 | 16 | #endif /* SND_USB_MIXER_QUIRKS_H */ |
| 13 | 17 | |
| @@ -1125,6 +1125,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) · 1124 unmodified lines | ||
| 1125 | 1125 | case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */ |
| 1126 | 1126 | case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ |
| 1127 | 1127 | case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ |
| 1128 | + case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ | |
| 1128 | 1129 | return true; |
| 1129 | 1130 | } |
| 1130 | 1131 | return false; |
| @@ -110,7 +110,7 @@ int cmd_buildid_list(int argc, const char **argv, · 109 unmodified lines | ||
| 110 | 110 | setup_pager(); |
| 111 | 111 | |
| 112 | 112 | if (show_kernel) |
| 113 | − return sysfs__fprintf_build_id(stdout); | |
| 113 | + return !(sysfs__fprintf_build_id(stdout) > 0); | |
| 114 | 114 | |
| 115 | 115 | return perf_session__list_build_ids(force, with_hits); |
| 116 | 116 | } |
| @@ -298,6 +298,9 @@ static bool hist_browser__toggle_fold(struct hist_browser *browser) · 297 unmodified lines | ||
| 298 | 298 | struct callchain_list *cl = container_of(ms, struct callchain_list, ms); |
| 299 | 299 | bool has_children; |
| 300 | 300 | |
| 301 | + if (!he || !ms) | |
| 302 | + return false; | |
| 303 | + | |
| 301 | 304 | if (ms == &he->ms) |
| 302 | 305 | has_children = hist_entry__toggle_fold(he); |
| 303 | 306 | else |
| @@ -928,6 +931,8 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) · 624 unmodified lines | ||
| 928 | 931 | } |
| 929 | 932 | |
| 930 | 933 | ui_browser__hists_init_top(browser); |
| 934 | + hb->he_selection = NULL; | |
| 935 | + hb->selection = NULL; | |
| 931 | 936 | |
| 932 | 937 | for (nd = browser->top; nd; nd = rb_next(nd)) { |
| 933 | 938 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
| @@ -1033,6 +1038,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser, · 99 unmodified lines | ||
| 1033 | 1038 | * and stop when we printed enough lines to fill the screen. |
| 1034 | 1039 | */ |
| 1035 | 1040 | do_offset: |
| 1041 | + if (!nd) | |
| 1042 | + return; | |
| 1043 | + | |
| 1036 | 1044 | if (offset > 0) { |
| 1037 | 1045 | do { |
| 1038 | 1046 | h = rb_entry(nd, struct hist_entry, rb_node); |
| @@ -91,7 +91,7 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf) · 90 unmodified lines | ||
| 91 | 91 | bid += 2; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | − return raw - build_id; | |
| 94 | + return (bid - bf) + 1; | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id) |
| @@ -124,6 +124,10 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = { · 123 unmodified lines | ||
| 124 | 124 | .symbol = "dummy", |
| 125 | 125 | .alias = "", |
| 126 | 126 | }, |
| 127 | + [PERF_COUNT_SW_BPF_OUTPUT] = { | |
| 128 | + .symbol = "bpf-output", | |
| 129 | + .alias = "", | |
| 130 | + }, | |
| 127 | 131 | }; |
| 128 | 132 | |
| 129 | 133 | #define __PERF_EVENT_FIELD(config, name) \ |
| @@ -1879,7 +1883,7 @@ restart: · 1749 unmodified lines | ||
| 1879 | 1883 | |
| 1880 | 1884 | for (i = 0; i < max; i++, syms++) { |
| 1881 | 1885 | |
| 1882 | − if (event_glob != NULL && | |
| 1886 | + if (event_glob != NULL && syms->symbol != NULL && | |
| 1883 | 1887 | !(strglobmatch(syms->symbol, event_glob) || |
| 1884 | 1888 | (syms->alias && strglobmatch(syms->alias, event_glob)))) |
| 1885 | 1889 | continue; |
| @@ -1114,7 +1114,7 @@ bool kvm_vgic_map_is_active(struct kvm_vcpu *vcpu, struct irq_phys_map *map) · 1113 unmodified lines | ||
| 1114 | 1114 | return true; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | − return dist_active_irq(vcpu); | |
| 1117 | + return vgic_irq_is_active(vcpu, map->virt_irq); | |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | /* |