Conflicts: drivers/net/ethernet/cavium/Kconfig The cavium conflict was overlapping dependency changes.
Unified · Split
| @@ -35,7 +35,7 @@ Example: · 34 unmodified lines | ||
| 35 | 35 | device_type = "dma"; |
| 36 | 36 | reg = <0x0 0x1f270000 0x0 0x10000>, |
| 37 | 37 | <0x0 0x1f200000 0x0 0x10000>, |
| 38 | − <0x0 0x1b008000 0x0 0x2000>, | |
| 38 | + <0x0 0x1b000000 0x0 0x400000>, | |
| 39 | 39 | <0x0 0x1054a000 0x0 0x100>; |
| 40 | 40 | interrupts = <0x0 0x82 0x4>, |
| 41 | 41 | <0x0 0xb8 0x4>, |
| @@ -82,6 +82,9 @@ Optional properties: · 81 unmodified lines | ||
| 82 | 82 | - id: If there are multiple instance of the same type, in order to |
| 83 | 83 | differentiate between each instance "id" can be used (e.g., multi-lane PCIe |
| 84 | 84 | PHY). If "id" is not provided, it is set to default value of '1'. |
| 85 | + - syscon-pllreset: Handle to system control region that contains the | |
| 86 | + CTRL_CORE_SMA_SW_0 register and register offset to the CTRL_CORE_SMA_SW_0 | |
| 87 | + register that contains the SATA_PLL_SOFT_RESET bit. Only valid for sata_phy. | |
| 85 | 88 | |
| 86 | 89 | This is usually a subnode of ocp2scp to which it is connected. |
| 87 | 90 | |
| @@ -100,3 +103,16 @@ usb3phy@4a084400 { · 12 unmodified lines | ||
| 100 | 103 | "sysclk", |
| 101 | 104 | "refclk"; |
| 102 | 105 | }; |
| 106 | + | |
| 107 | +sata_phy: phy@4A096000 { | |
| 108 | + compatible = "ti,phy-pipe3-sata"; | |
| 109 | + reg = <0x4A096000 0x80>, /* phy_rx */ | |
| 110 | + <0x4A096400 0x64>, /* phy_tx */ | |
| 111 | + <0x4A096800 0x40>; /* pll_ctrl */ | |
| 112 | + reg-names = "phy_rx", "phy_tx", "pll_ctrl"; | |
| 113 | + ctrl-module = <&omap_control_sata>; | |
| 114 | + clocks = <&sys_clkin1>, <&sata_ref_clk>; | |
| 115 | + clock-names = "sysclk", "refclk"; | |
| 116 | + syscon-pllreset = <&scm_conf 0x3fc>; | |
| 117 | + #phy-cells = <0>; | |
| 118 | +}; | |
| @@ -119,8 +119,10 @@ ALPS Absolute Mode - Protocol Version 2 · 118 unmodified lines | ||
| 119 | 119 | byte 5: 0 z6 z5 z4 z3 z2 z1 z0 |
| 120 | 120 | |
| 121 | 121 | Protocol Version 2 DualPoint devices send standard PS/2 mouse packets for |
| 122 | −the DualPoint Stick. For non interleaved dualpoint devices the pointingstick | |
| 123 | −buttons get reported separately in the PSM, PSR and PSL bits. | |
| 122 | +the DualPoint Stick. The M, R and L bits signal the combined status of both | |
| 123 | +the pointingstick and touchpad buttons, except for Dell dualpoint devices | |
| 124 | +where the pointingstick buttons get reported separately in the PSM, PSR | |
| 125 | +and PSL bits. | |
| 124 | 126 | |
| 125 | 127 | Dualpoint device -- interleaved packet format |
| 126 | 128 | --------------------------------------------- |
| @@ -5600,6 +5600,7 @@ F: kernel/irq/ · 5599 unmodified lines | ||
| 5600 | 5600 | IRQCHIP DRIVERS |
| 5601 | 5601 | M: Thomas Gleixner <tglx@linutronix.de> |
| 5602 | 5602 | M: Jason Cooper <jason@lakedaemon.net> |
| 5603 | +M: Marc Zyngier <marc.zyngier@arm.com> | |
| 5603 | 5604 | L: linux-kernel@vger.kernel.org |
| 5604 | 5605 | S: Maintained |
| 5605 | 5606 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core |
| @@ -5608,11 +5609,14 @@ F: Documentation/devicetree/bindings/interrupt-controller/ · 2 unmodified lines | ||
| 5608 | 5609 | F: drivers/irqchip/ |
| 5609 | 5610 | |
| 5610 | 5611 | IRQ DOMAINS (IRQ NUMBER MAPPING LIBRARY) |
| 5611 | −M: Benjamin Herrenschmidt <benh@kernel.crashing.org> | |
| 5612 | +M: Jiang Liu <jiang.liu@linux.intel.com> | |
| 5613 | +M: Marc Zyngier <marc.zyngier@arm.com> | |
| 5612 | 5614 | S: Maintained |
| 5615 | +T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core | |
| 5613 | 5616 | F: Documentation/IRQ-domain.txt |
| 5614 | 5617 | F: include/linux/irqdomain.h |
| 5615 | 5618 | F: kernel/irq/irqdomain.c |
| 5619 | +F: kernel/irq/msi.c | |
| 5616 | 5620 | |
| 5617 | 5621 | ISAPNP |
| 5618 | 5622 | M: Jaroslav Kysela <perex@perex.cz> |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | VERSION = 4 |
| 2 | 2 | PATCHLEVEL = 2 |
| 3 | 3 | SUBLEVEL = 0 |
| 4 | −EXTRAVERSION = -rc4 | |
| 4 | +EXTRAVERSION = -rc6 | |
| 5 | 5 | NAME = Hurr durr I'ma sheep |
| 6 | 6 | |
| 7 | 7 | # *DOCUMENTATION* |
| @@ -597,6 +597,11 @@ endif # $(dot-config) · 589 unmodified lines | ||
| 597 | 597 | # Defaults to vmlinux, but the arch makefile usually adds further targets |
| 598 | 598 | all: vmlinux |
| 599 | 599 | |
| 600 | +# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default | |
| 601 | +# values of the respective KBUILD_* variables | |
| 602 | +ARCH_CPPFLAGS := | |
| 603 | +ARCH_AFLAGS := | |
| 604 | +ARCH_CFLAGS := | |
| 600 | 605 | include arch/$(SRCARCH)/Makefile |
| 601 | 606 | |
| 602 | 607 | KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) |
| @@ -848,10 +853,10 @@ export mod_strip_cmd · 245 unmodified lines | ||
| 848 | 853 | mod_compress_cmd = true |
| 849 | 854 | ifdef CONFIG_MODULE_COMPRESS |
| 850 | 855 | ifdef CONFIG_MODULE_COMPRESS_GZIP |
| 851 | − mod_compress_cmd = gzip -n | |
| 856 | + mod_compress_cmd = gzip -n -f | |
| 852 | 857 | endif # CONFIG_MODULE_COMPRESS_GZIP |
| 853 | 858 | ifdef CONFIG_MODULE_COMPRESS_XZ |
| 854 | − mod_compress_cmd = xz | |
| 859 | + mod_compress_cmd = xz -f | |
| 855 | 860 | endif # CONFIG_MODULE_COMPRESS_XZ |
| 856 | 861 | endif # CONFIG_MODULE_COMPRESS |
| 857 | 862 | export mod_compress_cmd |
| @@ -313,11 +313,11 @@ config ARC_PAGE_SIZE_8K · 312 unmodified lines | ||
| 313 | 313 | |
| 314 | 314 | config ARC_PAGE_SIZE_16K |
| 315 | 315 | bool "16KB" |
| 316 | − depends on ARC_MMU_V3 | |
| 316 | + depends on ARC_MMU_V3 || ARC_MMU_V4 | |
| 317 | 317 | |
| 318 | 318 | config ARC_PAGE_SIZE_4K |
| 319 | 319 | bool "4KB" |
| 320 | − depends on ARC_MMU_V3 | |
| 320 | + depends on ARC_MMU_V3 || ARC_MMU_V4 | |
| 321 | 321 | |
| 322 | 322 | endchoice |
| 323 | 323 | |
| @@ -365,6 +365,11 @@ config ARC_HAS_LLSC · 41 unmodified lines | ||
| 365 | 365 | default y |
| 366 | 366 | depends on !ARC_CANT_LLSC |
| 367 | 367 | |
| 368 | +config ARC_STAR_9000923308 | |
| 369 | + bool "Workaround for llock/scond livelock" | |
| 370 | + default y | |
| 371 | + depends on ISA_ARCV2 && SMP && ARC_HAS_LLSC | |
| 372 | + | |
| 368 | 373 | config ARC_HAS_SWAPE |
| 369 | 374 | bool "Insn: SWAPE (endian-swap)" |
| 370 | 375 | default y |
| @@ -379,6 +384,10 @@ config ARC_HAS_LL64 · 8 unmodified lines | ||
| 379 | 384 | dest operands with 2 possible source operands. |
| 380 | 385 | default y |
| 381 | 386 | |
| 387 | +config ARC_HAS_DIV_REM | |
| 388 | + bool "Insn: div, divu, rem, remu" | |
| 389 | + default y | |
| 390 | + | |
| 382 | 391 | config ARC_HAS_RTC |
| 383 | 392 | bool "Local 64-bit r/o cycle counter" |
| 384 | 393 | default n |
| @@ -36,8 +36,16 @@ cflags-$(atleast_gcc44) += -fsection-anchors · 35 unmodified lines | ||
| 36 | 36 | cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock |
| 37 | 37 | cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape |
| 38 | 38 | |
| 39 | +ifdef CONFIG_ISA_ARCV2 | |
| 40 | + | |
| 39 | 41 | ifndef CONFIG_ARC_HAS_LL64 |
| 40 | −cflags-$(CONFIG_ISA_ARCV2) += -mno-ll64 | |
| 42 | +cflags-y += -mno-ll64 | |
| 43 | +endif | |
| 44 | + | |
| 45 | +ifndef CONFIG_ARC_HAS_DIV_REM | |
| 46 | +cflags-y += -mno-div-rem | |
| 47 | +endif | |
| 48 | + | |
| 41 | 49 | endif |
| 42 | 50 | |
| 43 | 51 | cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables |
| @@ -89,11 +89,10 @@ · 88 unmodified lines | ||
| 89 | 89 | #define ECR_C_BIT_DTLB_LD_MISS 8 |
| 90 | 90 | #define ECR_C_BIT_DTLB_ST_MISS 9 |
| 91 | 91 | |
| 92 | − | |
| 93 | 92 | /* Auxiliary registers */ |
| 94 | 93 | #define AUX_IDENTITY 4 |
| 95 | 94 | #define AUX_INTR_VEC_BASE 0x25 |
| 96 | − | |
| 95 | +#define AUX_NON_VOL 0x5e | |
| 97 | 96 | |
| 98 | 97 | /* |
| 99 | 98 | * Floating Pt Registers |
| @@ -240,9 +239,9 @@ struct bcr_extn_xymem { · 140 unmodified lines | ||
| 240 | 239 | |
| 241 | 240 | struct bcr_perip { |
| 242 | 241 | #ifdef CONFIG_CPU_BIG_ENDIAN |
| 243 | − unsigned int start:8, pad2:8, sz:8, pad:8; | |
| 242 | + unsigned int start:8, pad2:8, sz:8, ver:8; | |
| 244 | 243 | #else |
| 245 | − unsigned int pad:8, sz:8, pad2:8, start:8; | |
| 244 | + unsigned int ver:8, sz:8, pad2:8, start:8; | |
| 246 | 245 | #endif |
| 247 | 246 | }; |
| 248 | 247 | |
| @@ -23,33 +23,60 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #define atomic_set(v, i) (((v)->counter) = (i)) |
| 25 | 25 | |
| 26 | −#ifdef CONFIG_ISA_ARCV2 | |
| 27 | −#define PREFETCHW " prefetchw [%1] \n" | |
| 28 | −#else | |
| 29 | −#define PREFETCHW | |
| 26 | +#ifdef CONFIG_ARC_STAR_9000923308 | |
| 27 | + | |
| 28 | +#define SCOND_FAIL_RETRY_VAR_DEF \ | |
| 29 | + unsigned int delay = 1, tmp; \ | |
| 30 | + | |
| 31 | +#define SCOND_FAIL_RETRY_ASM \ | |
| 32 | + " bz 4f \n" \ | |
| 33 | + " ; --- scond fail delay --- \n" \ | |
| 34 | + " mov %[tmp], %[delay] \n" /* tmp = delay */ \ | |
| 35 | + "2: brne.d %[tmp], 0, 2b \n" /* while (tmp != 0) */ \ | |
| 36 | + " sub %[tmp], %[tmp], 1 \n" /* tmp-- */ \ | |
| 37 | + " rol %[delay], %[delay] \n" /* delay *= 2 */ \ | |
| 38 | + " b 1b \n" /* start over */ \ | |
| 39 | + "4: ; --- success --- \n" \ | |
| 40 | + | |
| 41 | +#define SCOND_FAIL_RETRY_VARS \ | |
| 42 | + ,[delay] "+&r" (delay),[tmp] "=&r" (tmp) \ | |
| 43 | + | |
| 44 | +#else /* !CONFIG_ARC_STAR_9000923308 */ | |
| 45 | + | |
| 46 | +#define SCOND_FAIL_RETRY_VAR_DEF | |
| 47 | + | |
| 48 | +#define SCOND_FAIL_RETRY_ASM \ | |
| 49 | + " bnz 1b \n" \ | |
| 50 | + | |
| 51 | +#define SCOND_FAIL_RETRY_VARS | |
| 52 | + | |
| 30 | 53 | #endif |
| 31 | 54 | |
| 32 | 55 | #define ATOMIC_OP(op, c_op, asm_op) \ |
| 33 | 56 | static inline void atomic_##op(int i, atomic_t *v) \ |
| 34 | 57 | { \ |
| 35 | − unsigned int temp; \ | |
| 58 | + unsigned int val; \ | |
| 59 | + SCOND_FAIL_RETRY_VAR_DEF \ | |
| 36 | 60 | \ |
| 37 | 61 | __asm__ __volatile__( \ |
| 38 | − "1: \n" \ | |
| 39 | − PREFETCHW \ | |
| 40 | − " llock %0, [%1] \n" \ | |
| 41 | − " " #asm_op " %0, %0, %2 \n" \ | |
| 42 | − " scond %0, [%1] \n" \ | |
| 43 | − " bnz 1b \n" \ | |
| 44 | − : "=&r"(temp) /* Early clobber, to prevent reg reuse */ \ | |
| 45 | − : "r"(&v->counter), "ir"(i) \ | |
| 62 | + "1: llock %[val], [%[ctr]] \n" \ | |
| 63 | + " " #asm_op " %[val], %[val], %[i] \n" \ | |
| 64 | + " scond %[val], [%[ctr]] \n" \ | |
| 65 | + " \n" \ | |
| 66 | + SCOND_FAIL_RETRY_ASM \ | |
| 67 | + \ | |
| 68 | + : [val] "=&r" (val) /* Early clobber to prevent reg reuse */ \ | |
| 69 | + SCOND_FAIL_RETRY_VARS \ | |
| 70 | + : [ctr] "r" (&v->counter), /* Not "m": llock only supports reg direct addr mode */ \ | |
| 71 | + [i] "ir" (i) \ | |
| 46 | 72 | : "cc"); \ |
| 47 | 73 | } \ |
| 48 | 74 | |
| 49 | 75 | #define ATOMIC_OP_RETURN(op, c_op, asm_op) \ |
| 50 | 76 | static inline int atomic_##op##_return(int i, atomic_t *v) \ |
| 51 | 77 | { \ |
| 52 | − unsigned int temp; \ | |
| 78 | + unsigned int val; \ | |
| 79 | + SCOND_FAIL_RETRY_VAR_DEF \ | |
| 53 | 80 | \ |
| 54 | 81 | /* \ |
| 55 | 82 | * Explicit full memory barrier needed before/after as \ |
| @@ -58,19 +85,21 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ · 2 unmodified lines | ||
| 58 | 85 | smp_mb(); \ |
| 59 | 86 | \ |
| 60 | 87 | __asm__ __volatile__( \ |
| 61 | − "1: \n" \ | |
| 62 | − PREFETCHW \ | |
| 63 | − " llock %0, [%1] \n" \ | |
| 64 | − " " #asm_op " %0, %0, %2 \n" \ | |
| 65 | − " scond %0, [%1] \n" \ | |
| 66 | − " bnz 1b \n" \ | |
| 67 | − : "=&r"(temp) \ | |
| 68 | − : "r"(&v->counter), "ir"(i) \ | |
| 88 | + "1: llock %[val], [%[ctr]] \n" \ | |
| 89 | + " " #asm_op " %[val], %[val], %[i] \n" \ | |
| 90 | + " scond %[val], [%[ctr]] \n" \ | |
| 91 | + " \n" \ | |
| 92 | + SCOND_FAIL_RETRY_ASM \ | |
| 93 | + \ | |
| 94 | + : [val] "=&r" (val) \ | |
| 95 | + SCOND_FAIL_RETRY_VARS \ | |
| 96 | + : [ctr] "r" (&v->counter), \ | |
| 97 | + [i] "ir" (i) \ | |
| 69 | 98 | : "cc"); \ |
| 70 | 99 | \ |
| 71 | 100 | smp_mb(); \ |
| 72 | 101 | \ |
| 73 | − return temp; \ | |
| 102 | + return val; \ | |
| 74 | 103 | } |
| 75 | 104 | |
| 76 | 105 | #else /* !CONFIG_ARC_HAS_LLSC */ |
| @@ -150,6 +179,9 @@ ATOMIC_OP(and, &=, and) · 73 unmodified lines | ||
| 150 | 179 | #undef ATOMIC_OPS |
| 151 | 180 | #undef ATOMIC_OP_RETURN |
| 152 | 181 | #undef ATOMIC_OP |
| 182 | +#undef SCOND_FAIL_RETRY_VAR_DEF | |
| 183 | +#undef SCOND_FAIL_RETRY_ASM | |
| 184 | +#undef SCOND_FAIL_RETRY_VARS | |
| 153 | 185 | |
| 154 | 186 | /** |
| 155 | 187 | * __atomic_add_unless - add unless the number is a given value |
| @@ -20,20 +20,20 @@ · 19 unmodified lines | ||
| 20 | 20 | struct pt_regs { |
| 21 | 21 | |
| 22 | 22 | /* Real registers */ |
| 23 | − long bta; /* bta_l1, bta_l2, erbta */ | |
| 23 | + unsigned long bta; /* bta_l1, bta_l2, erbta */ | |
| 24 | 24 | |
| 25 | − long lp_start, lp_end, lp_count; | |
| 25 | + unsigned long lp_start, lp_end, lp_count; | |
| 26 | 26 | |
| 27 | − long status32; /* status32_l1, status32_l2, erstatus */ | |
| 28 | − long ret; /* ilink1, ilink2 or eret */ | |
| 29 | − long blink; | |
| 30 | − long fp; | |
| 31 | − long r26; /* gp */ | |
| 27 | + unsigned long status32; /* status32_l1, status32_l2, erstatus */ | |
| 28 | + unsigned long ret; /* ilink1, ilink2 or eret */ | |
| 29 | + unsigned long blink; | |
| 30 | + unsigned long fp; | |
| 31 | + unsigned long r26; /* gp */ | |
| 32 | 32 | |
| 33 | − long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0; | |
| 33 | + unsigned long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0; | |
| 34 | 34 | |
| 35 | − long sp; /* user/kernel sp depending on where we came from */ | |
| 36 | − long orig_r0; | |
| 35 | + unsigned long sp; /* User/Kernel depending on where we came from */ | |
| 36 | + unsigned long orig_r0; | |
| 37 | 37 | |
| 38 | 38 | /* |
| 39 | 39 | * To distinguish bet excp, syscall, irq |
| @@ -55,13 +55,13 @@ struct pt_regs { · 15 unmodified lines | ||
| 55 | 55 | unsigned long event; |
| 56 | 56 | }; |
| 57 | 57 | |
| 58 | − long user_r25; | |
| 58 | + unsigned long user_r25; | |
| 59 | 59 | }; |
| 60 | 60 | #else |
| 61 | 61 | |
| 62 | 62 | struct pt_regs { |
| 63 | 63 | |
| 64 | − long orig_r0; | |
| 64 | + unsigned long orig_r0; | |
| 65 | 65 | |
| 66 | 66 | union { |
| 67 | 67 | struct { |
| @@ -76,26 +76,26 @@ struct pt_regs { · 8 unmodified lines | ||
| 76 | 76 | unsigned long event; |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | − long bta; /* bta_l1, bta_l2, erbta */ | |
| 79 | + unsigned long bta; /* bta_l1, bta_l2, erbta */ | |
| 80 | 80 | |
| 81 | − long user_r25; | |
| 81 | + unsigned long user_r25; | |
| 82 | 82 | |
| 83 | − long r26; /* gp */ | |
| 84 | − long fp; | |
| 85 | − long sp; /* user/kernel sp depending on where we came from */ | |
| 83 | + unsigned long r26; /* gp */ | |
| 84 | + unsigned long fp; | |
| 85 | + unsigned long sp; /* user/kernel sp depending on where we came from */ | |
| 86 | 86 | |
| 87 | − long r12; | |
| 87 | + unsigned long r12; | |
| 88 | 88 | |
| 89 | 89 | /*------- Below list auto saved by h/w -----------*/ |
| 90 | − long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; | |
| 90 | + unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; | |
| 91 | 91 | |
| 92 | − long blink; | |
| 93 | − long lp_end, lp_start, lp_count; | |
| 92 | + unsigned long blink; | |
| 93 | + unsigned long lp_end, lp_start, lp_count; | |
| 94 | 94 | |
| 95 | − long ei, ldi, jli; | |
| 95 | + unsigned long ei, ldi, jli; | |
| 96 | 96 | |
| 97 | − long ret; | |
| 98 | − long status32; | |
| 97 | + unsigned long ret; | |
| 98 | + unsigned long status32; | |
| 99 | 99 | }; |
| 100 | 100 | |
| 101 | 101 | #endif |
| @@ -103,10 +103,10 @@ struct pt_regs { · 1 unmodified line | ||
| 103 | 103 | /* Callee saved registers - need to be saved only when you are scheduled out */ |
| 104 | 104 | |
| 105 | 105 | struct callee_regs { |
| 106 | − long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13; | |
| 106 | + unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13; | |
| 107 | 107 | }; |
| 108 | 108 | |
| 109 | −#define instruction_pointer(regs) (unsigned long)((regs)->ret) | |
| 109 | +#define instruction_pointer(regs) ((regs)->ret) | |
| 110 | 110 | #define profile_pc(regs) instruction_pointer(regs) |
| 111 | 111 | |
| 112 | 112 | /* return 1 if user mode or 0 if kernel mode */ |
| @@ -142,7 +142,7 @@ struct callee_regs { · 29 unmodified lines | ||
| 142 | 142 | |
| 143 | 143 | static inline long regs_return_value(struct pt_regs *regs) |
| 144 | 144 | { |
| 145 | − return regs->r0; | |
| 145 | + return (long)regs->r0; | |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | #endif /* !__ASSEMBLY__ */ |
| @@ -18,9 +18,518 @@ · 17 unmodified lines | ||
| 18 | 18 | #define arch_spin_unlock_wait(x) \ |
| 19 | 19 | do { while (arch_spin_is_locked(x)) cpu_relax(); } while (0) |
| 20 | 20 | |
| 21 | +#ifdef CONFIG_ARC_HAS_LLSC | |
| 22 | + | |
| 23 | +/* | |
| 24 | + * A normal LLOCK/SCOND based system, w/o need for livelock workaround | |
| 25 | + */ | |
| 26 | +#ifndef CONFIG_ARC_STAR_9000923308 | |
| 27 | + | |
| 21 | 28 | static inline void arch_spin_lock(arch_spinlock_t *lock) |
| 22 | 29 | { |
| 23 | − unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; | |
| 30 | + unsigned int val; | |
| 31 | + | |
| 32 | + smp_mb(); | |
| 33 | + | |
| 34 | + __asm__ __volatile__( | |
| 35 | + "1: llock %[val], [%[slock]] \n" | |
| 36 | + " breq %[val], %[LOCKED], 1b \n" /* spin while LOCKED */ | |
| 37 | + " scond %[LOCKED], [%[slock]] \n" /* acquire */ | |
| 38 | + " bnz 1b \n" | |
| 39 | + " \n" | |
| 40 | + : [val] "=&r" (val) | |
| 41 | + : [slock] "r" (&(lock->slock)), | |
| 42 | + [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__) | |
| 43 | + : "memory", "cc"); | |
| 44 | + | |
| 45 | + smp_mb(); | |
| 46 | +} | |
| 47 | + | |
| 48 | +/* 1 - lock taken successfully */ | |
| 49 | +static inline int arch_spin_trylock(arch_spinlock_t *lock) | |
| 50 | +{ | |
| 51 | + unsigned int val, got_it = 0; | |
| 52 | + | |
| 53 | + smp_mb(); | |
| 54 | + | |
| 55 | + __asm__ __volatile__( | |
| 56 | + "1: llock %[val], [%[slock]] \n" | |
| 57 | + " breq %[val], %[LOCKED], 4f \n" /* already LOCKED, just bail */ | |
| 58 | + " scond %[LOCKED], [%[slock]] \n" /* acquire */ | |
| 59 | + " bnz 1b \n" | |
| 60 | + " mov %[got_it], 1 \n" | |
| 61 | + "4: \n" | |
| 62 | + " \n" | |
| 63 | + : [val] "=&r" (val), | |
| 64 | + [got_it] "+&r" (got_it) | |
| 65 | + : [slock] "r" (&(lock->slock)), | |
| 66 | + [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__) | |
| 67 | + : "memory", "cc"); | |
| 68 | + | |
| 69 | + smp_mb(); | |
| 70 | + | |
| 71 | + return got_it; | |
| 72 | +} | |
| 73 | + | |
| 74 | +static inline void arch_spin_unlock(arch_spinlock_t *lock) | |
| 75 | +{ | |
| 76 | + smp_mb(); | |
| 77 | + | |
| 78 | + lock->slock = __ARCH_SPIN_LOCK_UNLOCKED__; | |
| 79 | + | |
| 80 | + smp_mb(); | |
| 81 | +} | |
| 82 | + | |
| 83 | +/* | |
| 84 | + * Read-write spinlocks, allowing multiple readers but only one writer. | |
| 85 | + * Unfair locking as Writers could be starved indefinitely by Reader(s) | |
| 86 | + */ | |
| 87 | + | |
| 88 | +static inline void arch_read_lock(arch_rwlock_t *rw) | |
| 89 | +{ | |
| 90 | + unsigned int val; | |
| 91 | + | |
| 92 | + smp_mb(); | |
| 93 | + | |
| 94 | + /* | |
| 95 | + * zero means writer holds the lock exclusively, deny Reader. | |
| 96 | + * Otherwise grant lock to first/subseq reader | |
| 97 | + * | |
| 98 | + * if (rw->counter > 0) { | |
| 99 | + * rw->counter--; | |
| 100 | + * ret = 1; | |
| 101 | + * } | |
| 102 | + */ | |
| 103 | + | |
| 104 | + __asm__ __volatile__( | |
| 105 | + "1: llock %[val], [%[rwlock]] \n" | |
| 106 | + " brls %[val], %[WR_LOCKED], 1b\n" /* <= 0: spin while write locked */ | |
| 107 | + " sub %[val], %[val], 1 \n" /* reader lock */ | |
| 108 | + " scond %[val], [%[rwlock]] \n" | |
| 109 | + " bnz 1b \n" | |
| 110 | + " \n" | |
| 111 | + : [val] "=&r" (val) | |
| 112 | + : [rwlock] "r" (&(rw->counter)), | |
| 113 | + [WR_LOCKED] "ir" (0) | |
| 114 | + : "memory", "cc"); | |
| 115 | + | |
| 116 | + smp_mb(); | |
| 117 | +} | |
| 118 | + | |
| 119 | +/* 1 - lock taken successfully */ | |
| 120 | +static inline int arch_read_trylock(arch_rwlock_t *rw) | |
| 121 | +{ | |
| 122 | + unsigned int val, got_it = 0; | |
| 123 | + | |
| 124 | + smp_mb(); | |
| 125 | + | |
| 126 | + __asm__ __volatile__( | |
| 127 | + "1: llock %[val], [%[rwlock]] \n" | |
| 128 | + " brls %[val], %[WR_LOCKED], 4f\n" /* <= 0: already write locked, bail */ | |
| 129 | + " sub %[val], %[val], 1 \n" /* counter-- */ | |
| 130 | + " scond %[val], [%[rwlock]] \n" | |
| 131 | + " bnz 1b \n" /* retry if collided with someone */ | |
| 132 | + " mov %[got_it], 1 \n" | |
| 133 | + " \n" | |
| 134 | + "4: ; --- done --- \n" | |
| 135 | + | |
| 136 | + : [val] "=&r" (val), | |
| 137 | + [got_it] "+&r" (got_it) | |
| 138 | + : [rwlock] "r" (&(rw->counter)), | |
| 139 | + [WR_LOCKED] "ir" (0) | |
| 140 | + : "memory", "cc"); | |
| 141 | + | |
| 142 | + smp_mb(); | |
| 143 | + | |
| 144 | + return got_it; | |
| 145 | +} | |
| 146 | + | |
| 147 | +static inline void arch_write_lock(arch_rwlock_t *rw) | |
| 148 | +{ | |
| 149 | + unsigned int val; | |
| 150 | + | |
| 151 | + smp_mb(); | |
| 152 | + | |
| 153 | + /* | |
| 154 | + * If reader(s) hold lock (lock < __ARCH_RW_LOCK_UNLOCKED__), | |
| 155 | + * deny writer. Otherwise if unlocked grant to writer | |
| 156 | + * Hence the claim that Linux rwlocks are unfair to writers. | |
| 157 | + * (can be starved for an indefinite time by readers). | |
| 158 | + * | |
| 159 | + * if (rw->counter == __ARCH_RW_LOCK_UNLOCKED__) { | |
| 160 | + * rw->counter = 0; | |
| 161 | + * ret = 1; | |
| 162 | + * } | |
| 163 | + */ | |
| 164 | + | |
| 165 | + __asm__ __volatile__( | |
| 166 | + "1: llock %[val], [%[rwlock]] \n" | |
| 167 | + " brne %[val], %[UNLOCKED], 1b \n" /* while !UNLOCKED spin */ | |
| 168 | + " mov %[val], %[WR_LOCKED] \n" | |
| 169 | + " scond %[val], [%[rwlock]] \n" | |
| 170 | + " bnz 1b \n" | |
| 171 | + " \n" | |
| 172 | + : [val] "=&r" (val) | |
| 173 | + : [rwlock] "r" (&(rw->counter)), | |
| 174 | + [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__), | |
| 175 | + [WR_LOCKED] "ir" (0) | |
| 176 | + : "memory", "cc"); | |
| 177 | + | |
| 178 | + smp_mb(); | |
| 179 | +} | |
| 180 | + | |
| 181 | +/* 1 - lock taken successfully */ | |
| 182 | +static inline int arch_write_trylock(arch_rwlock_t *rw) | |
| 183 | +{ | |
| 184 | + unsigned int val, got_it = 0; | |
| 185 | + | |
| 186 | + smp_mb(); | |
| 187 | + | |
| 188 | + __asm__ __volatile__( | |
| 189 | + "1: llock %[val], [%[rwlock]] \n" | |
| 190 | + " brne %[val], %[UNLOCKED], 4f \n" /* !UNLOCKED, bail */ | |
| 191 | + " mov %[val], %[WR_LOCKED] \n" | |
| 192 | + " scond %[val], [%[rwlock]] \n" | |
| 193 | + " bnz 1b \n" /* retry if collided with someone */ | |
| 194 | + " mov %[got_it], 1 \n" | |
| 195 | + " \n" | |
| 196 | + "4: ; --- done --- \n" | |
| 197 | + | |
| 198 | + : [val] "=&r" (val), | |
| 199 | + [got_it] "+&r" (got_it) | |
| 200 | + : [rwlock] "r" (&(rw->counter)), | |
| 201 | + [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__), | |
| 202 | + [WR_LOCKED] "ir" (0) | |
| 203 | + : "memory", "cc"); | |
| 204 | + | |
| 205 | + smp_mb(); | |
| 206 | + | |
| 207 | + return got_it; | |
| 208 | +} | |
| 209 | + | |
| 210 | +static inline void arch_read_unlock(arch_rwlock_t *rw) | |
| 211 | +{ | |
| 212 | + unsigned int val; | |
| 213 | + | |
| 214 | + smp_mb(); | |
| 215 | + | |
| 216 | + /* | |
| 217 | + * rw->counter++; | |
| 218 | + */ | |
| 219 | + __asm__ __volatile__( | |
| 220 | + "1: llock %[val], [%[rwlock]] \n" | |
| 221 | + " add %[val], %[val], 1 \n" | |
| 222 | + " scond %[val], [%[rwlock]] \n" | |
| 223 | + " bnz 1b \n" | |
| 224 | + " \n" | |
| 225 | + : [val] "=&r" (val) | |
| 226 | + : [rwlock] "r" (&(rw->counter)) | |
| 227 | + : "memory", "cc"); | |
| 228 | + | |
| 229 | + smp_mb(); | |
| 230 | +} | |
| 231 | + | |
| 232 | +static inline void arch_write_unlock(arch_rwlock_t *rw) | |
| 233 | +{ | |
| 234 | + smp_mb(); | |
| 235 | + | |
| 236 | + rw->counter = __ARCH_RW_LOCK_UNLOCKED__; | |
| 237 | + | |
| 238 | + smp_mb(); | |
| 239 | +} | |
| 240 | + | |
| 241 | +#else /* CONFIG_ARC_STAR_9000923308 */ | |
| 242 | + | |
| 243 | +/* | |
| 244 | + * HS38x4 could get into a LLOCK/SCOND livelock in case of multiple overlapping | |
| 245 | + * coherency transactions in the SCU. The exclusive line state keeps rotating | |
| 246 | + * among contenting cores leading to a never ending cycle. So break the cycle | |
| 247 | + * by deferring the retry of failed exclusive access (SCOND). The actual delay | |
| 248 | + * needed is function of number of contending cores as well as the unrelated | |
| 249 | + * coherency traffic from other cores. To keep the code simple, start off with | |
| 250 | + * small delay of 1 which would suffice most cases and in case of contention | |
| 251 | + * double the delay. Eventually the delay is sufficient such that the coherency | |
| 252 | + * pipeline is drained, thus a subsequent exclusive access would succeed. | |
| 253 | + */ | |
| 254 | + | |
| 255 | +#define SCOND_FAIL_RETRY_VAR_DEF \ | |
| 256 | + unsigned int delay, tmp; \ | |
| 257 | + | |
| 258 | +#define SCOND_FAIL_RETRY_ASM \ | |
| 259 | + " ; --- scond fail delay --- \n" \ | |
| 260 | + " mov %[tmp], %[delay] \n" /* tmp = delay */ \ | |
| 261 | + "2: brne.d %[tmp], 0, 2b \n" /* while (tmp != 0) */ \ | |
| 262 | + " sub %[tmp], %[tmp], 1 \n" /* tmp-- */ \ | |
| 263 | + " rol %[delay], %[delay] \n" /* delay *= 2 */ \ | |
| 264 | + " b 1b \n" /* start over */ \ | |
| 265 | + " \n" \ | |
| 266 | + "4: ; --- done --- \n" \ | |
| 267 | + | |
| 268 | +#define SCOND_FAIL_RETRY_VARS \ | |
| 269 | + ,[delay] "=&r" (delay), [tmp] "=&r" (tmp) \ | |
| 270 | + | |
| 271 | +static inline void arch_spin_lock(arch_spinlock_t *lock) | |
| 272 | +{ | |
| 273 | + unsigned int val; | |
| 274 | + SCOND_FAIL_RETRY_VAR_DEF; | |
| 275 | + | |
| 276 | + smp_mb(); | |
| 277 | + | |
| 278 | + __asm__ __volatile__( | |
| 279 | + "0: mov %[delay], 1 \n" | |
| 280 | + "1: llock %[val], [%[slock]] \n" | |
| 281 | + " breq %[val], %[LOCKED], 0b \n" /* spin while LOCKED */ | |
| 282 | + " scond %[LOCKED], [%[slock]] \n" /* acquire */ | |
| 283 | + " bz 4f \n" /* done */ | |
| 284 | + " \n" | |
| 285 | + SCOND_FAIL_RETRY_ASM | |
| 286 | + | |
| 287 | + : [val] "=&r" (val) | |
| 288 | + SCOND_FAIL_RETRY_VARS | |
| 289 | + : [slock] "r" (&(lock->slock)), | |
| 290 | + [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__) | |
| 291 | + : "memory", "cc"); | |
| 292 | + | |
| 293 | + smp_mb(); | |
| 294 | +} | |
| 295 | + | |
| 296 | +/* 1 - lock taken successfully */ | |
| 297 | +static inline int arch_spin_trylock(arch_spinlock_t *lock) | |
| 298 | +{ | |
| 299 | + unsigned int val, got_it = 0; | |
| 300 | + SCOND_FAIL_RETRY_VAR_DEF; | |
| 301 | + | |
| 302 | + smp_mb(); | |
| 303 | + | |
| 304 | + __asm__ __volatile__( | |
| 305 | + "0: mov %[delay], 1 \n" | |
| 306 | + "1: llock %[val], [%[slock]] \n" | |
| 307 | + " breq %[val], %[LOCKED], 4f \n" /* already LOCKED, just bail */ | |
| 308 | + " scond %[LOCKED], [%[slock]] \n" /* acquire */ | |
| 309 | + " bz.d 4f \n" | |
| 310 | + " mov.z %[got_it], 1 \n" /* got it */ | |
| 311 | + " \n" | |
| 312 | + SCOND_FAIL_RETRY_ASM | |
| 313 | + | |
| 314 | + : [val] "=&r" (val), | |
| 315 | + [got_it] "+&r" (got_it) | |
| 316 | + SCOND_FAIL_RETRY_VARS | |
| 317 | + : [slock] "r" (&(lock->slock)), | |
| 318 | + [LOCKED] "r" (__ARCH_SPIN_LOCK_LOCKED__) | |
| 319 | + : "memory", "cc"); | |
| 320 | + | |
| 321 | + smp_mb(); | |
| 322 | + | |
| 323 | + return got_it; | |
| 324 | +} | |
| 325 | + | |
| 326 | +static inline void arch_spin_unlock(arch_spinlock_t *lock) | |
| 327 | +{ | |
| 328 | + smp_mb(); | |
| 329 | + | |
| 330 | + lock->slock = __ARCH_SPIN_LOCK_UNLOCKED__; | |
| 331 | + | |
| 332 | + smp_mb(); | |
| 333 | +} | |
| 334 | + | |
| 335 | +/* | |
| 336 | + * Read-write spinlocks, allowing multiple readers but only one writer. | |
| 337 | + * Unfair locking as Writers could be starved indefinitely by Reader(s) | |
| 338 | + */ | |
| 339 | + | |
| 340 | +static inline void arch_read_lock(arch_rwlock_t *rw) | |
| 341 | +{ | |
| 342 | + unsigned int val; | |
| 343 | + SCOND_FAIL_RETRY_VAR_DEF; | |
| 344 | + | |
| 345 | + smp_mb(); | |
| 346 | + | |
| 347 | + /* | |
| 348 | + * zero means writer holds the lock exclusively, deny Reader. | |
| 349 | + * Otherwise grant lock to first/subseq reader | |
| 350 | + * | |
| 351 | + * if (rw->counter > 0) { | |
| 352 | + * rw->counter--; | |
| 353 | + * ret = 1; | |
| 354 | + * } | |
| 355 | + */ | |
| 356 | + | |
| 357 | + __asm__ __volatile__( | |
| 358 | + "0: mov %[delay], 1 \n" | |
| 359 | + "1: llock %[val], [%[rwlock]] \n" | |
| 360 | + " brls %[val], %[WR_LOCKED], 0b\n" /* <= 0: spin while write locked */ | |
| 361 | + " sub %[val], %[val], 1 \n" /* reader lock */ | |
| 362 | + " scond %[val], [%[rwlock]] \n" | |
| 363 | + " bz 4f \n" /* done */ | |
| 364 | + " \n" | |
| 365 | + SCOND_FAIL_RETRY_ASM | |
| 366 | + | |
| 367 | + : [val] "=&r" (val) | |
| 368 | + SCOND_FAIL_RETRY_VARS | |
| 369 | + : [rwlock] "r" (&(rw->counter)), | |
| 370 | + [WR_LOCKED] "ir" (0) | |
| 371 | + : "memory", "cc"); | |
| 372 | + | |
| 373 | + smp_mb(); | |
| 374 | +} | |
| 375 | + | |
| 376 | +/* 1 - lock taken successfully */ | |
| 377 | +static inline int arch_read_trylock(arch_rwlock_t *rw) | |
| 378 | +{ | |
| 379 | + unsigned int val, got_it = 0; | |
| 380 | + SCOND_FAIL_RETRY_VAR_DEF; | |
| 381 | + | |
| 382 | + smp_mb(); | |
| 383 | + | |
| 384 | + __asm__ __volatile__( | |
| 385 | + "0: mov %[delay], 1 \n" | |
| 386 | + "1: llock %[val], [%[rwlock]] \n" | |
| 387 | + " brls %[val], %[WR_LOCKED], 4f\n" /* <= 0: already write locked, bail */ | |
| 388 | + " sub %[val], %[val], 1 \n" /* counter-- */ | |
| 389 | + " scond %[val], [%[rwlock]] \n" | |
| 390 | + " bz.d 4f \n" | |
| 391 | + " mov.z %[got_it], 1 \n" /* got it */ | |
| 392 | + " \n" | |
| 393 | + SCOND_FAIL_RETRY_ASM | |
| 394 | + | |
| 395 | + : [val] "=&r" (val), | |
| 396 | + [got_it] "+&r" (got_it) | |
| 397 | + SCOND_FAIL_RETRY_VARS | |
| 398 | + : [rwlock] "r" (&(rw->counter)), | |
| 399 | + [WR_LOCKED] "ir" (0) | |
| 400 | + : "memory", "cc"); | |
| 401 | + | |
| 402 | + smp_mb(); | |
| 403 | + | |
| 404 | + return got_it; | |
| 405 | +} | |
| 406 | + | |
| 407 | +static inline void arch_write_lock(arch_rwlock_t *rw) | |
| 408 | +{ | |
| 409 | + unsigned int val; | |
| 410 | + SCOND_FAIL_RETRY_VAR_DEF; | |
| 411 | + | |
| 412 | + smp_mb(); | |
| 413 | + | |
| 414 | + /* | |
| 415 | + * If reader(s) hold lock (lock < __ARCH_RW_LOCK_UNLOCKED__), | |
| 416 | + * deny writer. Otherwise if unlocked grant to writer | |
| 417 | + * Hence the claim that Linux rwlocks are unfair to writers. | |
| 418 | + * (can be starved for an indefinite time by readers). | |
| 419 | + * | |
| 420 | + * if (rw->counter == __ARCH_RW_LOCK_UNLOCKED__) { | |
| 421 | + * rw->counter = 0; | |
| 422 | + * ret = 1; | |
| 423 | + * } | |
| 424 | + */ | |
| 425 | + | |
| 426 | + __asm__ __volatile__( | |
| 427 | + "0: mov %[delay], 1 \n" | |
| 428 | + "1: llock %[val], [%[rwlock]] \n" | |
| 429 | + " brne %[val], %[UNLOCKED], 0b \n" /* while !UNLOCKED spin */ | |
| 430 | + " mov %[val], %[WR_LOCKED] \n" | |
| 431 | + " scond %[val], [%[rwlock]] \n" | |
| 432 | + " bz 4f \n" | |
| 433 | + " \n" | |
| 434 | + SCOND_FAIL_RETRY_ASM | |
| 435 | + | |
| 436 | + : [val] "=&r" (val) | |
| 437 | + SCOND_FAIL_RETRY_VARS | |
| 438 | + : [rwlock] "r" (&(rw->counter)), | |
| 439 | + [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__), | |
| 440 | + [WR_LOCKED] "ir" (0) | |
| 441 | + : "memory", "cc"); | |
| 442 | + | |
| 443 | + smp_mb(); | |
| 444 | +} | |
| 445 | + | |
| 446 | +/* 1 - lock taken successfully */ | |
| 447 | +static inline int arch_write_trylock(arch_rwlock_t *rw) | |
| 448 | +{ | |
| 449 | + unsigned int val, got_it = 0; | |
| 450 | + SCOND_FAIL_RETRY_VAR_DEF; | |
| 451 | + | |
| 452 | + smp_mb(); | |
| 453 | + | |
| 454 | + __asm__ __volatile__( | |
| 455 | + "0: mov %[delay], 1 \n" | |
| 456 | + "1: llock %[val], [%[rwlock]] \n" | |
| 457 | + " brne %[val], %[UNLOCKED], 4f \n" /* !UNLOCKED, bail */ | |
| 458 | + " mov %[val], %[WR_LOCKED] \n" | |
| 459 | + " scond %[val], [%[rwlock]] \n" | |
| 460 | + " bz.d 4f \n" | |
| 461 | + " mov.z %[got_it], 1 \n" /* got it */ | |
| 462 | + " \n" | |
| 463 | + SCOND_FAIL_RETRY_ASM | |
| 464 | + | |
| 465 | + : [val] "=&r" (val), | |
| 466 | + [got_it] "+&r" (got_it) | |
| 467 | + SCOND_FAIL_RETRY_VARS | |
| 468 | + : [rwlock] "r" (&(rw->counter)), | |
| 469 | + [UNLOCKED] "ir" (__ARCH_RW_LOCK_UNLOCKED__), | |
| 470 | + [WR_LOCKED] "ir" (0) | |
| 471 | + : "memory", "cc"); | |
| 472 | + | |
| 473 | + smp_mb(); | |
| 474 | + | |
| 475 | + return got_it; | |
| 476 | +} | |
| 477 | + | |
| 478 | +static inline void arch_read_unlock(arch_rwlock_t *rw) | |
| 479 | +{ | |
| 480 | + unsigned int val; | |
| 481 | + | |
| 482 | + smp_mb(); | |
| 483 | + | |
| 484 | + /* | |
| 485 | + * rw->counter++; | |
| 486 | + */ | |
| 487 | + __asm__ __volatile__( | |
| 488 | + "1: llock %[val], [%[rwlock]] \n" | |
| 489 | + " add %[val], %[val], 1 \n" | |
| 490 | + " scond %[val], [%[rwlock]] \n" | |
| 491 | + " bnz 1b \n" | |
| 492 | + " \n" | |
| 493 | + : [val] "=&r" (val) | |
| 494 | + : [rwlock] "r" (&(rw->counter)) | |
| 495 | + : "memory", "cc"); | |
| 496 | + | |
| 497 | + smp_mb(); | |
| 498 | +} | |
| 499 | + | |
| 500 | +static inline void arch_write_unlock(arch_rwlock_t *rw) | |
| 501 | +{ | |
| 502 | + unsigned int val; | |
| 503 | + | |
| 504 | + smp_mb(); | |
| 505 | + | |
| 506 | + /* | |
| 507 | + * rw->counter = __ARCH_RW_LOCK_UNLOCKED__; | |
| 508 | + */ | |
| 509 | + __asm__ __volatile__( | |
| 510 | + "1: llock %[val], [%[rwlock]] \n" | |
| 511 | + " scond %[UNLOCKED], [%[rwlock]]\n" | |
| 512 | + " bnz 1b \n" | |
| 513 | + " \n" | |
| 514 | + : [val] "=&r" (val) | |
| 515 | + : [rwlock] "r" (&(rw->counter)), | |
| 516 | + [UNLOCKED] "r" (__ARCH_RW_LOCK_UNLOCKED__) | |
| 517 | + : "memory", "cc"); | |
| 518 | + | |
| 519 | + smp_mb(); | |
| 520 | +} | |
| 521 | + | |
| 522 | +#undef SCOND_FAIL_RETRY_VAR_DEF | |
| 523 | +#undef SCOND_FAIL_RETRY_ASM | |
| 524 | +#undef SCOND_FAIL_RETRY_VARS | |
| 525 | + | |
| 526 | +#endif /* CONFIG_ARC_STAR_9000923308 */ | |
| 527 | + | |
| 528 | +#else /* !CONFIG_ARC_HAS_LLSC */ | |
| 529 | + | |
| 530 | +static inline void arch_spin_lock(arch_spinlock_t *lock) | |
| 531 | +{ | |
| 532 | + unsigned int val = __ARCH_SPIN_LOCK_LOCKED__; | |
| 24 | 533 | |
| 25 | 534 | /* |
| 26 | 535 | * This smp_mb() is technically superfluous, we only need the one |
| @@ -33,7 +542,7 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) · 6 unmodified lines | ||
| 33 | 542 | __asm__ __volatile__( |
| 34 | 543 | "1: ex %0, [%1] \n" |
| 35 | 544 | " breq %0, %2, 1b \n" |
| 36 | − : "+&r" (tmp) | |
| 545 | + : "+&r" (val) | |
| 37 | 546 | : "r"(&(lock->slock)), "ir"(__ARCH_SPIN_LOCK_LOCKED__) |
| 38 | 547 | : "memory"); |
| 39 | 548 | |
| @@ -48,26 +557,27 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) · 8 unmodified lines | ||
| 48 | 557 | smp_mb(); |
| 49 | 558 | } |
| 50 | 559 | |
| 560 | +/* 1 - lock taken successfully */ | |
| 51 | 561 | static inline int arch_spin_trylock(arch_spinlock_t *lock) |
| 52 | 562 | { |
| 53 | − unsigned int tmp = __ARCH_SPIN_LOCK_LOCKED__; | |
| 563 | + unsigned int val = __ARCH_SPIN_LOCK_LOCKED__; | |
| 54 | 564 | |
| 55 | 565 | smp_mb(); |
| 56 | 566 | |
| 57 | 567 | __asm__ __volatile__( |
| 58 | 568 | "1: ex %0, [%1] \n" |
| 59 | − : "+r" (tmp) | |
| 569 | + : "+r" (val) | |
| 60 | 570 | : "r"(&(lock->slock)) |
| 61 | 571 | : "memory"); |
| 62 | 572 | |
| 63 | 573 | smp_mb(); |
| 64 | 574 | |
| 65 | − return (tmp == __ARCH_SPIN_LOCK_UNLOCKED__); | |
| 575 | + return (val == __ARCH_SPIN_LOCK_UNLOCKED__); | |
| 66 | 576 | } |
| 67 | 577 | |
| 68 | 578 | static inline void arch_spin_unlock(arch_spinlock_t *lock) |
| 69 | 579 | { |
| 70 | − unsigned int tmp = __ARCH_SPIN_LOCK_UNLOCKED__; | |
| 580 | + unsigned int val = __ARCH_SPIN_LOCK_UNLOCKED__; | |
| 71 | 581 | |
| 72 | 582 | /* |
| 73 | 583 | * RELEASE barrier: given the instructions avail on ARCv2, full barrier |
| @@ -77,7 +587,7 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) · 3 unmodified lines | ||
| 77 | 587 | |
| 78 | 588 | __asm__ __volatile__( |
| 79 | 589 | " ex %0, [%1] \n" |
| 80 | − : "+r" (tmp) | |
| 590 | + : "+r" (val) | |
| 81 | 591 | : "r"(&(lock->slock)) |
| 82 | 592 | : "memory"); |
| 83 | 593 | |
| @@ -90,19 +600,12 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) · 6 unmodified lines | ||
| 90 | 600 | |
| 91 | 601 | /* |
| 92 | 602 | * Read-write spinlocks, allowing multiple readers but only one writer. |
| 603 | + * Unfair locking as Writers could be starved indefinitely by Reader(s) | |
| 93 | 604 | * |
| 94 | 605 | * The spinlock itself is contained in @counter and access to it is |
| 95 | 606 | * serialized with @lock_mutex. |
| 96 | − * | |
| 97 | − * Unfair locking as Writers could be starved indefinitely by Reader(s) | |
| 98 | 607 | */ |
| 99 | 608 | |
| 100 | −/* Would read_trylock() succeed? */ | |
| 101 | −#define arch_read_can_lock(x) ((x)->counter > 0) | |
| 102 | − | |
| 103 | −/* Would write_trylock() succeed? */ | |
| 104 | −#define arch_write_can_lock(x) ((x)->counter == __ARCH_RW_LOCK_UNLOCKED__) | |
| 105 | − | |
| 106 | 609 | /* 1 - lock taken successfully */ |
| 107 | 610 | static inline int arch_read_trylock(arch_rwlock_t *rw) |
| 108 | 611 | { |
| @@ -173,6 +676,11 @@ static inline void arch_write_unlock(arch_rwlock_t *rw) · 64 unmodified lines | ||
| 173 | 676 | arch_spin_unlock(&(rw->lock_mutex)); |
| 174 | 677 | } |
| 175 | 678 | |
| 679 | +#endif | |
| 680 | + | |
| 681 | +#define arch_read_can_lock(x) ((x)->counter > 0) | |
| 682 | +#define arch_write_can_lock(x) ((x)->counter == __ARCH_RW_LOCK_UNLOCKED__) | |
| 683 | + | |
| 176 | 684 | #define arch_read_lock_flags(lock, flags) arch_read_lock(lock) |
| 177 | 685 | #define arch_write_lock_flags(lock, flags) arch_write_lock(lock) |
| 178 | 686 | |
| @@ -26,7 +26,9 @@ typedef struct { · 25 unmodified lines | ||
| 26 | 26 | */ |
| 27 | 27 | typedef struct { |
| 28 | 28 | volatile unsigned int counter; |
| 29 | +#ifndef CONFIG_ARC_HAS_LLSC | |
| 29 | 30 | arch_spinlock_t lock_mutex; |
| 31 | +#endif | |
| 30 | 32 | } arch_rwlock_t; |
| 31 | 33 | |
| 32 | 34 | #define __ARCH_RW_LOCK_UNLOCKED__ 0x01000000 |
| @@ -32,20 +32,20 @@ · 31 unmodified lines | ||
| 32 | 32 | */ |
| 33 | 33 | struct user_regs_struct { |
| 34 | 34 | |
| 35 | − long pad; | |
| 35 | + unsigned long pad; | |
| 36 | 36 | struct { |
| 37 | − long bta, lp_start, lp_end, lp_count; | |
| 38 | − long status32, ret, blink, fp, gp; | |
| 39 | − long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0; | |
| 40 | − long sp; | |
| 37 | + unsigned long bta, lp_start, lp_end, lp_count; | |
| 38 | + unsigned long status32, ret, blink, fp, gp; | |
| 39 | + unsigned long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0; | |
| 40 | + unsigned long sp; | |
| 41 | 41 | } scratch; |
| 42 | − long pad2; | |
| 42 | + unsigned long pad2; | |
| 43 | 43 | struct { |
| 44 | − long r25, r24, r23, r22, r21, r20; | |
| 45 | − long r19, r18, r17, r16, r15, r14, r13; | |
| 44 | + unsigned long r25, r24, r23, r22, r21, r20; | |
| 45 | + unsigned long r19, r18, r17, r16, r15, r14, r13; | |
| 46 | 46 | } callee; |
| 47 | − long efa; /* break pt addr, for break points in delay slots */ | |
| 48 | − long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */ | |
| 47 | + unsigned long efa; /* break pt addr, for break points in delay slots */ | |
| 48 | + unsigned long stop_pc; /* give dbg stop_pc after ensuring brkpt trap */ | |
| 49 | 49 | }; |
| 50 | 50 | #endif /* !__ASSEMBLY__ */ |
| 51 | 51 | |
| @@ -47,6 +47,7 @@ static void read_arc_build_cfg_regs(void) · 46 unmodified lines | ||
| 47 | 47 | struct bcr_perip uncached_space; |
| 48 | 48 | struct bcr_generic bcr; |
| 49 | 49 | struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()]; |
| 50 | + unsigned long perip_space; | |
| 50 | 51 | FIX_PTR(cpu); |
| 51 | 52 | |
| 52 | 53 | READ_BCR(AUX_IDENTITY, cpu->core); |
| @@ -56,7 +57,12 @@ static void read_arc_build_cfg_regs(void) · 3 unmodified lines | ||
| 56 | 57 | cpu->vec_base = read_aux_reg(AUX_INTR_VEC_BASE); |
| 57 | 58 | |
| 58 | 59 | READ_BCR(ARC_REG_D_UNCACH_BCR, uncached_space); |
| 59 | − BUG_ON((uncached_space.start << 24) != ARC_UNCACHED_ADDR_SPACE); | |
| 60 | + if (uncached_space.ver < 3) | |
| 61 | + perip_space = uncached_space.start << 24; | |
| 62 | + else | |
| 63 | + perip_space = read_aux_reg(AUX_NON_VOL) & 0xF0000000; | |
| 64 | + | |
| 65 | + BUG_ON(perip_space != ARC_UNCACHED_ADDR_SPACE); | |
| 60 | 66 | |
| 61 | 67 | READ_BCR(ARC_REG_MUL_BCR, cpu->extn_mpy); |
| 62 | 68 | |
| @@ -330,6 +336,10 @@ static void arc_chk_core_config(void) · 267 unmodified lines | ||
| 330 | 336 | pr_warn("CONFIG_ARC_FPU_SAVE_RESTORE needed for working apps\n"); |
| 331 | 337 | else if (!cpu->extn.fpu_dp && fpu_enabled) |
| 332 | 338 | panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n"); |
| 339 | + | |
| 340 | + if (is_isa_arcv2() && IS_ENABLED(CONFIG_SMP) && cpu->isa.atomic && | |
| 341 | + !IS_ENABLED(CONFIG_ARC_STAR_9000923308)) | |
| 342 | + panic("llock/scond livelock workaround missing\n"); | |
| 333 | 343 | } |
| 334 | 344 | |
| 335 | 345 | /* |
| @@ -203,34 +203,24 @@ static int arc_clkevent_set_next_event(unsigned long delta, · 202 unmodified lines | ||
| 203 | 203 | return 0; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | −static void arc_clkevent_set_mode(enum clock_event_mode mode, | |
| 207 | − struct clock_event_device *dev) | |
| 206 | +static int arc_clkevent_set_periodic(struct clock_event_device *dev) | |
| 208 | 207 | { |
| 209 | − switch (mode) { | |
| 210 | − case CLOCK_EVT_MODE_PERIODIC: | |
| 211 | − /* | |
| 212 | − * At X Hz, 1 sec = 1000ms -> X cycles; | |
| 213 | − * 10ms -> X / 100 cycles | |
| 214 | − */ | |
| 215 | − arc_timer_event_setup(arc_get_core_freq() / HZ); | |
| 216 | − break; | |
| 217 | − case CLOCK_EVT_MODE_ONESHOT: | |
| 218 | − break; | |
| 219 | − default: | |
| 220 | − break; | |
| 221 | − } | |
| 222 | − | |
| 223 | − return; | |
| 208 | + /* | |
| 209 | + * At X Hz, 1 sec = 1000ms -> X cycles; | |
| 210 | + * 10ms -> X / 100 cycles | |
| 211 | + */ | |
| 212 | + arc_timer_event_setup(arc_get_core_freq() / HZ); | |
| 213 | + return 0; | |
| 224 | 214 | } |
| 225 | 215 | |
| 226 | 216 | static DEFINE_PER_CPU(struct clock_event_device, arc_clockevent_device) = { |
| 227 | − .name = "ARC Timer0", | |
| 228 | − .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC, | |
| 229 | − .mode = CLOCK_EVT_MODE_UNUSED, | |
| 230 | − .rating = 300, | |
| 231 | − .irq = TIMER0_IRQ, /* hardwired, no need for resources */ | |
| 232 | − .set_next_event = arc_clkevent_set_next_event, | |
| 233 | − .set_mode = arc_clkevent_set_mode, | |
| 217 | + .name = "ARC Timer0", | |
| 218 | + .features = CLOCK_EVT_FEAT_ONESHOT | | |
| 219 | + CLOCK_EVT_FEAT_PERIODIC, | |
| 220 | + .rating = 300, | |
| 221 | + .irq = TIMER0_IRQ, /* hardwired, no need for resources */ | |
| 222 | + .set_next_event = arc_clkevent_set_next_event, | |
| 223 | + .set_state_periodic = arc_clkevent_set_periodic, | |
| 234 | 224 | }; |
| 235 | 225 | |
| 236 | 226 | static irqreturn_t timer_irq_handler(int irq, void *dev_id) |
| @@ -240,7 +230,7 @@ static irqreturn_t timer_irq_handler(int irq, void *dev_id) · 3 unmodified lines | ||
| 240 | 230 | * irq_set_chip_and_handler() asked for handle_percpu_devid_irq() |
| 241 | 231 | */ |
| 242 | 232 | struct clock_event_device *evt = this_cpu_ptr(&arc_clockevent_device); |
| 243 | − int irq_reenable = evt->mode == CLOCK_EVT_MODE_PERIODIC; | |
| 233 | + int irq_reenable = clockevent_state_periodic(evt); | |
| 244 | 234 | |
| 245 | 235 | /* |
| 246 | 236 | * Any write to CTRL reg ACks the interrupt, we rewrite the |
| @@ -206,7 +206,7 @@ unalignedOffby3: · 205 unmodified lines | ||
| 206 | 206 | ld.ab r6, [r1, 4] |
| 207 | 207 | prefetch [r1, 28] ;Prefetch the next read location |
| 208 | 208 | ld.ab r8, [r1,4] |
| 209 | − prefetch [r3, 32] ;Prefetch the next write location | |
| 209 | + prefetchw [r3, 32] ;Prefetch the next write location | |
| 210 | 210 | |
| 211 | 211 | SHIFT_1 (r7, r6, 8) |
| 212 | 212 | or r7, r7, r5 |
| @@ -10,12 +10,6 @@ · 9 unmodified lines | ||
| 10 | 10 | |
| 11 | 11 | #undef PREALLOC_NOT_AVAIL |
| 12 | 12 | |
| 13 | −#ifdef PREALLOC_NOT_AVAIL | |
| 14 | −#define PREWRITE(A,B) prefetchw [(A),(B)] | |
| 15 | −#else | |
| 16 | −#define PREWRITE(A,B) prealloc [(A),(B)] | |
| 17 | −#endif | |
| 18 | − | |
| 19 | 13 | ENTRY(memset) |
| 20 | 14 | prefetchw [r0] ; Prefetch the write location |
| 21 | 15 | mov.f 0, r2 |
| @@ -51,9 +45,15 @@ ENTRY(memset) · 29 unmodified lines | ||
| 51 | 45 | |
| 52 | 46 | ;;; Convert len to Dwords, unfold x8 |
| 53 | 47 | lsr.f lp_count, lp_count, 6 |
| 48 | + | |
| 54 | 49 | lpnz @.Lset64bytes |
| 55 | 50 | ;; LOOP START |
| 56 | − PREWRITE(r3, 64) ;Prefetch the next write location | |
| 51 | +#ifdef PREALLOC_NOT_AVAIL | |
| 52 | + prefetchw [r3, 64] ;Prefetch the next write location | |
| 53 | +#else | |
| 54 | + prealloc [r3, 64] | |
| 55 | +#endif | |
| 56 | +#ifdef CONFIG_ARC_HAS_LL64 | |
| 57 | 57 | std.ab r4, [r3, 8] |
| 58 | 58 | std.ab r4, [r3, 8] |
| 59 | 59 | std.ab r4, [r3, 8] |
| @@ -62,16 +62,45 @@ ENTRY(memset) · 2 unmodified lines | ||
| 62 | 62 | std.ab r4, [r3, 8] |
| 63 | 63 | std.ab r4, [r3, 8] |
| 64 | 64 | std.ab r4, [r3, 8] |
| 65 | +#else | |
| 66 | + st.ab r4, [r3, 4] | |
| 67 | + st.ab r4, [r3, 4] | |
| 68 | + st.ab r4, [r3, 4] | |
| 69 | + st.ab r4, [r3, 4] | |
| 70 | + st.ab r4, [r3, 4] | |
| 71 | + st.ab r4, [r3, 4] | |
| 72 | + st.ab r4, [r3, 4] | |
| 73 | + st.ab r4, [r3, 4] | |
| 74 | + st.ab r4, [r3, 4] | |
| 75 | + st.ab r4, [r3, 4] | |
| 76 | + st.ab r4, [r3, 4] | |
| 77 | + st.ab r4, [r3, 4] | |
| 78 | + st.ab r4, [r3, 4] | |
| 79 | + st.ab r4, [r3, 4] | |
| 80 | + st.ab r4, [r3, 4] | |
| 81 | + st.ab r4, [r3, 4] | |
| 82 | +#endif | |
| 65 | 83 | .Lset64bytes: |
| 66 | 84 | |
| 67 | 85 | lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes |
| 68 | 86 | lpnz .Lset32bytes |
| 69 | 87 | ;; LOOP START |
| 70 | 88 | prefetchw [r3, 32] ;Prefetch the next write location |
| 89 | +#ifdef CONFIG_ARC_HAS_LL64 | |
| 71 | 90 | std.ab r4, [r3, 8] |
| 72 | 91 | std.ab r4, [r3, 8] |
| 73 | 92 | std.ab r4, [r3, 8] |
| 74 | 93 | std.ab r4, [r3, 8] |
| 94 | +#else | |
| 95 | + st.ab r4, [r3, 4] | |
| 96 | + st.ab r4, [r3, 4] | |
| 97 | + st.ab r4, [r3, 4] | |
| 98 | + st.ab r4, [r3, 4] | |
| 99 | + st.ab r4, [r3, 4] | |
| 100 | + st.ab r4, [r3, 4] | |
| 101 | + st.ab r4, [r3, 4] | |
| 102 | + st.ab r4, [r3, 4] | |
| 103 | +#endif | |
| 75 | 104 | .Lset32bytes: |
| 76 | 105 | |
| 77 | 106 | and.f lp_count, r2, 0x1F ;Last remaining 31 bytes |
| @@ -389,6 +389,21 @@ axs103_set_freq(unsigned int id, unsigned int fd, unsigned int od) · 388 unmodified lines | ||
| 389 | 389 | |
| 390 | 390 | static void __init axs103_early_init(void) |
| 391 | 391 | { |
| 392 | + /* | |
| 393 | + * AXS103 configurations for SMP/QUAD configurations share device tree | |
| 394 | + * which defaults to 90 MHz. However recent failures of Quad config | |
| 395 | + * revealed P&R timing violations so clamp it down to safe 50 MHz | |
| 396 | + * Instead of duplicating defconfig/DT for SMP/QUAD, add a small hack | |
| 397 | + * | |
| 398 | + * This hack is really hacky as of now. Fix it properly by getting the | |
| 399 | + * number of cores as return value of platform's early SMP callback | |
| 400 | + */ | |
| 401 | +#ifdef CONFIG_ARC_MCIP | |
| 402 | + unsigned int num_cores = (read_aux_reg(ARC_REG_MCIP_BCR) >> 16) & 0x3F; | |
| 403 | + if (num_cores > 2) | |
| 404 | + arc_set_core_freq(50 * 1000000); | |
| 405 | +#endif | |
| 406 | + | |
| 392 | 407 | switch (arc_get_core_freq()/1000000) { |
| 393 | 408 | case 33: |
| 394 | 409 | axs103_set_freq(1, 1, 1); |
| @@ -1140,6 +1140,7 @@ · 1139 unmodified lines | ||
| 1140 | 1140 | ctrl-module = <&omap_control_sata>; |
| 1141 | 1141 | clocks = <&sys_clkin1>, <&sata_ref_clk>; |
| 1142 | 1142 | clock-names = "sysclk", "refclk"; |
| 1143 | + syscon-pllreset = <&scm_conf 0x3fc>; | |
| 1143 | 1144 | #phy-cells = <0>; |
| 1144 | 1145 | }; |
| 1145 | 1146 | |
| @@ -138,8 +138,8 @@ · 137 unmodified lines | ||
| 138 | 138 | |
| 139 | 139 | mipi_phy: video-phy@10020710 { |
| 140 | 140 | compatible = "samsung,s5pv210-mipi-video-phy"; |
| 141 | − reg = <0x10020710 8>; | |
| 142 | 141 | #phy-cells = <1>; |
| 142 | + syscon = <&pmu_system_controller>; | |
| 143 | 143 | }; |
| 144 | 144 | |
| 145 | 145 | pd_cam: cam-power-domain@10023C00 { |
| @@ -127,6 +127,10 @@ · 126 unmodified lines | ||
| 127 | 127 | }; |
| 128 | 128 | }; |
| 129 | 129 | |
| 130 | +&cpu0 { | |
| 131 | + cpu0-supply = <&buck1_reg>; | |
| 132 | +}; | |
| 133 | + | |
| 130 | 134 | &fimd { |
| 131 | 135 | pinctrl-0 = <&lcd_en &lcd_clk &lcd_data24 &pwm0_out>; |
| 132 | 136 | pinctrl-names = "default"; |
| @@ -188,6 +188,10 @@ · 187 unmodified lines | ||
| 188 | 188 | }; |
| 189 | 189 | }; |
| 190 | 190 | |
| 191 | +&cpu0 { | |
| 192 | + cpu0-supply = <&varm_breg>; | |
| 193 | +}; | |
| 194 | + | |
| 191 | 195 | &dsi_0 { |
| 192 | 196 | vddcore-supply = <&vusb_reg>; |
| 193 | 197 | vddio-supply = <&vmipi_reg>; |
| @@ -548,6 +548,10 @@ · 547 unmodified lines | ||
| 548 | 548 | }; |
| 549 | 549 | }; |
| 550 | 550 | |
| 551 | +&cpu0 { | |
| 552 | + cpu0-supply = <&vdd_arm_reg>; | |
| 553 | +}; | |
| 554 | + | |
| 551 | 555 | &pinctrl_1 { |
| 552 | 556 | hdmi_hpd: hdmi-hpd { |
| 553 | 557 | samsung,pins = "gpx3-7"; |
| @@ -40,6 +40,18 @@ · 39 unmodified lines | ||
| 40 | 40 | device_type = "cpu"; |
| 41 | 41 | compatible = "arm,cortex-a9"; |
| 42 | 42 | reg = <0x900>; |
| 43 | + clocks = <&clock CLK_ARM_CLK>; | |
| 44 | + clock-names = "cpu"; | |
| 45 | + clock-latency = <160000>; | |
| 46 | + | |
| 47 | + operating-points = < | |
| 48 | + 1200000 1250000 | |
| 49 | + 1000000 1150000 | |
| 50 | + 800000 1075000 | |
| 51 | + 500000 975000 | |
| 52 | + 400000 975000 | |
| 53 | + 200000 950000 | |
| 54 | + >; | |
| 43 | 55 | cooling-min-level = <4>; |
| 44 | 56 | cooling-max-level = <2>; |
| 45 | 57 | #cooling-cells = <2>; /* min followed by max */ |
| @@ -286,8 +286,8 @@ · 285 unmodified lines | ||
| 286 | 286 | can1: can@53fe4000 { |
| 287 | 287 | compatible = "fsl,imx35-flexcan", "fsl,p1010-flexcan"; |
| 288 | 288 | reg = <0x53fe4000 0x1000>; |
| 289 | − clocks = <&clks 33>; | |
| 290 | − clock-names = "ipg"; | |
| 289 | + clocks = <&clks 33>, <&clks 33>; | |
| 290 | + clock-names = "ipg", "per"; | |
| 291 | 291 | interrupts = <43>; |
| 292 | 292 | status = "disabled"; |
| 293 | 293 | }; |
| @@ -295,8 +295,8 @@ · 1 unmodified line | ||
| 295 | 295 | can2: can@53fe8000 { |
| 296 | 296 | compatible = "fsl,imx35-flexcan", "fsl,p1010-flexcan"; |
| 297 | 297 | reg = <0x53fe8000 0x1000>; |
| 298 | − clocks = <&clks 34>; | |
| 299 | − clock-names = "ipg"; | |
| 298 | + clocks = <&clks 34>, <&clks 34>; | |
| 299 | + clock-names = "ipg", "per"; | |
| 300 | 300 | interrupts = <44>; |
| 301 | 301 | status = "disabled"; |
| 302 | 302 | }; |
| @@ -13,9 +13,8 @@ clocks { · 12 unmodified lines | ||
| 13 | 13 | #clock-cells = <0>; |
| 14 | 14 | compatible = "ti,keystone,main-pll-clock"; |
| 15 | 15 | clocks = <&refclksys>; |
| 16 | − reg = <0x02620350 4>, <0x02310110 4>; | |
| 17 | − reg-names = "control", "multiplier"; | |
| 18 | − fixed-postdiv = <2>; | |
| 16 | + reg = <0x02620350 4>, <0x02310110 4>, <0x02310108 4>; | |
| 17 | + reg-names = "control", "multiplier", "post-divider"; | |
| 19 | 18 | }; |
| 20 | 19 | |
| 21 | 20 | papllclk: papllclk@2620358 { |
| @@ -22,9 +22,8 @@ clocks { · 21 unmodified lines | ||
| 22 | 22 | #clock-cells = <0>; |
| 23 | 23 | compatible = "ti,keystone,main-pll-clock"; |
| 24 | 24 | clocks = <&refclksys>; |
| 25 | − reg = <0x02620350 4>, <0x02310110 4>; | |
| 26 | − reg-names = "control", "multiplier"; | |
| 27 | − fixed-postdiv = <2>; | |
| 25 | + reg = <0x02620350 4>, <0x02310110 4>, <0x02310108 4>; | |
| 26 | + reg-names = "control", "multiplier", "post-divider"; | |
| 28 | 27 | }; |
| 29 | 28 | |
| 30 | 29 | papllclk: papllclk@2620358 { |
| @@ -22,9 +22,8 @@ clocks { · 21 unmodified lines | ||
| 22 | 22 | #clock-cells = <0>; |
| 23 | 23 | compatible = "ti,keystone,main-pll-clock"; |
| 24 | 24 | clocks = <&refclksys>; |
| 25 | − reg = <0x02620350 4>, <0x02310110 4>; | |
| 26 | − reg-names = "control", "multiplier"; | |
| 27 | − fixed-postdiv = <2>; | |
| 25 | + reg = <0x02620350 4>, <0x02310110 4>, <0x02310108 4>; | |
| 26 | + reg-names = "control", "multiplier", "post-divider"; | |
| 28 | 27 | }; |
| 29 | 28 | |
| 30 | 29 | papllclk: papllclk@2620358 { |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | ||
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | 19 | aliases { |
| 20 | + serial1 = &uart1; | |
| 20 | 21 | stmpe-i2c0 = &stmpe0; |
| 21 | 22 | stmpe-i2c1 = &stmpe1; |
| 22 | 23 | }; |
| @@ -15,6 +15,10 @@ · 14 unmodified lines | ||
| 15 | 15 | bootargs = "root=/dev/ram0 console=ttyAMA1,115200n8 earlyprintk"; |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | + aliases { | |
| 19 | + serial1 = &uart1; | |
| 20 | + }; | |
| 21 | + | |
| 18 | 22 | src@101e0000 { |
| 19 | 23 | /* These chrystal drivers are not used on this board */ |
| 20 | 24 | disable-sxtalo; |
| @@ -757,6 +757,7 @@ · 756 unmodified lines | ||
| 757 | 757 | clock-names = "uartclk", "apb_pclk"; |
| 758 | 758 | pinctrl-names = "default"; |
| 759 | 759 | pinctrl-0 = <&uart0_default_mux>; |
| 760 | + status = "disabled"; | |
| 760 | 761 | }; |
| 761 | 762 | |
| 762 | 763 | uart1: uart@101fb000 { |
| @@ -2373,6 +2373,9 @@ static int of_dev_hwmod_lookup(struct device_node *np, · 2372 unmodified lines | ||
| 2373 | 2373 | * registers. This address is needed early so the OCP registers that |
| 2374 | 2374 | * are part of the device's address space can be ioremapped properly. |
| 2375 | 2375 | * |
| 2376 | + * If SYSC access is not needed, the registers will not be remapped | |
| 2377 | + * and non-availability of MPU access is not treated as an error. | |
| 2378 | + * | |
| 2376 | 2379 | * Returns 0 on success, -EINVAL if an invalid hwmod is passed, and |
| 2377 | 2380 | * -ENXIO on absent or invalid register target address space. |
| 2378 | 2381 | */ |
| @@ -2387,6 +2390,11 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, · 8 unmodified lines | ||
| 2387 | 2390 | |
| 2388 | 2391 | _save_mpu_port_index(oh); |
| 2389 | 2392 | |
| 2393 | + /* if we don't need sysc access we don't need to ioremap */ | |
| 2394 | + if (!oh->class->sysc) | |
| 2395 | + return 0; | |
| 2396 | + | |
| 2397 | + /* we can't continue without MPU PORT if we need sysc access */ | |
| 2390 | 2398 | if (oh->_int_flags & _HWMOD_NO_MPU_PORT) |
| 2391 | 2399 | return -ENXIO; |
| 2392 | 2400 | |
| @@ -2396,8 +2404,10 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, · 3 unmodified lines | ||
| 2396 | 2404 | oh->name); |
| 2397 | 2405 | |
| 2398 | 2406 | /* Extract the IO space from device tree blob */ |
| 2399 | − if (!np) | |
| 2407 | + if (!np) { | |
| 2408 | + pr_err("omap_hwmod: %s: no dt node\n", oh->name); | |
| 2400 | 2409 | return -ENXIO; |
| 2410 | + } | |
| 2401 | 2411 | |
| 2402 | 2412 | va_start = of_iomap(np, index + oh->mpu_rt_idx); |
| 2403 | 2413 | } else { |
| @@ -2456,13 +2466,11 @@ static int __init _init(struct omap_hwmod *oh, void *data) · 52 unmodified lines | ||
| 2456 | 2466 | oh->name, np->name); |
| 2457 | 2467 | } |
| 2458 | 2468 | |
| 2459 | − if (oh->class->sysc) { | |
| 2460 | − r = _init_mpu_rt_base(oh, NULL, index, np); | |
| 2461 | − if (r < 0) { | |
| 2462 | − WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n", | |
| 2463 | − oh->name); | |
| 2464 | − return 0; | |
| 2465 | − } | |
| 2469 | + r = _init_mpu_rt_base(oh, NULL, index, np); | |
| 2470 | + if (r < 0) { | |
| 2471 | + WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n", | |
| 2472 | + oh->name); | |
| 2473 | + return 0; | |
| 2466 | 2474 | } |
| 2467 | 2475 | |
| 2468 | 2476 | r = _init_clocks(oh, NULL); |
| @@ -827,8 +827,7 @@ static struct omap_hwmod_class_sysconfig dra7xx_gpmc_sysc = { · 826 unmodified lines | ||
| 827 | 827 | .syss_offs = 0x0014, |
| 828 | 828 | .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_SIDLEMODE | |
| 829 | 829 | SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS), |
| 830 | − .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | | |
| 831 | − SIDLE_SMART_WKUP), | |
| 830 | + .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART), | |
| 832 | 831 | .sysc_fields = &omap_hwmod_sysc_type1, |
| 833 | 832 | }; |
| 834 | 833 | |
| @@ -844,7 +843,7 @@ static struct omap_hwmod dra7xx_gpmc_hwmod = { · 9 unmodified lines | ||
| 844 | 843 | .class = &dra7xx_gpmc_hwmod_class, |
| 845 | 844 | .clkdm_name = "l3main1_clkdm", |
| 846 | 845 | /* Skip reset for CONFIG_OMAP_GPMC_DEBUG for bootloader timings */ |
| 847 | − .flags = HWMOD_SWSUP_SIDLE | DEBUG_OMAP_GPMC_HWMOD_FLAGS, | |
| 846 | + .flags = DEBUG_OMAP_GPMC_HWMOD_FLAGS, | |
| 848 | 847 | .main_clk = "l3_iclk_div", |
| 849 | 848 | .prcm = { |
| 850 | 849 | .omap4 = { |
| @@ -823,7 +823,7 @@ · 822 unmodified lines | ||
| 823 | 823 | device_type = "dma"; |
| 824 | 824 | reg = <0x0 0x1f270000 0x0 0x10000>, |
| 825 | 825 | <0x0 0x1f200000 0x0 0x10000>, |
| 826 | − <0x0 0x1b008000 0x0 0x2000>, | |
| 826 | + <0x0 0x1b000000 0x0 0x400000>, | |
| 827 | 827 | <0x0 0x1054a000 0x0 0x100>; |
| 828 | 828 | interrupts = <0x0 0x82 0x4>, |
| 829 | 829 | <0x0 0xb8 0x4>, |
| @@ -168,7 +168,8 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) · 167 unmodified lines | ||
| 168 | 168 | * Other callers might not initialize the si_lsb field, |
| 169 | 169 | * so check explicitely for the right codes here. |
| 170 | 170 | */ |
| 171 | − if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO) | |
| 171 | + if (from->si_signo == SIGBUS && | |
| 172 | + (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)) | |
| 172 | 173 | err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); |
| 173 | 174 | #endif |
| 174 | 175 | break; |
| @@ -201,8 +202,6 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) · 26 unmodified lines | ||
| 201 | 202 | |
| 202 | 203 | int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) |
| 203 | 204 | { |
| 204 | − memset(to, 0, sizeof *to); | |
| 205 | − | |
| 206 | 205 | if (copy_from_user(to, from, __ARCH_SI_PREAMBLE_SIZE) || |
| 207 | 206 | copy_from_user(to->_sifields._pad, |
| 208 | 207 | from->_sifields._pad, SI_PAD_SIZE)) |
| @@ -199,16 +199,15 @@ up_fail: · 198 unmodified lines | ||
| 199 | 199 | */ |
| 200 | 200 | void update_vsyscall(struct timekeeper *tk) |
| 201 | 201 | { |
| 202 | − struct timespec xtime_coarse; | |
| 203 | 202 | u32 use_syscall = strcmp(tk->tkr_mono.clock->name, "arch_sys_counter"); |
| 204 | 203 | |
| 205 | 204 | ++vdso_data->tb_seq_count; |
| 206 | 205 | smp_wmb(); |
| 207 | 206 | |
| 208 | − xtime_coarse = __current_kernel_time(); | |
| 209 | 207 | vdso_data->use_syscall = use_syscall; |
| 210 | − vdso_data->xtime_coarse_sec = xtime_coarse.tv_sec; | |
| 211 | − vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec; | |
| 208 | + vdso_data->xtime_coarse_sec = tk->xtime_sec; | |
| 209 | + vdso_data->xtime_coarse_nsec = tk->tkr_mono.xtime_nsec >> | |
| 210 | + tk->tkr_mono.shift; | |
| 212 | 211 | vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec; |
| 213 | 212 | vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec; |
| 214 | 213 | |
| @@ -151,7 +151,6 @@ config BMIPS_GENERIC · 150 unmodified lines | ||
| 151 | 151 | select BCM7120_L2_IRQ |
| 152 | 152 | select BRCMSTB_L2_IRQ |
| 153 | 153 | select IRQ_MIPS_CPU |
| 154 | − select RAW_IRQ_ACCESSORS | |
| 155 | 154 | select DMA_NONCOHERENT |
| 156 | 155 | select SYS_SUPPORTS_32BIT_KERNEL |
| 157 | 156 | select SYS_SUPPORTS_LITTLE_ENDIAN |
| @@ -190,6 +190,7 @@ int get_c0_perfcount_int(void) · 189 unmodified lines | ||
| 190 | 190 | { |
| 191 | 191 | return ATH79_MISC_IRQ(5); |
| 192 | 192 | } |
| 193 | +EXPORT_SYMBOL_GPL(get_c0_perfcount_int); | |
| 193 | 194 | |
| 194 | 195 | unsigned int get_c0_compare_int(void) |
| 195 | 196 | { |
| @@ -42,7 +42,7 @@ static irqreturn_t mailbox_interrupt(int irq, void *dev_id) · 41 unmodified lines | ||
| 42 | 42 | cvmx_write_csr(CVMX_CIU_MBOX_CLRX(coreid), action); |
| 43 | 43 | |
| 44 | 44 | if (action & SMP_CALL_FUNCTION) |
| 45 | − smp_call_function_interrupt(); | |
| 45 | + generic_smp_call_function_interrupt(); | |
| 46 | 46 | if (action & SMP_RESCHEDULE_YOURSELF) |
| 47 | 47 | scheduler_ipi(); |
| 48 | 48 | |
| @@ -1,10 +0,0 @@ | ||
| 1 | −#ifndef __ASM_MACH_BCM63XX_DMA_COHERENCE_H | |
| 2 | −#define __ASM_MACH_BCM63XX_DMA_COHERENCE_H | |
| 3 | − | |
| 4 | −#include <asm/bmips.h> | |
| 5 | − | |
| 6 | −#define plat_post_dma_flush bmips_post_dma_flush | |
| 7 | − | |
| 8 | −#include <asm/mach-generic/dma-coherence.h> | |
| 9 | − | |
| 10 | −#endif /* __ASM_MACH_BCM63XX_DMA_COHERENCE_H */ | |
| @@ -182,8 +182,39 @@ static inline void set_pte(pte_t *ptep, pte_t pteval) · 181 unmodified lines | ||
| 182 | 182 | * Make sure the buddy is global too (if it's !none, |
| 183 | 183 | * it better already be global) |
| 184 | 184 | */ |
| 185 | +#ifdef CONFIG_SMP | |
| 186 | + /* | |
| 187 | + * For SMP, multiple CPUs can race, so we need to do | |
| 188 | + * this atomically. | |
| 189 | + */ | |
| 190 | +#ifdef CONFIG_64BIT | |
| 191 | +#define LL_INSN "lld" | |
| 192 | +#define SC_INSN "scd" | |
| 193 | +#else /* CONFIG_32BIT */ | |
| 194 | +#define LL_INSN "ll" | |
| 195 | +#define SC_INSN "sc" | |
| 196 | +#endif | |
| 197 | + unsigned long page_global = _PAGE_GLOBAL; | |
| 198 | + unsigned long tmp; | |
| 199 | + | |
| 200 | + __asm__ __volatile__ ( | |
| 201 | + " .set push\n" | |
| 202 | + " .set noreorder\n" | |
| 203 | + "1: " LL_INSN " %[tmp], %[buddy]\n" | |
| 204 | + " bnez %[tmp], 2f\n" | |
| 205 | + " or %[tmp], %[tmp], %[global]\n" | |
| 206 | + " " SC_INSN " %[tmp], %[buddy]\n" | |
| 207 | + " beqz %[tmp], 1b\n" | |
| 208 | + " nop\n" | |
| 209 | + "2:\n" | |
| 210 | + " .set pop" | |
| 211 | + : [buddy] "+m" (buddy->pte), | |
| 212 | + [tmp] "=&r" (tmp) | |
| 213 | + : [global] "r" (page_global)); | |
| 214 | +#else /* !CONFIG_SMP */ | |
| 185 | 215 | if (pte_none(*buddy)) |
| 186 | 216 | pte_val(*buddy) = pte_val(*buddy) | _PAGE_GLOBAL; |
| 217 | +#endif /* CONFIG_SMP */ | |
| 187 | 218 | } |
| 188 | 219 | #endif |
| 189 | 220 | } |
| @@ -83,8 +83,6 @@ static inline void __cpu_die(unsigned int cpu) · 82 unmodified lines | ||
| 83 | 83 | extern void play_dead(void); |
| 84 | 84 | #endif |
| 85 | 85 | |
| 86 | −extern asmlinkage void smp_call_function_interrupt(void); | |
| 87 | − | |
| 88 | 86 | static inline void arch_send_call_function_single_ipi(int cpu) |
| 89 | 87 | { |
| 90 | 88 | extern struct plat_smp_ops *mp_ops; /* private */ |
| @@ -152,6 +152,31 @@ · 151 unmodified lines | ||
| 152 | 152 | .set noreorder |
| 153 | 153 | bltz k0, 8f |
| 154 | 154 | move k1, sp |
| 155 | +#ifdef CONFIG_EVA | |
| 156 | + /* | |
| 157 | + * Flush interAptiv's Return Prediction Stack (RPS) by writing | |
| 158 | + * EntryHi. Toggling Config7.RPS is slower and less portable. | |
| 159 | + * | |
| 160 | + * The RPS isn't automatically flushed when exceptions are | |
| 161 | + * taken, which can result in kernel mode speculative accesses | |
| 162 | + * to user addresses if the RPS mispredicts. That's harmless | |
| 163 | + * when user and kernel share the same address space, but with | |
| 164 | + * EVA the same user segments may be unmapped to kernel mode, | |
| 165 | + * even containing sensitive MMIO regions or invalid memory. | |
| 166 | + * | |
| 167 | + * This can happen when the kernel sets the return address to | |
| 168 | + * ret_from_* and jr's to the exception handler, which looks | |
| 169 | + * more like a tail call than a function call. If nested calls | |
| 170 | + * don't evict the last user address in the RPS, it will | |
| 171 | + * mispredict the return and fetch from a user controlled | |
| 172 | + * address into the icache. | |
| 173 | + * | |
| 174 | + * More recent EVA-capable cores with MAAR to restrict | |
| 175 | + * speculative accesses aren't affected. | |
| 176 | + */ | |
| 177 | + MFC0 k0, CP0_ENTRYHI | |
| 178 | + MTC0 k0, CP0_ENTRYHI | |
| 179 | +#endif | |
| 155 | 180 | .set reorder |
| 156 | 181 | /* Called from user mode, new stack. */ |
| 157 | 182 | get_saved_sp |
| @@ -154,7 +154,7 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, · 153 unmodified lines | ||
| 154 | 154 | unsigned long __user *user_mask_ptr) |
| 155 | 155 | { |
| 156 | 156 | unsigned int real_len; |
| 157 | − cpumask_t mask; | |
| 157 | + cpumask_t allowed, mask; | |
| 158 | 158 | int retval; |
| 159 | 159 | struct task_struct *p; |
| 160 | 160 | |
| @@ -173,7 +173,8 @@ asmlinkage long mipsmt_sys_sched_getaffinity(pid_t pid, unsigned int len, · 12 unmodified lines | ||
| 173 | 173 | if (retval) |
| 174 | 174 | goto out_unlock; |
| 175 | 175 | |
| 176 | − cpumask_and(&mask, &p->thread.user_cpus_allowed, cpu_possible_mask); | |
| 176 | + cpumask_or(&allowed, &p->thread.user_cpus_allowed, &p->cpus_allowed); | |
| 177 | + cpumask_and(&mask, &allowed, cpu_active_mask); | |
| 177 | 178 | |
| 178 | 179 | out_unlock: |
| 179 | 180 | read_unlock(&tasklist_lock); |
| @@ -38,7 +38,7 @@ char *mips_get_machine_name(void) · 37 unmodified lines | ||
| 38 | 38 | return mips_machine_name; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | −#ifdef CONFIG_OF | |
| 41 | +#ifdef CONFIG_USE_OF | |
| 42 | 42 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) |
| 43 | 43 | { |
| 44 | 44 | return add_memory_region(base, size, BOOT_MEM_RAM); |
| @@ -24,7 +24,7 @@ LEAF(relocate_new_kernel) · 23 unmodified lines | ||
| 24 | 24 | |
| 25 | 25 | process_entry: |
| 26 | 26 | PTR_L s2, (s0) |
| 27 | − PTR_ADD s0, s0, SZREG | |
| 27 | + PTR_ADDIU s0, s0, SZREG | |
| 28 | 28 | |
| 29 | 29 | /* |
| 30 | 30 | * In case of a kdump/crash kernel, the indirection page is not |
| @@ -61,9 +61,9 @@ copy_word: · 30 unmodified lines | ||
| 61 | 61 | /* copy page word by word */ |
| 62 | 62 | REG_L s5, (s2) |
| 63 | 63 | REG_S s5, (s4) |
| 64 | − PTR_ADD s4, s4, SZREG | |
| 65 | − PTR_ADD s2, s2, SZREG | |
| 66 | − LONG_SUB s6, s6, 1 | |
| 64 | + PTR_ADDIU s4, s4, SZREG | |
| 65 | + PTR_ADDIU s2, s2, SZREG | |
| 66 | + LONG_ADDIU s6, s6, -1 | |
| 67 | 67 | beq s6, zero, process_entry |
| 68 | 68 | b copy_word |
| 69 | 69 | b process_entry |
| @@ -409,8 +409,6 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from) · 408 unmodified lines | ||
| 409 | 409 | |
| 410 | 410 | int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) |
| 411 | 411 | { |
| 412 | − memset(to, 0, sizeof *to); | |
| 413 | − | |
| 414 | 412 | if (copy_from_user(to, from, 3*sizeof(int)) || |
| 415 | 413 | copy_from_user(to->_sifields._pad, |
| 416 | 414 | from->_sifields._pad, SI_PAD_SIZE32)) |
| @@ -284,7 +284,7 @@ static irqreturn_t bmips5000_ipi_interrupt(int irq, void *dev_id) · 283 unmodified lines | ||
| 284 | 284 | if (action == 0) |
| 285 | 285 | scheduler_ipi(); |
| 286 | 286 | else |
| 287 | − smp_call_function_interrupt(); | |
| 287 | + generic_smp_call_function_interrupt(); | |
| 288 | 288 | |
| 289 | 289 | return IRQ_HANDLED; |
| 290 | 290 | } |
| @@ -336,7 +336,7 @@ static irqreturn_t bmips43xx_ipi_interrupt(int irq, void *dev_id) · 45 unmodified lines | ||
| 336 | 336 | if (action & SMP_RESCHEDULE_YOURSELF) |
| 337 | 337 | scheduler_ipi(); |
| 338 | 338 | if (action & SMP_CALL_FUNCTION) |
| 339 | − smp_call_function_interrupt(); | |
| 339 | + generic_smp_call_function_interrupt(); | |
| 340 | 340 | |
| 341 | 341 | return IRQ_HANDLED; |
| 342 | 342 | } |
| @@ -192,16 +192,6 @@ asmlinkage void start_secondary(void) · 191 unmodified lines | ||
| 192 | 192 | cpu_startup_entry(CPUHP_ONLINE); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | −/* | |
| 196 | − * Call into both interrupt handlers, as we share the IPI for them | |
| 197 | − */ | |
| 198 | −void __irq_entry smp_call_function_interrupt(void) | |
| 199 | −{ | |
| 200 | − irq_enter(); | |
| 201 | − generic_smp_call_function_interrupt(); | |
| 202 | − irq_exit(); | |
| 203 | −} | |
| 204 | − | |
| 205 | 195 | static void stop_this_cpu(void *dummy) |
| 206 | 196 | { |
| 207 | 197 | /* |
| @@ -192,6 +192,7 @@ static void show_stacktrace(struct task_struct *task, · 191 unmodified lines | ||
| 192 | 192 | void show_stack(struct task_struct *task, unsigned long *sp) |
| 193 | 193 | { |
| 194 | 194 | struct pt_regs regs; |
| 195 | + mm_segment_t old_fs = get_fs(); | |
| 195 | 196 | if (sp) { |
| 196 | 197 | regs.regs[29] = (unsigned long)sp; |
| 197 | 198 | regs.regs[31] = 0; |
| @@ -210,7 +211,13 @@ void show_stack(struct task_struct *task, unsigned long *sp) · 12 unmodified lines | ||
| 210 | 211 | prepare_frametrace(®s); |
| 211 | 212 | } |
| 212 | 213 | } |
| 214 | + /* | |
| 215 | + * show_stack() deals exclusively with kernel mode, so be sure to access | |
| 216 | + * the stack in the kernel (not user) address space. | |
| 217 | + */ | |
| 218 | + set_fs(KERNEL_DS); | |
| 213 | 219 | show_stacktrace(task, ®s); |
| 220 | + set_fs(old_fs); | |
| 214 | 221 | } |
| 215 | 222 | |
| 216 | 223 | static void show_code(unsigned int __user *pc) |
| @@ -1519,6 +1526,7 @@ asmlinkage void do_mcheck(struct pt_regs *regs) · 1302 unmodified lines | ||
| 1519 | 1526 | const int field = 2 * sizeof(unsigned long); |
| 1520 | 1527 | int multi_match = regs->cp0_status & ST0_TS; |
| 1521 | 1528 | enum ctx_state prev_state; |
| 1529 | + mm_segment_t old_fs = get_fs(); | |
| 1522 | 1530 | |
| 1523 | 1531 | prev_state = exception_enter(); |
| 1524 | 1532 | show_regs(regs); |
| @@ -1540,8 +1548,13 @@ asmlinkage void do_mcheck(struct pt_regs *regs) · 15 unmodified lines | ||
| 1540 | 1548 | dump_tlb_all(); |
| 1541 | 1549 | } |
| 1542 | 1550 | |
| 1551 | + if (!user_mode(regs)) | |
| 1552 | + set_fs(KERNEL_DS); | |
| 1553 | + | |
| 1543 | 1554 | show_code((unsigned int __user *) regs->cp0_epc); |
| 1544 | 1555 | |
| 1556 | + set_fs(old_fs); | |
| 1557 | + | |
| 1545 | 1558 | /* |
| 1546 | 1559 | * Some chips may have other causes of machine check (e.g. SB1 |
| 1547 | 1560 | * graduation timer) |
| @@ -438,7 +438,7 @@ do { \ · 437 unmodified lines | ||
| 438 | 438 | : "memory"); \ |
| 439 | 439 | } while(0) |
| 440 | 440 | |
| 441 | −#define StoreDW(addr, value, res) \ | |
| 441 | +#define _StoreDW(addr, value, res) \ | |
| 442 | 442 | do { \ |
| 443 | 443 | __asm__ __volatile__ ( \ |
| 444 | 444 | ".set\tpush\n\t" \ |
| @@ -293,7 +293,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 292 unmodified lines | ||
| 293 | 293 | |
| 294 | 294 | static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) |
| 295 | 295 | { |
| 296 | − smp_call_function_interrupt(); | |
| 296 | + generic_smp_call_function_interrupt(); | |
| 297 | 297 | return IRQ_HANDLED; |
| 298 | 298 | } |
| 299 | 299 | |
| @@ -466,6 +466,7 @@ int get_c0_perfcount_int(void) · 166 unmodified lines | ||
| 466 | 466 | { |
| 467 | 467 | return ltq_perfcount_irq; |
| 468 | 468 | } |
| 469 | +EXPORT_SYMBOL_GPL(get_c0_perfcount_int); | |
| 469 | 470 | |
| 470 | 471 | unsigned int get_c0_compare_int(void) |
| 471 | 472 | { |
| @@ -266,8 +266,11 @@ void loongson3_ipi_interrupt(struct pt_regs *regs) · 265 unmodified lines | ||
| 266 | 266 | if (action & SMP_RESCHEDULE_YOURSELF) |
| 267 | 267 | scheduler_ipi(); |
| 268 | 268 | |
| 269 | − if (action & SMP_CALL_FUNCTION) | |
| 270 | − smp_call_function_interrupt(); | |
| 269 | + if (action & SMP_CALL_FUNCTION) { | |
| 270 | + irq_enter(); | |
| 271 | + generic_smp_call_function_interrupt(); | |
| 272 | + irq_exit(); | |
| 273 | + } | |
| 271 | 274 | |
| 272 | 275 | if (action & SMP_ASK_C0COUNT) { |
| 273 | 276 | BUG_ON(cpu != 0); |
| @@ -160,18 +160,18 @@ static inline void setup_protection_map(void) · 159 unmodified lines | ||
| 160 | 160 | protection_map[1] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC); |
| 161 | 161 | protection_map[2] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); |
| 162 | 162 | protection_map[3] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC); |
| 163 | − protection_map[4] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ); | |
| 163 | + protection_map[4] = __pgprot(_page_cachable_default | _PAGE_PRESENT); | |
| 164 | 164 | protection_map[5] = __pgprot(_page_cachable_default | _PAGE_PRESENT); |
| 165 | − protection_map[6] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ); | |
| 165 | + protection_map[6] = __pgprot(_page_cachable_default | _PAGE_PRESENT); | |
| 166 | 166 | protection_map[7] = __pgprot(_page_cachable_default | _PAGE_PRESENT); |
| 167 | 167 | |
| 168 | 168 | protection_map[8] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_NO_READ); |
| 169 | 169 | protection_map[9] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC); |
| 170 | 170 | protection_map[10] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE | _PAGE_NO_READ); |
| 171 | 171 | protection_map[11] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_EXEC | _PAGE_WRITE); |
| 172 | − protection_map[12] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_NO_READ); | |
| 172 | + protection_map[12] = __pgprot(_page_cachable_default | _PAGE_PRESENT); | |
| 173 | 173 | protection_map[13] = __pgprot(_page_cachable_default | _PAGE_PRESENT); |
| 174 | − protection_map[14] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE | _PAGE_NO_READ); | |
| 174 | + protection_map[14] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE); | |
| 175 | 175 | protection_map[15] = __pgprot(_page_cachable_default | _PAGE_PRESENT | _PAGE_WRITE); |
| 176 | 176 | |
| 177 | 177 | } else { |
| @@ -133,7 +133,8 @@ good_area: · 132 unmodified lines | ||
| 133 | 133 | #endif |
| 134 | 134 | goto bad_area; |
| 135 | 135 | } |
| 136 | − if (!(vma->vm_flags & VM_READ)) { | |
| 136 | + if (!(vma->vm_flags & VM_READ) && | |
| 137 | + exception_epc(regs) != address) { | |
| 137 | 138 | #if 0 |
| 138 | 139 | pr_notice("Cpu%d[%s:%d:%0*lx:%ld:%0*lx] RI violation\n", |
| 139 | 140 | raw_smp_processor_id(), |
| @@ -222,7 +222,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 221 unmodified lines | ||
| 222 | 222 | |
| 223 | 223 | static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) |
| 224 | 224 | { |
| 225 | − smp_call_function_interrupt(); | |
| 225 | + generic_smp_call_function_interrupt(); | |
| 226 | 226 | |
| 227 | 227 | return IRQ_HANDLED; |
| 228 | 228 | } |
| @@ -154,6 +154,7 @@ int get_c0_perfcount_int(void) · 153 unmodified lines | ||
| 154 | 154 | |
| 155 | 155 | return mips_cpu_perf_irq; |
| 156 | 156 | } |
| 157 | +EXPORT_SYMBOL_GPL(get_c0_perfcount_int); | |
| 157 | 158 | |
| 158 | 159 | unsigned int get_c0_compare_int(void) |
| 159 | 160 | { |
| @@ -171,14 +172,17 @@ unsigned int get_c0_compare_int(void) · 11 unmodified lines | ||
| 171 | 172 | |
| 172 | 173 | static void __init init_rtc(void) |
| 173 | 174 | { |
| 174 | − /* stop the clock whilst setting it up */ | |
| 175 | − CMOS_WRITE(RTC_SET | RTC_24H, RTC_CONTROL); | |
| 175 | + unsigned char freq, ctrl; | |
| 176 | 176 | |
| 177 | − /* 32KHz time base */ | |
| 178 | − CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_FREQ_SELECT); | |
| 177 | + /* Set 32KHz time base if not already set */ | |
| 178 | + freq = CMOS_READ(RTC_FREQ_SELECT); | |
| 179 | + if ((freq & RTC_DIV_CTL) != RTC_REF_CLCK_32KHZ) | |
| 180 | + CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_FREQ_SELECT); | |
| 179 | 181 | |
| 180 | − /* start the clock */ | |
| 181 | − CMOS_WRITE(RTC_24H, RTC_CONTROL); | |
| 182 | + /* Ensure SET bit is clear so RTC can run */ | |
| 183 | + ctrl = CMOS_READ(RTC_CONTROL); | |
| 184 | + if (ctrl & RTC_SET) | |
| 185 | + CMOS_WRITE(ctrl & ~RTC_SET, RTC_CONTROL); | |
| 182 | 186 | } |
| 183 | 187 | |
| 184 | 188 | void __init plat_time_init(void) |
| @@ -77,6 +77,7 @@ int get_c0_perfcount_int(void) · 76 unmodified lines | ||
| 77 | 77 | return MIPS_CPU_IRQ_BASE + cp0_perfcount_irq; |
| 78 | 78 | return -1; |
| 79 | 79 | } |
| 80 | +EXPORT_SYMBOL_GPL(get_c0_perfcount_int); | |
| 80 | 81 | |
| 81 | 82 | unsigned int get_c0_compare_int(void) |
| 82 | 83 | { |
| @@ -86,7 +86,7 @@ void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc) · 85 unmodified lines | ||
| 86 | 86 | { |
| 87 | 87 | clear_c0_eimr(irq); |
| 88 | 88 | ack_c0_eirr(irq); |
| 89 | − smp_call_function_interrupt(); | |
| 89 | + generic_smp_call_function_interrupt(); | |
| 90 | 90 | set_c0_eimr(irq); |
| 91 | 91 | } |
| 92 | 92 | |
| @@ -114,7 +114,7 @@ static irqreturn_t paravirt_reched_interrupt(int irq, void *dev_id) · 113 unmodified lines | ||
| 114 | 114 | |
| 115 | 115 | static irqreturn_t paravirt_function_interrupt(int irq, void *dev_id) |
| 116 | 116 | { |
| 117 | − smp_call_function_interrupt(); | |
| 117 | + generic_smp_call_function_interrupt(); | |
| 118 | 118 | return IRQ_HANDLED; |
| 119 | 119 | } |
| 120 | 120 | |
| @@ -26,6 +26,7 @@ int get_c0_perfcount_int(void) · 25 unmodified lines | ||
| 26 | 26 | { |
| 27 | 27 | return gic_get_c0_perfcount_int(); |
| 28 | 28 | } |
| 29 | +EXPORT_SYMBOL_GPL(get_c0_perfcount_int); | |
| 29 | 30 | |
| 30 | 31 | int get_c0_fdc_int(void) |
| 31 | 32 | { |
| @@ -44,7 +44,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) |
| 46 | 46 | { |
| 47 | − smp_call_function_interrupt(); | |
| 47 | + generic_smp_call_function_interrupt(); | |
| 48 | 48 | |
| 49 | 49 | return IRQ_HANDLED; |
| 50 | 50 | } |
| @@ -89,6 +89,7 @@ int get_c0_perfcount_int(void) · 88 unmodified lines | ||
| 89 | 89 | { |
| 90 | 90 | return rt_perfcount_irq; |
| 91 | 91 | } |
| 92 | +EXPORT_SYMBOL_GPL(get_c0_perfcount_int); | |
| 92 | 93 | |
| 93 | 94 | unsigned int get_c0_compare_int(void) |
| 94 | 95 | { |
| @@ -107,10 +107,14 @@ static void ip27_do_irq_mask0(void) · 106 unmodified lines | ||
| 107 | 107 | scheduler_ipi(); |
| 108 | 108 | } else if (pend0 & (1UL << CPU_CALL_A_IRQ)) { |
| 109 | 109 | LOCAL_HUB_CLR_INTR(CPU_CALL_A_IRQ); |
| 110 | − smp_call_function_interrupt(); | |
| 110 | + irq_enter(); | |
| 111 | + generic_smp_call_function_interrupt(); | |
| 112 | + irq_exit(); | |
| 111 | 113 | } else if (pend0 & (1UL << CPU_CALL_B_IRQ)) { |
| 112 | 114 | LOCAL_HUB_CLR_INTR(CPU_CALL_B_IRQ); |
| 113 | − smp_call_function_interrupt(); | |
| 115 | + irq_enter(); | |
| 116 | + generic_smp_call_function_interrupt(); | |
| 117 | + irq_exit(); | |
| 114 | 118 | } else |
| 115 | 119 | #endif |
| 116 | 120 | { |
| @@ -29,8 +29,6 @@ · 28 unmodified lines | ||
| 29 | 29 | #include <asm/sibyte/bcm1480_regs.h> |
| 30 | 30 | #include <asm/sibyte/bcm1480_int.h> |
| 31 | 31 | |
| 32 | −extern void smp_call_function_interrupt(void); | |
| 33 | − | |
| 34 | 32 | /* |
| 35 | 33 | * These are routines for dealing with the bcm1480 smp capabilities |
| 36 | 34 | * independent of board/firmware |
| @@ -184,6 +182,9 @@ void bcm1480_mailbox_interrupt(void) · 147 unmodified lines | ||
| 184 | 182 | if (action & SMP_RESCHEDULE_YOURSELF) |
| 185 | 183 | scheduler_ipi(); |
| 186 | 184 | |
| 187 | − if (action & SMP_CALL_FUNCTION) | |
| 188 | − smp_call_function_interrupt(); | |
| 185 | + if (action & SMP_CALL_FUNCTION) { | |
| 186 | + irq_enter(); | |
| 187 | + generic_smp_call_function_interrupt(); | |
| 188 | + irq_exit(); | |
| 189 | + } | |
| 189 | 190 | } |
| @@ -172,6 +172,9 @@ void sb1250_mailbox_interrupt(void) · 171 unmodified lines | ||
| 172 | 172 | if (action & SMP_RESCHEDULE_YOURSELF) |
| 173 | 173 | scheduler_ipi(); |
| 174 | 174 | |
| 175 | − if (action & SMP_CALL_FUNCTION) | |
| 176 | − smp_call_function_interrupt(); | |
| 175 | + if (action & SMP_CALL_FUNCTION) { | |
| 176 | + irq_enter(); | |
| 177 | + generic_smp_call_function_interrupt(); | |
| 178 | + irq_exit(); | |
| 179 | + } | |
| 177 | 180 | } |
| @@ -966,8 +966,6 @@ int copy_siginfo_to_user32(struct compat_siginfo __user *d, const siginfo_t *s) · 965 unmodified lines | ||
| 966 | 966 | |
| 967 | 967 | int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from) |
| 968 | 968 | { |
| 969 | − memset(to, 0, sizeof *to); | |
| 970 | − | |
| 971 | 969 | if (copy_from_user(to, from, 3*sizeof(int)) || |
| 972 | 970 | copy_from_user(to->_sifields._pad, |
| 973 | 971 | from->_sifields._pad, SI_PAD_SIZE32)) |
| @@ -1478,7 +1478,7 @@ static int pnv_eeh_next_error(struct eeh_pe **pe) · 1477 unmodified lines | ||
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | /* Unmask the event */ |
| 1481 | − if (eeh_enabled()) | |
| 1481 | + if (ret == EEH_NEXT_ERR_NONE && eeh_enabled()) | |
| 1482 | 1482 | enable_irq(eeh_event_irq); |
| 1483 | 1483 | |
| 1484 | 1484 | return ret; |
| @@ -2220,7 +2220,7 @@ static void pnv_pci_ioda_setup_opal_tce_kill(struct pnv_phb *phb) · 2219 unmodified lines | ||
| 2220 | 2220 | |
| 2221 | 2221 | static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift, |
| 2222 | 2222 | unsigned levels, unsigned long limit, |
| 2223 | − unsigned long *current_offset) | |
| 2223 | + unsigned long *current_offset, unsigned long *total_allocated) | |
| 2224 | 2224 | { |
| 2225 | 2225 | struct page *tce_mem = NULL; |
| 2226 | 2226 | __be64 *addr, *tmp; |
| @@ -2236,6 +2236,7 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift, · 9 unmodified lines | ||
| 2236 | 2236 | } |
| 2237 | 2237 | addr = page_address(tce_mem); |
| 2238 | 2238 | memset(addr, 0, allocated); |
| 2239 | + *total_allocated += allocated; | |
| 2239 | 2240 | |
| 2240 | 2241 | --levels; |
| 2241 | 2242 | if (!levels) { |
| @@ -2245,7 +2246,7 @@ static __be64 *pnv_pci_ioda2_table_do_alloc_pages(int nid, unsigned shift, · 3 unmodified lines | ||
| 2245 | 2246 | |
| 2246 | 2247 | for (i = 0; i < entries; ++i) { |
| 2247 | 2248 | tmp = pnv_pci_ioda2_table_do_alloc_pages(nid, shift, |
| 2248 | − levels, limit, current_offset); | |
| 2249 | + levels, limit, current_offset, total_allocated); | |
| 2249 | 2250 | if (!tmp) |
| 2250 | 2251 | break; |
| 2251 | 2252 | |
| @@ -2267,7 +2268,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, · 15 unmodified lines | ||
| 2267 | 2268 | struct iommu_table *tbl) |
| 2268 | 2269 | { |
| 2269 | 2270 | void *addr; |
| 2270 | − unsigned long offset = 0, level_shift; | |
| 2271 | + unsigned long offset = 0, level_shift, total_allocated = 0; | |
| 2271 | 2272 | const unsigned window_shift = ilog2(window_size); |
| 2272 | 2273 | unsigned entries_shift = window_shift - page_shift; |
| 2273 | 2274 | unsigned table_shift = max_t(unsigned, entries_shift + 3, PAGE_SHIFT); |
| @@ -2286,7 +2287,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, · 12 unmodified lines | ||
| 2286 | 2287 | |
| 2287 | 2288 | /* Allocate TCE table */ |
| 2288 | 2289 | addr = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift, |
| 2289 | − levels, tce_table_size, &offset); | |
| 2290 | + levels, tce_table_size, &offset, &total_allocated); | |
| 2290 | 2291 | |
| 2291 | 2292 | /* addr==NULL means that the first level allocation failed */ |
| 2292 | 2293 | if (!addr) |
| @@ -2308,7 +2309,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset, · 15 unmodified lines | ||
| 2308 | 2309 | page_shift); |
| 2309 | 2310 | tbl->it_level_size = 1ULL << (level_shift - 3); |
| 2310 | 2311 | tbl->it_indirect_levels = levels - 1; |
| 2311 | − tbl->it_allocated_size = offset; | |
| 2312 | + tbl->it_allocated_size = total_allocated; | |
| 2312 | 2313 | |
| 2313 | 2314 | pr_devel("Created TCE table: ws=%08llx ts=%lx @%08llx\n", |
| 2314 | 2315 | window_size, tce_table_size, bus_offset); |
| @@ -1742,10 +1742,10 @@ static bool ibs_enabled(struct kvm_vcpu *vcpu) · 1741 unmodified lines | ||
| 1742 | 1742 | |
| 1743 | 1743 | static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu) |
| 1744 | 1744 | { |
| 1745 | − if (!vcpu->requests) | |
| 1746 | − return 0; | |
| 1747 | 1745 | retry: |
| 1748 | 1746 | kvm_s390_vcpu_request_handled(vcpu); |
| 1747 | + if (!vcpu->requests) | |
| 1748 | + return 0; | |
| 1749 | 1749 | /* |
| 1750 | 1750 | * We use MMU_RELOAD just to re-arm the ipte notifier for the |
| 1751 | 1751 | * guest prefix page. gmap_ipte_notify will wait on the ptl lock. |
| @@ -28,16 +28,10 @@ · 27 unmodified lines | ||
| 28 | 28 | * Must preserve %o5 between VISEntryHalf and VISExitHalf */ |
| 29 | 29 | |
| 30 | 30 | #define VISEntryHalf \ |
| 31 | − rd %fprs, %o5; \ | |
| 32 | − andcc %o5, FPRS_FEF, %g0; \ | |
| 33 | − be,pt %icc, 297f; \ | |
| 34 | − sethi %hi(298f), %g7; \ | |
| 35 | − sethi %hi(VISenterhalf), %g1; \ | |
| 36 | − jmpl %g1 + %lo(VISenterhalf), %g0; \ | |
| 37 | − or %g7, %lo(298f), %g7; \ | |
| 38 | − clr %o5; \ | |
| 39 | −297: wr %o5, FPRS_FEF, %fprs; \ | |
| 40 | −298: | |
| 31 | + VISEntry | |
| 32 | + | |
| 33 | +#define VISExitHalf \ | |
| 34 | + VISExit | |
| 41 | 35 | |
| 42 | 36 | #define VISEntryHalfFast(fail_label) \ |
| 43 | 37 | rd %fprs, %o5; \ |
| @@ -47,7 +41,7 @@ · 3 unmodified lines | ||
| 47 | 41 | ba,a,pt %xcc, fail_label; \ |
| 48 | 42 | 297: wr %o5, FPRS_FEF, %fprs; |
| 49 | 43 | |
| 50 | −#define VISExitHalf \ | |
| 44 | +#define VISExitHalfFast \ | |
| 51 | 45 | wr %o5, 0, %fprs; |
| 52 | 46 | |
| 53 | 47 | #ifndef __ASSEMBLY__ |
| @@ -240,8 +240,11 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ · 239 unmodified lines | ||
| 240 | 240 | add %o0, 0x40, %o0 |
| 241 | 241 | bne,pt %icc, 1b |
| 242 | 242 | LOAD(prefetch, %g1 + 0x200, #n_reads_strong) |
| 243 | +#ifdef NON_USER_COPY | |
| 244 | + VISExitHalfFast | |
| 245 | +#else | |
| 243 | 246 | VISExitHalf |
| 244 | − | |
| 247 | +#endif | |
| 245 | 248 | brz,pn %o2, .Lexit |
| 246 | 249 | cmp %o2, 19 |
| 247 | 250 | ble,pn %icc, .Lsmall_unaligned |
| @@ -44,9 +44,8 @@ vis1: ldub [%g6 + TI_FPSAVED], %g3 · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | stx %g3, [%g6 + TI_GSR] |
| 46 | 46 | 2: add %g6, %g1, %g3 |
| 47 | − cmp %o5, FPRS_DU | |
| 48 | − be,pn %icc, 6f | |
| 49 | − sll %g1, 3, %g1 | |
| 47 | + mov FPRS_DU | FPRS_DL | FPRS_FEF, %o5 | |
| 48 | + sll %g1, 3, %g1 | |
| 50 | 49 | stb %o5, [%g3 + TI_FPSAVED] |
| 51 | 50 | rd %gsr, %g2 |
| 52 | 51 | add %g6, %g1, %g3 |
| @@ -80,65 +79,3 @@ vis1: ldub [%g6 + TI_FPSAVED], %g3 · 27 unmodified lines | ||
| 80 | 79 | .align 32 |
| 81 | 80 | 80: jmpl %g7 + %g0, %g0 |
| 82 | 81 | nop |
| 83 | − | |
| 84 | −6: ldub [%g3 + TI_FPSAVED], %o5 | |
| 85 | − or %o5, FPRS_DU, %o5 | |
| 86 | − add %g6, TI_FPREGS+0x80, %g2 | |
| 87 | − stb %o5, [%g3 + TI_FPSAVED] | |
| 88 | − | |
| 89 | − sll %g1, 5, %g1 | |
| 90 | − add %g6, TI_FPREGS+0xc0, %g3 | |
| 91 | − wr %g0, FPRS_FEF, %fprs | |
| 92 | − membar #Sync | |
| 93 | − stda %f32, [%g2 + %g1] ASI_BLK_P | |
| 94 | − stda %f48, [%g3 + %g1] ASI_BLK_P | |
| 95 | − membar #Sync | |
| 96 | − ba,pt %xcc, 80f | |
| 97 | − nop | |
| 98 | − | |
| 99 | − .align 32 | |
| 100 | −80: jmpl %g7 + %g0, %g0 | |
| 101 | − nop | |
| 102 | − | |
| 103 | − .align 32 | |
| 104 | −VISenterhalf: | |
| 105 | − ldub [%g6 + TI_FPDEPTH], %g1 | |
| 106 | − brnz,a,pn %g1, 1f | |
| 107 | − cmp %g1, 1 | |
| 108 | − stb %g0, [%g6 + TI_FPSAVED] | |
| 109 | − stx %fsr, [%g6 + TI_XFSR] | |
| 110 | − clr %o5 | |
| 111 | − jmpl %g7 + %g0, %g0 | |
| 112 | − wr %g0, FPRS_FEF, %fprs | |
| 113 | − | |
| 114 | −1: bne,pn %icc, 2f | |
| 115 | − srl %g1, 1, %g1 | |
| 116 | − ba,pt %xcc, vis1 | |
| 117 | − sub %g7, 8, %g7 | |
| 118 | −2: addcc %g6, %g1, %g3 | |
| 119 | − sll %g1, 3, %g1 | |
| 120 | − andn %o5, FPRS_DU, %g2 | |
| 121 | − stb %g2, [%g3 + TI_FPSAVED] | |
| 122 | − | |
| 123 | − rd %gsr, %g2 | |
| 124 | − add %g6, %g1, %g3 | |
| 125 | − stx %g2, [%g3 + TI_GSR] | |
| 126 | − add %g6, %g1, %g2 | |
| 127 | − stx %fsr, [%g2 + TI_XFSR] | |
| 128 | − sll %g1, 5, %g1 | |
| 129 | −3: andcc %o5, FPRS_DL, %g0 | |
| 130 | − be,pn %icc, 4f | |
| 131 | − add %g6, TI_FPREGS, %g2 | |
| 132 | − | |
| 133 | − add %g6, TI_FPREGS+0x40, %g3 | |
| 134 | − membar #Sync | |
| 135 | − stda %f0, [%g2 + %g1] ASI_BLK_P | |
| 136 | − stda %f16, [%g3 + %g1] ASI_BLK_P | |
| 137 | − membar #Sync | |
| 138 | − ba,pt %xcc, 4f | |
| 139 | − nop | |
| 140 | − | |
| 141 | − .align 32 | |
| 142 | −4: and %o5, FPRS_DU, %o5 | |
| 143 | − jmpl %g7 + %g0, %g0 | |
| 144 | − wr %o5, FPRS_FEF, %fprs | |
| @@ -135,10 +135,6 @@ EXPORT_SYMBOL(copy_user_page); · 134 unmodified lines | ||
| 135 | 135 | void VISenter(void); |
| 136 | 136 | EXPORT_SYMBOL(VISenter); |
| 137 | 137 | |
| 138 | −/* CRYPTO code needs this */ | |
| 139 | −void VISenterhalf(void); | |
| 140 | −EXPORT_SYMBOL(VISenterhalf); | |
| 141 | − | |
| 142 | 138 | extern void xor_vis_2(unsigned long, unsigned long *, unsigned long *); |
| 143 | 139 | extern void xor_vis_3(unsigned long, unsigned long *, unsigned long *, |
| 144 | 140 | unsigned long *); |
| @@ -113,8 +113,6 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from) · 112 unmodified lines | ||
| 113 | 113 | if (!access_ok(VERIFY_READ, from, sizeof(struct compat_siginfo))) |
| 114 | 114 | return -EFAULT; |
| 115 | 115 | |
| 116 | − memset(to, 0, sizeof(*to)); | |
| 117 | − | |
| 118 | 116 | err = __get_user(to->si_signo, &from->si_signo); |
| 119 | 117 | err |= __get_user(to->si_errno, &from->si_errno); |
| 120 | 118 | err |= __get_user(to->si_code, &from->si_code); |
| @@ -1193,6 +1193,10 @@ static efi_status_t setup_e820(struct boot_params *params, · 1192 unmodified lines | ||
| 1193 | 1193 | unsigned int e820_type = 0; |
| 1194 | 1194 | unsigned long m = efi->efi_memmap; |
| 1195 | 1195 | |
| 1196 | +#ifdef CONFIG_X86_64 | |
| 1197 | + m |= (u64)efi->efi_memmap_hi << 32; | |
| 1198 | +#endif | |
| 1199 | + | |
| 1196 | 1200 | d = (efi_memory_desc_t *)(m + (i * efi->efi_memdesc_size)); |
| 1197 | 1201 | switch (d->type) { |
| 1198 | 1202 | case EFI_RESERVED_TYPE: |
| @@ -280,21 +280,6 @@ static inline void clear_LDT(void) · 279 unmodified lines | ||
| 280 | 280 | set_ldt(NULL, 0); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | −/* | |
| 284 | − * load one particular LDT into the current CPU | |
| 285 | − */ | |
| 286 | −static inline void load_LDT_nolock(mm_context_t *pc) | |
| 287 | −{ | |
| 288 | − set_ldt(pc->ldt, pc->size); | |
| 289 | −} | |
| 290 | − | |
| 291 | −static inline void load_LDT(mm_context_t *pc) | |
| 292 | −{ | |
| 293 | − preempt_disable(); | |
| 294 | − load_LDT_nolock(pc); | |
| 295 | − preempt_enable(); | |
| 296 | −} | |
| 297 | − | |
| 298 | 283 | static inline unsigned long get_desc_base(const struct desc_struct *desc) |
| 299 | 284 | { |
| 300 | 285 | return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24)); |
| @@ -9,8 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | * we put the segment information here. |
| 10 | 10 | */ |
| 11 | 11 | typedef struct { |
| 12 | − void *ldt; | |
| 13 | − int size; | |
| 12 | + struct ldt_struct *ldt; | |
| 14 | 13 | |
| 15 | 14 | #ifdef CONFIG_X86_64 |
| 16 | 15 | /* True if mm supports a task running in 32 bit compatibility mode. */ |
| @@ -33,6 +33,50 @@ static inline void load_mm_cr4(struct mm_struct *mm) · 32 unmodified lines | ||
| 33 | 33 | static inline void load_mm_cr4(struct mm_struct *mm) {} |
| 34 | 34 | #endif |
| 35 | 35 | |
| 36 | +/* | |
| 37 | + * ldt_structs can be allocated, used, and freed, but they are never | |
| 38 | + * modified while live. | |
| 39 | + */ | |
| 40 | +struct ldt_struct { | |
| 41 | + /* | |
| 42 | + * Xen requires page-aligned LDTs with special permissions. This is | |
| 43 | + * needed to prevent us from installing evil descriptors such as | |
| 44 | + * call gates. On native, we could merge the ldt_struct and LDT | |
| 45 | + * allocations, but it's not worth trying to optimize. | |
| 46 | + */ | |
| 47 | + struct desc_struct *entries; | |
| 48 | + int size; | |
| 49 | +}; | |
| 50 | + | |
| 51 | +static inline void load_mm_ldt(struct mm_struct *mm) | |
| 52 | +{ | |
| 53 | + struct ldt_struct *ldt; | |
| 54 | + | |
| 55 | + /* lockless_dereference synchronizes with smp_store_release */ | |
| 56 | + ldt = lockless_dereference(mm->context.ldt); | |
| 57 | + | |
| 58 | + /* | |
| 59 | + * Any change to mm->context.ldt is followed by an IPI to all | |
| 60 | + * CPUs with the mm active. The LDT will not be freed until | |
| 61 | + * after the IPI is handled by all such CPUs. This means that, | |
| 62 | + * if the ldt_struct changes before we return, the values we see | |
| 63 | + * will be safe, and the new values will be loaded before we run | |
| 64 | + * any user code. | |
| 65 | + * | |
| 66 | + * NB: don't try to convert this to use RCU without extreme care. | |
| 67 | + * We would still need IRQs off, because we don't want to change | |
| 68 | + * the local LDT after an IPI loaded a newer value than the one | |
| 69 | + * that we can see. | |
| 70 | + */ | |
| 71 | + | |
| 72 | + if (unlikely(ldt)) | |
| 73 | + set_ldt(ldt->entries, ldt->size); | |
| 74 | + else | |
| 75 | + clear_LDT(); | |
| 76 | + | |
| 77 | + DEBUG_LOCKS_WARN_ON(preemptible()); | |
| 78 | +} | |
| 79 | + | |
| 36 | 80 | /* |
| 37 | 81 | * Used for LDT copy/destruction. |
| 38 | 82 | */ |
| @@ -78,12 +122,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · 39 unmodified lines | ||
| 78 | 122 | * was called and then modify_ldt changed |
| 79 | 123 | * prev->context.ldt but suppressed an IPI to this CPU. |
| 80 | 124 | * In this case, prev->context.ldt != NULL, because we |
| 81 | − * never free an LDT while the mm still exists. That | |
| 82 | − * means that next->context.ldt != prev->context.ldt, | |
| 83 | − * because mms never share an LDT. | |
| 125 | + * never set context.ldt to NULL while the mm still | |
| 126 | + * exists. That means that next->context.ldt != | |
| 127 | + * prev->context.ldt, because mms never share an LDT. | |
| 84 | 128 | */ |
| 85 | 129 | if (unlikely(prev->context.ldt != next->context.ldt)) |
| 86 | − load_LDT_nolock(&next->context); | |
| 130 | + load_mm_ldt(next); | |
| 87 | 131 | } |
| 88 | 132 | #ifdef CONFIG_SMP |
| 89 | 133 | else { |
| @@ -106,7 +150,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, · 16 unmodified lines | ||
| 106 | 150 | load_cr3(next->pgd); |
| 107 | 151 | trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL); |
| 108 | 152 | load_mm_cr4(next); |
| 109 | − load_LDT_nolock(&next->context); | |
| 153 | + load_mm_ldt(next); | |
| 110 | 154 | } |
| 111 | 155 | } |
| 112 | 156 | #endif |
| @@ -57,9 +57,9 @@ struct sigcontext { · 56 unmodified lines | ||
| 57 | 57 | unsigned long ip; |
| 58 | 58 | unsigned long flags; |
| 59 | 59 | unsigned short cs; |
| 60 | − unsigned short __pad2; /* Was called gs, but was always zero. */ | |
| 61 | − unsigned short __pad1; /* Was called fs, but was always zero. */ | |
| 62 | − unsigned short ss; | |
| 60 | + unsigned short gs; | |
| 61 | + unsigned short fs; | |
| 62 | + unsigned short __pad0; | |
| 63 | 63 | unsigned long err; |
| 64 | 64 | unsigned long trapno; |
| 65 | 65 | unsigned long oldmask; |
| @@ -177,24 +177,9 @@ struct sigcontext { · 176 unmodified lines | ||
| 177 | 177 | __u64 rip; |
| 178 | 178 | __u64 eflags; /* RFLAGS */ |
| 179 | 179 | __u16 cs; |
| 180 | − | |
| 181 | − /* | |
| 182 | − * Prior to 2.5.64 ("[PATCH] x86-64 updates for 2.5.64-bk3"), | |
| 183 | − * Linux saved and restored fs and gs in these slots. This | |
| 184 | − * was counterproductive, as fsbase and gsbase were never | |
| 185 | − * saved, so arch_prctl was presumably unreliable. | |
| 186 | − * | |
| 187 | − * If these slots are ever needed for any other purpose, there | |
| 188 | − * is some risk that very old 64-bit binaries could get | |
| 189 | − * confused. I doubt that many such binaries still work, | |
| 190 | − * though, since the same patch in 2.5.64 also removed the | |
| 191 | − * 64-bit set_thread_area syscall, so it appears that there is | |
| 192 | − * no TLS API that works in both pre- and post-2.5.64 kernels. | |
| 193 | − */ | |
| 194 | − __u16 __pad2; /* Was gs. */ | |
| 195 | − __u16 __pad1; /* Was fs. */ | |
| 196 | − | |
| 197 | − __u16 ss; | |
| 180 | + __u16 gs; | |
| 181 | + __u16 fs; | |
| 182 | + __u16 __pad0; | |
| 198 | 183 | __u64 err; |
| 199 | 184 | __u64 trapno; |
| 200 | 185 | __u64 oldmask; |
| @@ -943,7 +943,7 @@ static bool mp_check_pin_attr(int irq, struct irq_alloc_info *info) · 942 unmodified lines | ||
| 943 | 943 | */ |
| 944 | 944 | if (irq < nr_legacy_irqs() && data->count == 1) { |
| 945 | 945 | if (info->ioapic_trigger != data->trigger) |
| 946 | − mp_register_handler(irq, data->trigger); | |
| 946 | + mp_register_handler(irq, info->ioapic_trigger); | |
| 947 | 947 | data->entry.trigger = data->trigger = info->ioapic_trigger; |
| 948 | 948 | data->entry.polarity = data->polarity = info->ioapic_polarity; |
| 949 | 949 | } |
| @@ -1410,7 +1410,7 @@ void cpu_init(void) · 1409 unmodified lines | ||
| 1410 | 1410 | load_sp0(t, ¤t->thread); |
| 1411 | 1411 | set_tss_desc(cpu, t); |
| 1412 | 1412 | load_TR_desc(); |
| 1413 | − load_LDT(&init_mm.context); | |
| 1413 | + load_mm_ldt(&init_mm); | |
| 1414 | 1414 | |
| 1415 | 1415 | clear_all_debug_regs(); |
| 1416 | 1416 | dbg_restore_debug_regs(); |
| @@ -1459,7 +1459,7 @@ void cpu_init(void) · 42 unmodified lines | ||
| 1459 | 1459 | load_sp0(t, thread); |
| 1460 | 1460 | set_tss_desc(cpu, t); |
| 1461 | 1461 | load_TR_desc(); |
| 1462 | − load_LDT(&init_mm.context); | |
| 1462 | + load_mm_ldt(&init_mm); | |
| 1463 | 1463 | |
| 1464 | 1464 | t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap); |
| 1465 | 1465 | |
| @@ -2179,21 +2179,25 @@ static unsigned long get_segment_base(unsigned int segment) · 2178 unmodified lines | ||
| 2179 | 2179 | int idx = segment >> 3; |
| 2180 | 2180 | |
| 2181 | 2181 | if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) { |
| 2182 | + struct ldt_struct *ldt; | |
| 2183 | + | |
| 2182 | 2184 | if (idx > LDT_ENTRIES) |
| 2183 | 2185 | return 0; |
| 2184 | 2186 | |
| 2185 | − if (idx > current->active_mm->context.size) | |
| 2187 | + /* IRQs are off, so this synchronizes with smp_store_release */ | |
| 2188 | + ldt = lockless_dereference(current->active_mm->context.ldt); | |
| 2189 | + if (!ldt || idx > ldt->size) | |
| 2186 | 2190 | return 0; |
| 2187 | 2191 | |
| 2188 | − desc = current->active_mm->context.ldt; | |
| 2192 | + desc = &ldt->entries[idx]; | |
| 2189 | 2193 | } else { |
| 2190 | 2194 | if (idx > GDT_ENTRIES) |
| 2191 | 2195 | return 0; |
| 2192 | 2196 | |
| 2193 | − desc = raw_cpu_ptr(gdt_page.gdt); | |
| 2197 | + desc = raw_cpu_ptr(gdt_page.gdt) + idx; | |
| 2194 | 2198 | } |
| 2195 | 2199 | |
| 2196 | − return get_desc_base(desc + idx); | |
| 2200 | + return get_desc_base(desc); | |
| 2197 | 2201 | } |
| 2198 | 2202 | |
| 2199 | 2203 | #ifdef CONFIG_COMPAT |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | #include <linux/string.h> |
| 13 | 13 | #include <linux/mm.h> |
| 14 | 14 | #include <linux/smp.h> |
| 15 | +#include <linux/slab.h> | |
| 15 | 16 | #include <linux/vmalloc.h> |
| 16 | 17 | #include <linux/uaccess.h> |
| 17 | 18 | |
| @@ -20,82 +21,82 @@ · 2 unmodified lines | ||
| 20 | 21 | #include <asm/mmu_context.h> |
| 21 | 22 | #include <asm/syscalls.h> |
| 22 | 23 | |
| 23 | −#ifdef CONFIG_SMP | |
| 24 | +/* context.lock is held for us, so we don't need any locking. */ | |
| 24 | 25 | static void flush_ldt(void *current_mm) |
| 25 | 26 | { |
| 26 | − if (current->active_mm == current_mm) | |
| 27 | − load_LDT(¤t->active_mm->context); | |
| 27 | + mm_context_t *pc; | |
| 28 | + | |
| 29 | + if (current->active_mm != current_mm) | |
| 30 | + return; | |
| 31 | + | |
| 32 | + pc = ¤t->active_mm->context; | |
| 33 | + set_ldt(pc->ldt->entries, pc->ldt->size); | |
| 28 | 34 | } |
| 29 | −#endif | |
| 30 | 35 | |
| 31 | −static int alloc_ldt(mm_context_t *pc, int mincount, int reload) | |
| 36 | +/* The caller must call finalize_ldt_struct on the result. LDT starts zeroed. */ | |
| 37 | +static struct ldt_struct *alloc_ldt_struct(int size) | |
| 32 | 38 | { |
| 33 | − void *oldldt, *newldt; | |
| 34 | − int oldsize; | |
| 35 | − | |
| 36 | − if (mincount <= pc->size) | |
| 37 | − return 0; | |
| 38 | − oldsize = pc->size; | |
| 39 | − mincount = (mincount + (PAGE_SIZE / LDT_ENTRY_SIZE - 1)) & | |
| 40 | − (~(PAGE_SIZE / LDT_ENTRY_SIZE - 1)); | |
| 41 | − if (mincount * LDT_ENTRY_SIZE > PAGE_SIZE) | |
| 42 | − newldt = vmalloc(mincount * LDT_ENTRY_SIZE); | |
| 39 | + struct ldt_struct *new_ldt; | |
| 40 | + int alloc_size; | |
| 41 | + | |
| 42 | + if (size > LDT_ENTRIES) | |
| 43 | + return NULL; | |
| 44 | + | |
| 45 | + new_ldt = kmalloc(sizeof(struct ldt_struct), GFP_KERNEL); | |
| 46 | + if (!new_ldt) | |
| 47 | + return NULL; | |
| 48 | + | |
| 49 | + BUILD_BUG_ON(LDT_ENTRY_SIZE != sizeof(struct desc_struct)); | |
| 50 | + alloc_size = size * LDT_ENTRY_SIZE; | |
| 51 | + | |
| 52 | + /* | |
| 53 | + * Xen is very picky: it requires a page-aligned LDT that has no | |
| 54 | + * trailing nonzero bytes in any page that contains LDT descriptors. | |
| 55 | + * Keep it simple: zero the whole allocation and never allocate less | |
| 56 | + * than PAGE_SIZE. | |
| 57 | + */ | |
| 58 | + if (alloc_size > PAGE_SIZE) | |
| 59 | + new_ldt->entries = vzalloc(alloc_size); | |
| 43 | 60 | else |
| 44 | − newldt = (void *)__get_free_page(GFP_KERNEL); | |
| 45 | − | |
| 46 | − if (!newldt) | |
| 47 | − return -ENOMEM; | |
| 61 | + new_ldt->entries = kzalloc(PAGE_SIZE, GFP_KERNEL); | |
| 48 | 62 | |
| 49 | − if (oldsize) | |
| 50 | − memcpy(newldt, pc->ldt, oldsize * LDT_ENTRY_SIZE); | |
| 51 | − oldldt = pc->ldt; | |
| 52 | − memset(newldt + oldsize * LDT_ENTRY_SIZE, 0, | |
| 53 | − (mincount - oldsize) * LDT_ENTRY_SIZE); | |
| 63 | + if (!new_ldt->entries) { | |
| 64 | + kfree(new_ldt); | |
| 65 | + return NULL; | |
| 66 | + } | |
| 54 | 67 | |
| 55 | − paravirt_alloc_ldt(newldt, mincount); | |
| 68 | + new_ldt->size = size; | |
| 69 | + return new_ldt; | |
| 70 | +} | |
| 56 | 71 | |
| 57 | −#ifdef CONFIG_X86_64 | |
| 58 | − /* CHECKME: Do we really need this ? */ | |
| 59 | − wmb(); | |
| 60 | −#endif | |
| 61 | − pc->ldt = newldt; | |
| 62 | − wmb(); | |
| 63 | − pc->size = mincount; | |
| 64 | − wmb(); | |
| 65 | − | |
| 66 | − if (reload) { | |
| 67 | −#ifdef CONFIG_SMP | |
| 68 | − preempt_disable(); | |
| 69 | − load_LDT(pc); | |
| 70 | − if (!cpumask_equal(mm_cpumask(current->mm), | |
| 71 | − cpumask_of(smp_processor_id()))) | |
| 72 | − smp_call_function(flush_ldt, current->mm, 1); | |
| 73 | − preempt_enable(); | |
| 74 | −#else | |
| 75 | − load_LDT(pc); | |
| 76 | −#endif | |
| 77 | − } | |
| 78 | − if (oldsize) { | |
| 79 | − paravirt_free_ldt(oldldt, oldsize); | |
| 80 | − if (oldsize * LDT_ENTRY_SIZE > PAGE_SIZE) | |
| 81 | − vfree(oldldt); | |
| 82 | − else | |
| 83 | − put_page(virt_to_page(oldldt)); | |
| 84 | − } | |
| 85 | − return 0; | |
| 72 | +/* After calling this, the LDT is immutable. */ | |
| 73 | +static void finalize_ldt_struct(struct ldt_struct *ldt) | |
| 74 | +{ | |
| 75 | + paravirt_alloc_ldt(ldt->entries, ldt->size); | |
| 86 | 76 | } |
| 87 | 77 | |
| 88 | −static inline int copy_ldt(mm_context_t *new, mm_context_t *old) | |
| 78 | +/* context.lock is held */ | |
| 79 | +static void install_ldt(struct mm_struct *current_mm, | |
| 80 | + struct ldt_struct *ldt) | |
| 89 | 81 | { |
| 90 | − int err = alloc_ldt(new, old->size, 0); | |
| 91 | − int i; | |
| 82 | + /* Synchronizes with lockless_dereference in load_mm_ldt. */ | |
| 83 | + smp_store_release(¤t_mm->context.ldt, ldt); | |
| 84 | + | |
| 85 | + /* Activate the LDT for all CPUs using current_mm. */ | |
| 86 | + on_each_cpu_mask(mm_cpumask(current_mm), flush_ldt, current_mm, true); | |
| 87 | +} | |
| 92 | 88 | |
| 93 | − if (err < 0) | |
| 94 | − return err; | |
| 89 | +static void free_ldt_struct(struct ldt_struct *ldt) | |
| 90 | +{ | |
| 91 | + if (likely(!ldt)) | |
| 92 | + return; | |
| 95 | 93 | |
| 96 | − for (i = 0; i < old->size; i++) | |
| 97 | − write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE); | |
| 98 | − return 0; | |
| 94 | + paravirt_free_ldt(ldt->entries, ldt->size); | |
| 95 | + if (ldt->size * LDT_ENTRY_SIZE > PAGE_SIZE) | |
| 96 | + vfree(ldt->entries); | |
| 97 | + else | |
| 98 | + kfree(ldt->entries); | |
| 99 | + kfree(ldt); | |
| 99 | 100 | } |
| 100 | 101 | |
| 101 | 102 | /* |
| @@ -104,17 +105,37 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old) · 2 unmodified lines | ||
| 104 | 105 | */ |
| 105 | 106 | int init_new_context(struct task_struct *tsk, struct mm_struct *mm) |
| 106 | 107 | { |
| 108 | + struct ldt_struct *new_ldt; | |
| 107 | 109 | struct mm_struct *old_mm; |
| 108 | 110 | int retval = 0; |
| 109 | 111 | |
| 110 | 112 | mutex_init(&mm->context.lock); |
| 111 | − mm->context.size = 0; | |
| 112 | 113 | old_mm = current->mm; |
| 113 | − if (old_mm && old_mm->context.size > 0) { | |
| 114 | − mutex_lock(&old_mm->context.lock); | |
| 115 | − retval = copy_ldt(&mm->context, &old_mm->context); | |
| 116 | − mutex_unlock(&old_mm->context.lock); | |
| 114 | + if (!old_mm) { | |
| 115 | + mm->context.ldt = NULL; | |
| 116 | + return 0; | |
| 117 | 117 | } |
| 118 | + | |
| 119 | + mutex_lock(&old_mm->context.lock); | |
| 120 | + if (!old_mm->context.ldt) { | |
| 121 | + mm->context.ldt = NULL; | |
| 122 | + goto out_unlock; | |
| 123 | + } | |
| 124 | + | |
| 125 | + new_ldt = alloc_ldt_struct(old_mm->context.ldt->size); | |
| 126 | + if (!new_ldt) { | |
| 127 | + retval = -ENOMEM; | |
| 128 | + goto out_unlock; | |
| 129 | + } | |
| 130 | + | |
| 131 | + memcpy(new_ldt->entries, old_mm->context.ldt->entries, | |
| 132 | + new_ldt->size * LDT_ENTRY_SIZE); | |
| 133 | + finalize_ldt_struct(new_ldt); | |
| 134 | + | |
| 135 | + mm->context.ldt = new_ldt; | |
| 136 | + | |
| 137 | +out_unlock: | |
| 138 | + mutex_unlock(&old_mm->context.lock); | |
| 118 | 139 | return retval; |
| 119 | 140 | } |
| 120 | 141 | |
| @@ -125,53 +146,47 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) · 4 unmodified lines | ||
| 125 | 146 | */ |
| 126 | 147 | void destroy_context(struct mm_struct *mm) |
| 127 | 148 | { |
| 128 | − if (mm->context.size) { | |
| 129 | −#ifdef CONFIG_X86_32 | |
| 130 | − /* CHECKME: Can this ever happen ? */ | |
| 131 | − if (mm == current->active_mm) | |
| 132 | − clear_LDT(); | |
| 133 | −#endif | |
| 134 | − paravirt_free_ldt(mm->context.ldt, mm->context.size); | |
| 135 | − if (mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE) | |
| 136 | − vfree(mm->context.ldt); | |
| 137 | − else | |
| 138 | − put_page(virt_to_page(mm->context.ldt)); | |
| 139 | − mm->context.size = 0; | |
| 140 | − } | |
| 149 | + free_ldt_struct(mm->context.ldt); | |
| 150 | + mm->context.ldt = NULL; | |
| 141 | 151 | } |
| 142 | 152 | |
| 143 | 153 | static int read_ldt(void __user *ptr, unsigned long bytecount) |
| 144 | 154 | { |
| 145 | − int err; | |
| 155 | + int retval; | |
| 146 | 156 | unsigned long size; |
| 147 | 157 | struct mm_struct *mm = current->mm; |
| 148 | 158 | |
| 149 | − if (!mm->context.size) | |
| 150 | − return 0; | |
| 159 | + mutex_lock(&mm->context.lock); | |
| 160 | + | |
| 161 | + if (!mm->context.ldt) { | |
| 162 | + retval = 0; | |
| 163 | + goto out_unlock; | |
| 164 | + } | |
| 165 | + | |
| 151 | 166 | if (bytecount > LDT_ENTRY_SIZE * LDT_ENTRIES) |
| 152 | 167 | bytecount = LDT_ENTRY_SIZE * LDT_ENTRIES; |
| 153 | 168 | |
| 154 | − mutex_lock(&mm->context.lock); | |
| 155 | − size = mm->context.size * LDT_ENTRY_SIZE; | |
| 169 | + size = mm->context.ldt->size * LDT_ENTRY_SIZE; | |
| 156 | 170 | if (size > bytecount) |
| 157 | 171 | size = bytecount; |
| 158 | 172 | |
| 159 | − err = 0; | |
| 160 | − if (copy_to_user(ptr, mm->context.ldt, size)) | |
| 161 | − err = -EFAULT; | |
| 162 | − mutex_unlock(&mm->context.lock); | |
| 163 | − if (err < 0) | |
| 164 | − goto error_return; | |
| 173 | + if (copy_to_user(ptr, mm->context.ldt->entries, size)) { | |
| 174 | + retval = -EFAULT; | |
| 175 | + goto out_unlock; | |
| 176 | + } | |
| 177 | + | |
| 165 | 178 | if (size != bytecount) { |
| 166 | − /* zero-fill the rest */ | |
| 167 | − if (clear_user(ptr + size, bytecount - size) != 0) { | |
| 168 | − err = -EFAULT; | |
| 169 | − goto error_return; | |
| 179 | + /* Zero-fill the rest and pretend we read bytecount bytes. */ | |
| 180 | + if (clear_user(ptr + size, bytecount - size)) { | |
| 181 | + retval = -EFAULT; | |
| 182 | + goto out_unlock; | |
| 170 | 183 | } |
| 171 | 184 | } |
| 172 | − return bytecount; | |
| 173 | −error_return: | |
| 174 | − return err; | |
| 185 | + retval = bytecount; | |
| 186 | + | |
| 187 | +out_unlock: | |
| 188 | + mutex_unlock(&mm->context.lock); | |
| 189 | + return retval; | |
| 175 | 190 | } |
| 176 | 191 | |
| 177 | 192 | static int read_default_ldt(void __user *ptr, unsigned long bytecount) |
| @@ -195,6 +210,8 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) · 17 unmodified lines | ||
| 195 | 210 | struct desc_struct ldt; |
| 196 | 211 | int error; |
| 197 | 212 | struct user_desc ldt_info; |
| 213 | + int oldsize, newsize; | |
| 214 | + struct ldt_struct *new_ldt, *old_ldt; | |
| 198 | 215 | |
| 199 | 216 | error = -EINVAL; |
| 200 | 217 | if (bytecount != sizeof(ldt_info)) |
| @@ -213,34 +230,39 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) · 12 unmodified lines | ||
| 213 | 230 | goto out; |
| 214 | 231 | } |
| 215 | 232 | |
| 216 | − mutex_lock(&mm->context.lock); | |
| 217 | − if (ldt_info.entry_number >= mm->context.size) { | |
| 218 | − error = alloc_ldt(¤t->mm->context, | |
| 219 | − ldt_info.entry_number + 1, 1); | |
| 220 | − if (error < 0) | |
| 221 | − goto out_unlock; | |
| 222 | − } | |
| 223 | − | |
| 224 | − /* Allow LDTs to be cleared by the user. */ | |
| 225 | − if (ldt_info.base_addr == 0 && ldt_info.limit == 0) { | |
| 226 | − if (oldmode || LDT_empty(&ldt_info)) { | |
| 227 | − memset(&ldt, 0, sizeof(ldt)); | |
| 228 | − goto install; | |
| 233 | + if ((oldmode && !ldt_info.base_addr && !ldt_info.limit) || | |
| 234 | + LDT_empty(&ldt_info)) { | |
| 235 | + /* The user wants to clear the entry. */ | |
| 236 | + memset(&ldt, 0, sizeof(ldt)); | |
| 237 | + } else { | |
| 238 | + if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) { | |
| 239 | + error = -EINVAL; | |
| 240 | + goto out; | |
| 229 | 241 | } |
| 242 | + | |
| 243 | + fill_ldt(&ldt, &ldt_info); | |
| 244 | + if (oldmode) | |
| 245 | + ldt.avl = 0; | |
| 230 | 246 | } |
| 231 | 247 | |
| 232 | − if (!IS_ENABLED(CONFIG_X86_16BIT) && !ldt_info.seg_32bit) { | |
| 233 | − error = -EINVAL; | |
| 248 | + mutex_lock(&mm->context.lock); | |
| 249 | + | |
| 250 | + old_ldt = mm->context.ldt; | |
| 251 | + oldsize = old_ldt ? old_ldt->size : 0; | |
| 252 | + newsize = max((int)(ldt_info.entry_number + 1), oldsize); | |
| 253 | + | |
| 254 | + error = -ENOMEM; | |
| 255 | + new_ldt = alloc_ldt_struct(newsize); | |
| 256 | + if (!new_ldt) | |
| 234 | 257 | goto out_unlock; |
| 235 | − } | |
| 236 | 258 | |
| 237 | − fill_ldt(&ldt, &ldt_info); | |
| 238 | − if (oldmode) | |
| 239 | − ldt.avl = 0; | |
| 259 | + if (old_ldt) | |
| 260 | + memcpy(new_ldt->entries, old_ldt->entries, oldsize * LDT_ENTRY_SIZE); | |
| 261 | + new_ldt->entries[ldt_info.entry_number] = ldt; | |
| 262 | + finalize_ldt_struct(new_ldt); | |
| 240 | 263 | |
| 241 | − /* Install the new entry ... */ | |
| 242 | −install: | |
| 243 | − write_ldt_entry(mm->context.ldt, ldt_info.entry_number, &ldt); | |
| 264 | + install_ldt(mm, new_ldt); | |
| 265 | + free_ldt_struct(old_ldt); | |
| 244 | 266 | error = 0; |
| 245 | 267 | |
| 246 | 268 | out_unlock: |
| @@ -121,11 +121,11 @@ void __show_regs(struct pt_regs *regs, int all) · 120 unmodified lines | ||
| 121 | 121 | void release_thread(struct task_struct *dead_task) |
| 122 | 122 | { |
| 123 | 123 | if (dead_task->mm) { |
| 124 | − if (dead_task->mm->context.size) { | |
| 124 | + if (dead_task->mm->context.ldt) { | |
| 125 | 125 | pr_warn("WARNING: dead process %s still has LDT? <%p/%d>\n", |
| 126 | 126 | dead_task->comm, |
| 127 | 127 | dead_task->mm->context.ldt, |
| 128 | − dead_task->mm->context.size); | |
| 128 | + dead_task->mm->context.ldt->size); | |
| 129 | 129 | BUG(); |
| 130 | 130 | } |
| 131 | 131 | } |
| @@ -93,8 +93,15 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) · 92 unmodified lines | ||
| 93 | 93 | COPY(r15); |
| 94 | 94 | #endif /* CONFIG_X86_64 */ |
| 95 | 95 | |
| 96 | +#ifdef CONFIG_X86_32 | |
| 96 | 97 | COPY_SEG_CPL3(cs); |
| 97 | 98 | COPY_SEG_CPL3(ss); |
| 99 | +#else /* !CONFIG_X86_32 */ | |
| 100 | + /* Kernel saves and restores only the CS segment register on signals, | |
| 101 | + * which is the bare minimum needed to allow mixed 32/64-bit code. | |
| 102 | + * App's signal handler can save/restore other segments if needed. */ | |
| 103 | + COPY_SEG_CPL3(cs); | |
| 104 | +#endif /* CONFIG_X86_32 */ | |
| 98 | 105 | |
| 99 | 106 | get_user_ex(tmpflags, &sc->flags); |
| 100 | 107 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); |
| @@ -154,9 +161,8 @@ int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate, · 53 unmodified lines | ||
| 154 | 161 | #else /* !CONFIG_X86_32 */ |
| 155 | 162 | put_user_ex(regs->flags, &sc->flags); |
| 156 | 163 | put_user_ex(regs->cs, &sc->cs); |
| 157 | − put_user_ex(0, &sc->__pad2); | |
| 158 | − put_user_ex(0, &sc->__pad1); | |
| 159 | − put_user_ex(regs->ss, &sc->ss); | |
| 164 | + put_user_ex(0, &sc->gs); | |
| 165 | + put_user_ex(0, &sc->fs); | |
| 160 | 166 | #endif /* CONFIG_X86_32 */ |
| 161 | 167 | |
| 162 | 168 | put_user_ex(fpstate, &sc->fpstate); |
| @@ -451,19 +457,9 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig, · 288 unmodified lines | ||
| 451 | 457 | |
| 452 | 458 | regs->sp = (unsigned long)frame; |
| 453 | 459 | |
| 454 | − /* | |
| 455 | − * Set up the CS and SS registers to run signal handlers in | |
| 456 | − * 64-bit mode, even if the handler happens to be interrupting | |
| 457 | − * 32-bit or 16-bit code. | |
| 458 | − * | |
| 459 | − * SS is subtle. In 64-bit mode, we don't need any particular | |
| 460 | − * SS descriptor, but we do need SS to be valid. It's possible | |
| 461 | − * that the old SS is entirely bogus -- this can happen if the | |
| 462 | − * signal we're trying to deliver is #GP or #SS caused by a bad | |
| 463 | − * SS value. | |
| 464 | − */ | |
| 460 | + /* Set up the CS register to run signal handlers in 64-bit mode, | |
| 461 | + even if the handler happens to be interrupting 32-bit code. */ | |
| 465 | 462 | regs->cs = __USER_CS; |
| 466 | − regs->ss = __USER_DS; | |
| 467 | 463 | |
| 468 | 464 | return 0; |
| 469 | 465 | } |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | #include <linux/mm.h> |
| 6 | 6 | #include <linux/ptrace.h> |
| 7 | 7 | #include <asm/desc.h> |
| 8 | +#include <asm/mmu_context.h> | |
| 8 | 9 | |
| 9 | 10 | unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs) |
| 10 | 11 | { |
| @@ -30,10 +31,11 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re · 19 unmodified lines | ||
| 30 | 31 | seg &= ~7UL; |
| 31 | 32 | |
| 32 | 33 | mutex_lock(&child->mm->context.lock); |
| 33 | − if (unlikely((seg >> 3) >= child->mm->context.size)) | |
| 34 | + if (unlikely(!child->mm->context.ldt || | |
| 35 | + (seg >> 3) >= child->mm->context.ldt->size)) | |
| 34 | 36 | addr = -1L; /* bogus selector, access would fault */ |
| 35 | 37 | else { |
| 36 | − desc = child->mm->context.ldt + seg; | |
| 38 | + desc = &child->mm->context.ldt->entries[seg]; | |
| 37 | 39 | base = get_desc_base(desc); |
| 38 | 40 | |
| 39 | 41 | /* 16-bit code segment? */ |
| @@ -672,16 +672,16 @@ u8 kvm_mtrr_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn) · 671 unmodified lines | ||
| 672 | 672 | if (iter.mtrr_disabled) |
| 673 | 673 | return mtrr_disabled_type(); |
| 674 | 674 | |
| 675 | + /* not contained in any MTRRs. */ | |
| 676 | + if (type == -1) | |
| 677 | + return mtrr_default_type(mtrr_state); | |
| 678 | + | |
| 675 | 679 | /* |
| 676 | 680 | * We just check one page, partially covered by MTRRs is |
| 677 | 681 | * impossible. |
| 678 | 682 | */ |
| 679 | 683 | WARN_ON(iter.partial_map); |
| 680 | 684 | |
| 681 | − /* not contained in any MTRRs. */ | |
| 682 | − if (type == -1) | |
| 683 | − return mtrr_default_type(mtrr_state); | |
| 684 | − | |
| 685 | 685 | return type; |
| 686 | 686 | } |
| 687 | 687 | EXPORT_SYMBOL_GPL(kvm_mtrr_get_guest_memory_type); |
| @@ -972,6 +972,11 @@ u64 efi_mem_attributes(unsigned long phys_addr) · 971 unmodified lines | ||
| 972 | 972 | |
| 973 | 973 | static int __init arch_parse_efi_cmdline(char *str) |
| 974 | 974 | { |
| 975 | + if (!str) { | |
| 976 | + pr_warn("need at least one option\n"); | |
| 977 | + return -EINVAL; | |
| 978 | + } | |
| 979 | + | |
| 975 | 980 | if (parse_option_str(str, "old_map")) |
| 976 | 981 | set_bit(EFI_OLD_MEMMAP, &efi.flags); |
| 977 | 982 | if (parse_option_str(str, "debug")) |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include <asm/fpu/internal.h> |
| 23 | 23 | #include <asm/debugreg.h> |
| 24 | 24 | #include <asm/cpu.h> |
| 25 | +#include <asm/mmu_context.h> | |
| 25 | 26 | |
| 26 | 27 | #ifdef CONFIG_X86_32 |
| 27 | 28 | __visible unsigned long saved_context_ebx; |
| @@ -153,7 +154,7 @@ static void fix_processor_context(void) · 125 unmodified lines | ||
| 153 | 154 | syscall_init(); /* This sets MSR_*STAR and related */ |
| 154 | 155 | #endif |
| 155 | 156 | load_TR_desc(); /* This does ltr */ |
| 156 | − load_LDT(¤t->active_mm->context); /* This does lldt */ | |
| 157 | + load_mm_ldt(current->active_mm); /* This does lldt */ | |
| 157 | 158 | |
| 158 | 159 | fpu__resume_cpu(); |
| 159 | 160 | } |
| @@ -13,13 +13,13 @@ CFLAGS_mmu.o := $(nostackp) · 12 unmodified lines | ||
| 13 | 13 | obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ |
| 14 | 14 | time.o xen-asm.o xen-asm_$(BITS).o \ |
| 15 | 15 | grant-table.o suspend.o platform-pci-unplug.o \ |
| 16 | − p2m.o | |
| 16 | + p2m.o apic.o | |
| 17 | 17 | |
| 18 | 18 | obj-$(CONFIG_EVENT_TRACING) += trace.o |
| 19 | 19 | |
| 20 | 20 | obj-$(CONFIG_SMP) += smp.o |
| 21 | 21 | obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o |
| 22 | 22 | obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o |
| 23 | −obj-$(CONFIG_XEN_DOM0) += apic.o vga.o | |
| 23 | +obj-$(CONFIG_XEN_DOM0) += vga.o | |
| 24 | 24 | obj-$(CONFIG_SWIOTLB_XEN) += pci-swiotlb-xen.o |
| 25 | 25 | obj-$(CONFIG_XEN_EFI) += efi.o |
| @@ -483,6 +483,7 @@ static void set_aliased_prot(void *v, pgprot_t prot) · 482 unmodified lines | ||
| 483 | 483 | pte_t pte; |
| 484 | 484 | unsigned long pfn; |
| 485 | 485 | struct page *page; |
| 486 | + unsigned char dummy; | |
| 486 | 487 | |
| 487 | 488 | ptep = lookup_address((unsigned long)v, &level); |
| 488 | 489 | BUG_ON(ptep == NULL); |
| @@ -492,6 +493,32 @@ static void set_aliased_prot(void *v, pgprot_t prot) · 3 unmodified lines | ||
| 492 | 493 | |
| 493 | 494 | pte = pfn_pte(pfn, prot); |
| 494 | 495 | |
| 496 | + /* | |
| 497 | + * Careful: update_va_mapping() will fail if the virtual address | |
| 498 | + * we're poking isn't populated in the page tables. We don't | |
| 499 | + * need to worry about the direct map (that's always in the page | |
| 500 | + * tables), but we need to be careful about vmap space. In | |
| 501 | + * particular, the top level page table can lazily propagate | |
| 502 | + * entries between processes, so if we've switched mms since we | |
| 503 | + * vmapped the target in the first place, we might not have the | |
| 504 | + * top-level page table entry populated. | |
| 505 | + * | |
| 506 | + * We disable preemption because we want the same mm active when | |
| 507 | + * we probe the target and when we issue the hypercall. We'll | |
| 508 | + * have the same nominal mm, but if we're a kernel thread, lazy | |
| 509 | + * mm dropping could change our pgd. | |
| 510 | + * | |
| 511 | + * Out of an abundance of caution, this uses __get_user() to fault | |
| 512 | + * in the target address just in case there's some obscure case | |
| 513 | + * in which the target address isn't readable. | |
| 514 | + */ | |
| 515 | + | |
| 516 | + preempt_disable(); | |
| 517 | + | |
| 518 | + pagefault_disable(); /* Avoid warnings due to being atomic. */ | |
| 519 | + __get_user(dummy, (unsigned char __user __force *)v); | |
| 520 | + pagefault_enable(); | |
| 521 | + | |
| 495 | 522 | if (HYPERVISOR_update_va_mapping((unsigned long)v, pte, 0)) |
| 496 | 523 | BUG(); |
| 497 | 524 | |
| @@ -503,6 +530,8 @@ static void set_aliased_prot(void *v, pgprot_t prot) · 5 unmodified lines | ||
| 503 | 530 | BUG(); |
| 504 | 531 | } else |
| 505 | 532 | kmap_flush_unused(); |
| 533 | + | |
| 534 | + preempt_enable(); | |
| 506 | 535 | } |
| 507 | 536 | |
| 508 | 537 | static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries) |
| @@ -510,6 +539,17 @@ static void xen_alloc_ldt(struct desc_struct *ldt, unsigned entries) · 1 unmodified line | ||
| 510 | 539 | const unsigned entries_per_page = PAGE_SIZE / LDT_ENTRY_SIZE; |
| 511 | 540 | int i; |
| 512 | 541 | |
| 542 | + /* | |
| 543 | + * We need to mark the all aliases of the LDT pages RO. We | |
| 544 | + * don't need to call vm_flush_aliases(), though, since that's | |
| 545 | + * only responsible for flushing aliases out the TLBs, not the | |
| 546 | + * page tables, and Xen will flush the TLB for us if needed. | |
| 547 | + * | |
| 548 | + * To avoid confusing future readers: none of this is necessary | |
| 549 | + * to load the LDT. The hypervisor only checks this when the | |
| 550 | + * LDT is faulted in due to subsequent descriptor access. | |
| 551 | + */ | |
| 552 | + | |
| 513 | 553 | for(i = 0; i < entries; i += entries_per_page) |
| 514 | 554 | set_aliased_prot(ldt + i, PAGE_KERNEL_RO); |
| 515 | 555 | } |
| @@ -101,17 +101,15 @@ struct dom0_vga_console_info; · 100 unmodified lines | ||
| 101 | 101 | |
| 102 | 102 | #ifdef CONFIG_XEN_DOM0 |
| 103 | 103 | void __init xen_init_vga(const struct dom0_vga_console_info *, size_t size); |
| 104 | −void __init xen_init_apic(void); | |
| 105 | 104 | #else |
| 106 | 105 | static inline void __init xen_init_vga(const struct dom0_vga_console_info *info, |
| 107 | 106 | size_t size) |
| 108 | 107 | { |
| 109 | 108 | } |
| 110 | −static inline void __init xen_init_apic(void) | |
| 111 | −{ | |
| 112 | −} | |
| 113 | 109 | #endif |
| 114 | 110 | |
| 111 | +void __init xen_init_apic(void); | |
| 112 | + | |
| 115 | 113 | #ifdef CONFIG_XEN_EFI |
| 116 | 114 | extern void xen_efi_init(void); |
| 117 | 115 | #else |
| @@ -296,11 +296,20 @@ static int regcache_rbtree_insert_to_block(struct regmap *map, · 295 unmodified lines | ||
| 296 | 296 | if (!blk) |
| 297 | 297 | return -ENOMEM; |
| 298 | 298 | |
| 299 | − present = krealloc(rbnode->cache_present, | |
| 300 | − BITS_TO_LONGS(blklen) * sizeof(*present), GFP_KERNEL); | |
| 301 | − if (!present) { | |
| 302 | − kfree(blk); | |
| 303 | − return -ENOMEM; | |
| 299 | + if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) { | |
| 300 | + present = krealloc(rbnode->cache_present, | |
| 301 | + BITS_TO_LONGS(blklen) * sizeof(*present), | |
| 302 | + GFP_KERNEL); | |
| 303 | + if (!present) { | |
| 304 | + kfree(blk); | |
| 305 | + return -ENOMEM; | |
| 306 | + } | |
| 307 | + | |
| 308 | + memset(present + BITS_TO_LONGS(rbnode->blklen), 0, | |
| 309 | + (BITS_TO_LONGS(blklen) - BITS_TO_LONGS(rbnode->blklen)) | |
| 310 | + * sizeof(*present)); | |
| 311 | + } else { | |
| 312 | + present = rbnode->cache_present; | |
| 304 | 313 | } |
| 305 | 314 | |
| 306 | 315 | /* insert the register value in the correct place in the rbnode block */ |
| @@ -523,6 +523,7 @@ void rbd_warn(struct rbd_device *rbd_dev, const char *fmt, ...) · 522 unmodified lines | ||
| 523 | 523 | # define rbd_assert(expr) ((void) 0) |
| 524 | 524 | #endif /* !RBD_DEBUG */ |
| 525 | 525 | |
| 526 | +static void rbd_osd_copyup_callback(struct rbd_obj_request *obj_request); | |
| 526 | 527 | static int rbd_img_obj_request_submit(struct rbd_obj_request *obj_request); |
| 527 | 528 | static void rbd_img_parent_read(struct rbd_obj_request *obj_request); |
| 528 | 529 | static void rbd_dev_remove_parent(struct rbd_device *rbd_dev); |
| @@ -1818,6 +1819,16 @@ static void rbd_osd_stat_callback(struct rbd_obj_request *obj_request) · 1289 unmodified lines | ||
| 1818 | 1819 | obj_request_done_set(obj_request); |
| 1819 | 1820 | } |
| 1820 | 1821 | |
| 1822 | +static void rbd_osd_call_callback(struct rbd_obj_request *obj_request) | |
| 1823 | +{ | |
| 1824 | + dout("%s: obj %p\n", __func__, obj_request); | |
| 1825 | + | |
| 1826 | + if (obj_request_img_data_test(obj_request)) | |
| 1827 | + rbd_osd_copyup_callback(obj_request); | |
| 1828 | + else | |
| 1829 | + obj_request_done_set(obj_request); | |
| 1830 | +} | |
| 1831 | + | |
| 1821 | 1832 | static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, |
| 1822 | 1833 | struct ceph_msg *msg) |
| 1823 | 1834 | { |
| @@ -1866,6 +1877,8 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req, · 42 unmodified lines | ||
| 1866 | 1877 | rbd_osd_discard_callback(obj_request); |
| 1867 | 1878 | break; |
| 1868 | 1879 | case CEPH_OSD_OP_CALL: |
| 1880 | + rbd_osd_call_callback(obj_request); | |
| 1881 | + break; | |
| 1869 | 1882 | case CEPH_OSD_OP_NOTIFY_ACK: |
| 1870 | 1883 | case CEPH_OSD_OP_WATCH: |
| 1871 | 1884 | rbd_osd_trivial_callback(obj_request); |
| @@ -2530,13 +2543,15 @@ out_unwind: · 658 unmodified lines | ||
| 2530 | 2543 | } |
| 2531 | 2544 | |
| 2532 | 2545 | static void |
| 2533 | −rbd_img_obj_copyup_callback(struct rbd_obj_request *obj_request) | |
| 2546 | +rbd_osd_copyup_callback(struct rbd_obj_request *obj_request) | |
| 2534 | 2547 | { |
| 2535 | 2548 | struct rbd_img_request *img_request; |
| 2536 | 2549 | struct rbd_device *rbd_dev; |
| 2537 | 2550 | struct page **pages; |
| 2538 | 2551 | u32 page_count; |
| 2539 | 2552 | |
| 2553 | + dout("%s: obj %p\n", __func__, obj_request); | |
| 2554 | + | |
| 2540 | 2555 | rbd_assert(obj_request->type == OBJ_REQUEST_BIO || |
| 2541 | 2556 | obj_request->type == OBJ_REQUEST_NODATA); |
| 2542 | 2557 | rbd_assert(obj_request_img_data_test(obj_request)); |
| @@ -2563,9 +2578,7 @@ rbd_img_obj_copyup_callback(struct rbd_obj_request *obj_request) · 20 unmodified lines | ||
| 2563 | 2578 | if (!obj_request->result) |
| 2564 | 2579 | obj_request->xferred = obj_request->length; |
| 2565 | 2580 | |
| 2566 | − /* Finish up with the normal image object callback */ | |
| 2567 | − | |
| 2568 | − rbd_img_obj_callback(obj_request); | |
| 2581 | + obj_request_done_set(obj_request); | |
| 2569 | 2582 | } |
| 2570 | 2583 | |
| 2571 | 2584 | static void |
| @@ -2650,7 +2663,6 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request) · 78 unmodified lines | ||
| 2650 | 2663 | |
| 2651 | 2664 | /* All set, send it off. */ |
| 2652 | 2665 | |
| 2653 | − orig_request->callback = rbd_img_obj_copyup_callback; | |
| 2654 | 2666 | osdc = &rbd_dev->rbd_client->client->osdc; |
| 2655 | 2667 | img_result = rbd_obj_request_submit(osdc, orig_request); |
| 2656 | 2668 | if (!img_result) |
| @@ -369,8 +369,8 @@ static void purge_persistent_gnt(struct xen_blkif *blkif) · 368 unmodified lines | ||
| 369 | 369 | return; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | − if (work_pending(&blkif->persistent_purge_work)) { | |
| 373 | − pr_alert_ratelimited("Scheduled work from previous purge is still pending, cannot purge list\n"); | |
| 372 | + if (work_busy(&blkif->persistent_purge_work)) { | |
| 373 | + pr_alert_ratelimited("Scheduled work from previous purge is still busy, cannot purge list\n"); | |
| 374 | 374 | return; |
| 375 | 375 | } |
| 376 | 376 | |
| @@ -179,6 +179,7 @@ static DEFINE_SPINLOCK(minor_lock); · 178 unmodified lines | ||
| 179 | 179 | ((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME) |
| 180 | 180 | |
| 181 | 181 | static int blkfront_setup_indirect(struct blkfront_info *info); |
| 182 | +static int blkfront_gather_backend_features(struct blkfront_info *info); | |
| 182 | 183 | |
| 183 | 184 | static int get_id_from_freelist(struct blkfront_info *info) |
| 184 | 185 | { |
| @@ -1128,8 +1129,10 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info, · 943 unmodified lines | ||
| 1128 | 1129 | * Add the used indirect page back to the list of |
| 1129 | 1130 | * available pages for indirect grefs. |
| 1130 | 1131 | */ |
| 1131 | − indirect_page = pfn_to_page(s->indirect_grants[i]->pfn); | |
| 1132 | − list_add(&indirect_page->lru, &info->indirect_pages); | |
| 1132 | + if (!info->feature_persistent) { | |
| 1133 | + indirect_page = pfn_to_page(s->indirect_grants[i]->pfn); | |
| 1134 | + list_add(&indirect_page->lru, &info->indirect_pages); | |
| 1135 | + } | |
| 1133 | 1136 | s->indirect_grants[i]->gref = GRANT_INVALID_REF; |
| 1134 | 1137 | list_add_tail(&s->indirect_grants[i]->node, &info->grants); |
| 1135 | 1138 | } |
| @@ -1519,7 +1522,7 @@ static int blkif_recover(struct blkfront_info *info) · 383 unmodified lines | ||
| 1519 | 1522 | info->shadow_free = info->ring.req_prod_pvt; |
| 1520 | 1523 | info->shadow[BLK_RING_SIZE(info)-1].req.u.rw.id = 0x0fffffff; |
| 1521 | 1524 | |
| 1522 | − rc = blkfront_setup_indirect(info); | |
| 1525 | + rc = blkfront_gather_backend_features(info); | |
| 1523 | 1526 | if (rc) { |
| 1524 | 1527 | kfree(copy); |
| 1525 | 1528 | return rc; |
| @@ -1720,20 +1723,13 @@ static void blkfront_setup_discard(struct blkfront_info *info) · 194 unmodified lines | ||
| 1720 | 1723 | |
| 1721 | 1724 | static int blkfront_setup_indirect(struct blkfront_info *info) |
| 1722 | 1725 | { |
| 1723 | − unsigned int indirect_segments, segs; | |
| 1726 | + unsigned int segs; | |
| 1724 | 1727 | int err, i; |
| 1725 | 1728 | |
| 1726 | − err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1727 | − "feature-max-indirect-segments", "%u", &indirect_segments, | |
| 1728 | − NULL); | |
| 1729 | − if (err) { | |
| 1730 | − info->max_indirect_segments = 0; | |
| 1729 | + if (info->max_indirect_segments == 0) | |
| 1731 | 1730 | segs = BLKIF_MAX_SEGMENTS_PER_REQUEST; |
| 1732 | − } else { | |
| 1733 | − info->max_indirect_segments = min(indirect_segments, | |
| 1734 | − xen_blkif_max_segments); | |
| 1731 | + else | |
| 1735 | 1732 | segs = info->max_indirect_segments; |
| 1736 | − } | |
| 1737 | 1733 | |
| 1738 | 1734 | err = fill_grant_buffer(info, (segs + INDIRECT_GREFS(segs)) * BLK_RING_SIZE(info)); |
| 1739 | 1735 | if (err) |
| @@ -1796,6 +1792,68 @@ out_of_memory: · 56 unmodified lines | ||
| 1796 | 1792 | return -ENOMEM; |
| 1797 | 1793 | } |
| 1798 | 1794 | |
| 1795 | +/* | |
| 1796 | + * Gather all backend feature-* | |
| 1797 | + */ | |
| 1798 | +static int blkfront_gather_backend_features(struct blkfront_info *info) | |
| 1799 | +{ | |
| 1800 | + int err; | |
| 1801 | + int barrier, flush, discard, persistent; | |
| 1802 | + unsigned int indirect_segments; | |
| 1803 | + | |
| 1804 | + info->feature_flush = 0; | |
| 1805 | + | |
| 1806 | + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1807 | + "feature-barrier", "%d", &barrier, | |
| 1808 | + NULL); | |
| 1809 | + | |
| 1810 | + /* | |
| 1811 | + * If there's no "feature-barrier" defined, then it means | |
| 1812 | + * we're dealing with a very old backend which writes | |
| 1813 | + * synchronously; nothing to do. | |
| 1814 | + * | |
| 1815 | + * If there are barriers, then we use flush. | |
| 1816 | + */ | |
| 1817 | + if (!err && barrier) | |
| 1818 | + info->feature_flush = REQ_FLUSH | REQ_FUA; | |
| 1819 | + /* | |
| 1820 | + * And if there is "feature-flush-cache" use that above | |
| 1821 | + * barriers. | |
| 1822 | + */ | |
| 1823 | + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1824 | + "feature-flush-cache", "%d", &flush, | |
| 1825 | + NULL); | |
| 1826 | + | |
| 1827 | + if (!err && flush) | |
| 1828 | + info->feature_flush = REQ_FLUSH; | |
| 1829 | + | |
| 1830 | + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1831 | + "feature-discard", "%d", &discard, | |
| 1832 | + NULL); | |
| 1833 | + | |
| 1834 | + if (!err && discard) | |
| 1835 | + blkfront_setup_discard(info); | |
| 1836 | + | |
| 1837 | + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1838 | + "feature-persistent", "%u", &persistent, | |
| 1839 | + NULL); | |
| 1840 | + if (err) | |
| 1841 | + info->feature_persistent = 0; | |
| 1842 | + else | |
| 1843 | + info->feature_persistent = persistent; | |
| 1844 | + | |
| 1845 | + err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1846 | + "feature-max-indirect-segments", "%u", &indirect_segments, | |
| 1847 | + NULL); | |
| 1848 | + if (err) | |
| 1849 | + info->max_indirect_segments = 0; | |
| 1850 | + else | |
| 1851 | + info->max_indirect_segments = min(indirect_segments, | |
| 1852 | + xen_blkif_max_segments); | |
| 1853 | + | |
| 1854 | + return blkfront_setup_indirect(info); | |
| 1855 | +} | |
| 1856 | + | |
| 1799 | 1857 | /* |
| 1800 | 1858 | * Invoked when the backend is finally 'ready' (and has told produced |
| 1801 | 1859 | * the details about the physical device - #sectors, size, etc). |
| @@ -1807,7 +1865,6 @@ static void blkfront_connect(struct blkfront_info *info) · 5 unmodified lines | ||
| 1807 | 1865 | unsigned int physical_sector_size; |
| 1808 | 1866 | unsigned int binfo; |
| 1809 | 1867 | int err; |
| 1810 | − int barrier, flush, discard, persistent; | |
| 1811 | 1868 | |
| 1812 | 1869 | switch (info->connected) { |
| 1813 | 1870 | case BLKIF_STATE_CONNECTED: |
| @@ -1864,48 +1921,7 @@ static void blkfront_connect(struct blkfront_info *info) · 50 unmodified lines | ||
| 1864 | 1921 | if (err != 1) |
| 1865 | 1922 | physical_sector_size = sector_size; |
| 1866 | 1923 | |
| 1867 | − info->feature_flush = 0; | |
| 1868 | − | |
| 1869 | − err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1870 | − "feature-barrier", "%d", &barrier, | |
| 1871 | − NULL); | |
| 1872 | − | |
| 1873 | − /* | |
| 1874 | − * If there's no "feature-barrier" defined, then it means | |
| 1875 | − * we're dealing with a very old backend which writes | |
| 1876 | − * synchronously; nothing to do. | |
| 1877 | − * | |
| 1878 | − * If there are barriers, then we use flush. | |
| 1879 | − */ | |
| 1880 | − if (!err && barrier) | |
| 1881 | − info->feature_flush = REQ_FLUSH | REQ_FUA; | |
| 1882 | − /* | |
| 1883 | − * And if there is "feature-flush-cache" use that above | |
| 1884 | − * barriers. | |
| 1885 | − */ | |
| 1886 | − err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1887 | − "feature-flush-cache", "%d", &flush, | |
| 1888 | − NULL); | |
| 1889 | − | |
| 1890 | − if (!err && flush) | |
| 1891 | − info->feature_flush = REQ_FLUSH; | |
| 1892 | − | |
| 1893 | − err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1894 | − "feature-discard", "%d", &discard, | |
| 1895 | − NULL); | |
| 1896 | − | |
| 1897 | − if (!err && discard) | |
| 1898 | − blkfront_setup_discard(info); | |
| 1899 | − | |
| 1900 | − err = xenbus_gather(XBT_NIL, info->xbdev->otherend, | |
| 1901 | − "feature-persistent", "%u", &persistent, | |
| 1902 | − NULL); | |
| 1903 | − if (err) | |
| 1904 | − info->feature_persistent = 0; | |
| 1905 | − else | |
| 1906 | − info->feature_persistent = persistent; | |
| 1907 | − | |
| 1908 | − err = blkfront_setup_indirect(info); | |
| 1924 | + err = blkfront_gather_backend_features(info); | |
| 1909 | 1925 | if (err) { |
| 1910 | 1926 | xenbus_dev_fatal(info->xbdev, err, "setup_indirect at %s", |
| 1911 | 1927 | info->xbdev->otherend); |
| @@ -429,7 +429,7 @@ static int hwrng_fillfn(void *unused) · 428 unmodified lines | ||
| 429 | 429 | static void start_khwrngd(void) |
| 430 | 430 | { |
| 431 | 431 | hwrng_fill = kthread_run(hwrng_fillfn, NULL, "hwrng"); |
| 432 | − if (hwrng_fill == ERR_PTR(-ENOMEM)) { | |
| 432 | + if (IS_ERR(hwrng_fill)) { | |
| 433 | 433 | pr_err("hwrng_fill thread creation failed"); |
| 434 | 434 | hwrng_fill = NULL; |
| 435 | 435 | } |
| @@ -20,7 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <asm/clock.h> |
| 21 | 21 | #include <asm/idle.h> |
| 22 | 22 | |
| 23 | −#include <asm/mach-loongson/loongson.h> | |
| 23 | +#include <asm/mach-loongson64/loongson.h> | |
| 24 | 24 | |
| 25 | 25 | static uint nowait; |
| 26 | 26 | |
| @@ -905,7 +905,6 @@ static int ablk_perform(struct ablkcipher_request *req, int encrypt) · 904 unmodified lines | ||
| 905 | 905 | crypt->mode |= NPE_OP_NOT_IN_PLACE; |
| 906 | 906 | /* This was never tested by Intel |
| 907 | 907 | * for more than one dst buffer, I think. */ |
| 908 | − BUG_ON(req->dst->length < nbytes); | |
| 909 | 908 | req_ctx->dst = NULL; |
| 910 | 909 | if (!chainup_buffers(dev, req->dst, nbytes, &dst_hook, |
| 911 | 910 | flags, DMA_FROM_DEVICE)) |
| @@ -73,7 +73,8 @@ · 72 unmodified lines | ||
| 73 | 73 | ICP_QAT_HW_CIPHER_KEY_CONVERT, \ |
| 74 | 74 | ICP_QAT_HW_CIPHER_DECRYPT) |
| 75 | 75 | |
| 76 | −static atomic_t active_dev; | |
| 76 | +static DEFINE_MUTEX(algs_lock); | |
| 77 | +static unsigned int active_devs; | |
| 77 | 78 | |
| 78 | 79 | struct qat_alg_buf { |
| 79 | 80 | uint32_t len; |
| @@ -1280,7 +1281,10 @@ static struct crypto_alg qat_algs[] = { { · 1200 unmodified lines | ||
| 1280 | 1281 | |
| 1281 | 1282 | int qat_algs_register(void) |
| 1282 | 1283 | { |
| 1283 | − if (atomic_add_return(1, &active_dev) == 1) { | |
| 1284 | + int ret = 0; | |
| 1285 | + | |
| 1286 | + mutex_lock(&algs_lock); | |
| 1287 | + if (++active_devs == 1) { | |
| 1284 | 1288 | int i; |
| 1285 | 1289 | |
| 1286 | 1290 | for (i = 0; i < ARRAY_SIZE(qat_algs); i++) |
| @@ -1289,21 +1293,25 @@ int qat_algs_register(void) · 2 unmodified lines | ||
| 1289 | 1293 | CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC : |
| 1290 | 1294 | CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC; |
| 1291 | 1295 | |
| 1292 | − return crypto_register_algs(qat_algs, ARRAY_SIZE(qat_algs)); | |
| 1296 | + ret = crypto_register_algs(qat_algs, ARRAY_SIZE(qat_algs)); | |
| 1293 | 1297 | } |
| 1294 | − return 0; | |
| 1298 | + mutex_unlock(&algs_lock); | |
| 1299 | + return ret; | |
| 1295 | 1300 | } |
| 1296 | 1301 | |
| 1297 | 1302 | int qat_algs_unregister(void) |
| 1298 | 1303 | { |
| 1299 | − if (atomic_sub_return(1, &active_dev) == 0) | |
| 1300 | − return crypto_unregister_algs(qat_algs, ARRAY_SIZE(qat_algs)); | |
| 1301 | − return 0; | |
| 1304 | + int ret = 0; | |
| 1305 | + | |
| 1306 | + mutex_lock(&algs_lock); | |
| 1307 | + if (--active_devs == 0) | |
| 1308 | + ret = crypto_unregister_algs(qat_algs, ARRAY_SIZE(qat_algs)); | |
| 1309 | + mutex_unlock(&algs_lock); | |
| 1310 | + return ret; | |
| 1302 | 1311 | } |
| 1303 | 1312 | |
| 1304 | 1313 | int qat_algs_init(void) |
| 1305 | 1314 | { |
| 1306 | − atomic_set(&active_dev, 0); | |
| 1307 | 1315 | crypto_get_default_rng(); |
| 1308 | 1316 | return 0; |
| 1309 | 1317 | } |
| @@ -48,6 +48,8 @@ · 47 unmodified lines | ||
| 48 | 48 | BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |\ |
| 49 | 49 | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES)) |
| 50 | 50 | |
| 51 | +#define ATC_MAX_DSCR_TRIALS 10 | |
| 52 | + | |
| 51 | 53 | /* |
| 52 | 54 | * Initial number of descriptors to allocate for each channel. This could |
| 53 | 55 | * be increased during dma usage. |
| @@ -285,28 +287,19 @@ static struct at_desc *atc_get_desc_by_cookie(struct at_dma_chan *atchan, · 231 unmodified lines | ||
| 285 | 287 | * |
| 286 | 288 | * @current_len: the number of bytes left before reading CTRLA |
| 287 | 289 | * @ctrla: the value of CTRLA |
| 288 | − * @desc: the descriptor containing the transfer width | |
| 289 | 290 | */ |
| 290 | −static inline int atc_calc_bytes_left(int current_len, u32 ctrla, | |
| 291 | − struct at_desc *desc) | |
| 291 | +static inline int atc_calc_bytes_left(int current_len, u32 ctrla) | |
| 292 | 292 | { |
| 293 | − return current_len - ((ctrla & ATC_BTSIZE_MAX) << desc->tx_width); | |
| 294 | −} | |
| 293 | + u32 btsize = (ctrla & ATC_BTSIZE_MAX); | |
| 294 | + u32 src_width = ATC_REG_TO_SRC_WIDTH(ctrla); | |
| 295 | 295 | |
| 296 | −/** | |
| 297 | − * atc_calc_bytes_left_from_reg - calculates the number of bytes left according | |
| 298 | − * to the current value of CTRLA. | |
| 299 | − * | |
| 300 | − * @current_len: the number of bytes left before reading CTRLA | |
| 301 | − * @atchan: the channel to read CTRLA for | |
| 302 | − * @desc: the descriptor containing the transfer width | |
| 303 | − */ | |
| 304 | −static inline int atc_calc_bytes_left_from_reg(int current_len, | |
| 305 | − struct at_dma_chan *atchan, struct at_desc *desc) | |
| 306 | −{ | |
| 307 | − u32 ctrla = channel_readl(atchan, CTRLA); | |
| 308 | − | |
| 309 | − return atc_calc_bytes_left(current_len, ctrla, desc); | |
| 296 | + /* | |
| 297 | + * According to the datasheet, when reading the Control A Register | |
| 298 | + * (ctrla), the Buffer Transfer Size (btsize) bitfield refers to the | |
| 299 | + * number of transfers completed on the Source Interface. | |
| 300 | + * So btsize is always a number of source width transfers. | |
| 301 | + */ | |
| 302 | + return current_len - (btsize << src_width); | |
| 310 | 303 | } |
| 311 | 304 | |
| 312 | 305 | /** |
| @@ -320,7 +313,7 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) · 7 unmodified lines | ||
| 320 | 313 | struct at_desc *desc_first = atc_first_active(atchan); |
| 321 | 314 | struct at_desc *desc; |
| 322 | 315 | int ret; |
| 323 | − u32 ctrla, dscr; | |
| 316 | + u32 ctrla, dscr, trials; | |
| 324 | 317 | |
| 325 | 318 | /* |
| 326 | 319 | * If the cookie doesn't match to the currently running transfer then |
| @@ -346,15 +339,82 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) · 19 unmodified lines | ||
| 346 | 339 | * the channel's DSCR register and compare it against the value |
| 347 | 340 | * of the hardware linked list structure of each child |
| 348 | 341 | * descriptor. |
| 342 | + * | |
| 343 | + * The CTRLA register provides us with the amount of data | |
| 344 | + * already read from the source for the current child | |
| 345 | + * descriptor. So we can compute a more accurate residue by also | |
| 346 | + * removing the number of bytes corresponding to this amount of | |
| 347 | + * data. | |
| 348 | + * | |
| 349 | + * However, the DSCR and CTRLA registers cannot be read both | |
| 350 | + * atomically. Hence a race condition may occur: the first read | |
| 351 | + * register may refer to one child descriptor whereas the second | |
| 352 | + * read may refer to a later child descriptor in the list | |
| 353 | + * because of the DMA transfer progression inbetween the two | |
| 354 | + * reads. | |
| 355 | + * | |
| 356 | + * One solution could have been to pause the DMA transfer, read | |
| 357 | + * the DSCR and CTRLA then resume the DMA transfer. Nonetheless, | |
| 358 | + * this approach presents some drawbacks: | |
| 359 | + * - If the DMA transfer is paused, RX overruns or TX underruns | |
| 360 | + * are more likey to occur depending on the system latency. | |
| 361 | + * Taking the USART driver as an example, it uses a cyclic DMA | |
| 362 | + * transfer to read data from the Receive Holding Register | |
| 363 | + * (RHR) to avoid RX overruns since the RHR is not protected | |
| 364 | + * by any FIFO on most Atmel SoCs. So pausing the DMA transfer | |
| 365 | + * to compute the residue would break the USART driver design. | |
| 366 | + * - The atc_pause() function masks interrupts but we'd rather | |
| 367 | + * avoid to do so for system latency purpose. | |
| 368 | + * | |
| 369 | + * Then we'd rather use another solution: the DSCR is read a | |
| 370 | + * first time, the CTRLA is read in turn, next the DSCR is read | |
| 371 | + * a second time. If the two consecutive read values of the DSCR | |
| 372 | + * are the same then we assume both refers to the very same | |
| 373 | + * child descriptor as well as the CTRLA value read inbetween | |
| 374 | + * does. For cyclic tranfers, the assumption is that a full loop | |
| 375 | + * is "not so fast". | |
| 376 | + * If the two DSCR values are different, we read again the CTRLA | |
| 377 | + * then the DSCR till two consecutive read values from DSCR are | |
| 378 | + * equal or till the maxium trials is reach. | |
| 379 | + * This algorithm is very unlikely not to find a stable value for | |
| 380 | + * DSCR. | |
| 349 | 381 | */ |
| 350 | 382 | |
| 351 | − ctrla = channel_readl(atchan, CTRLA); | |
| 352 | − rmb(); /* ensure CTRLA is read before DSCR */ | |
| 353 | 383 | dscr = channel_readl(atchan, DSCR); |
| 384 | + rmb(); /* ensure DSCR is read before CTRLA */ | |
| 385 | + ctrla = channel_readl(atchan, CTRLA); | |
| 386 | + for (trials = 0; trials < ATC_MAX_DSCR_TRIALS; ++trials) { | |
| 387 | + u32 new_dscr; | |
| 388 | + | |
| 389 | + rmb(); /* ensure DSCR is read after CTRLA */ | |
| 390 | + new_dscr = channel_readl(atchan, DSCR); | |
| 391 | + | |
| 392 | + /* | |
| 393 | + * If the DSCR register value has not changed inside the | |
| 394 | + * DMA controller since the previous read, we assume | |
| 395 | + * that both the dscr and ctrla values refers to the | |
| 396 | + * very same descriptor. | |
| 397 | + */ | |
| 398 | + if (likely(new_dscr == dscr)) | |
| 399 | + break; | |
| 400 | + | |
| 401 | + /* | |
| 402 | + * DSCR has changed inside the DMA controller, so the | |
| 403 | + * previouly read value of CTRLA may refer to an already | |
| 404 | + * processed descriptor hence could be outdated. | |
| 405 | + * We need to update ctrla to match the current | |
| 406 | + * descriptor. | |
| 407 | + */ | |
| 408 | + dscr = new_dscr; | |
| 409 | + rmb(); /* ensure DSCR is read before CTRLA */ | |
| 410 | + ctrla = channel_readl(atchan, CTRLA); | |
| 411 | + } | |
| 412 | + if (unlikely(trials >= ATC_MAX_DSCR_TRIALS)) | |
| 413 | + return -ETIMEDOUT; | |
| 354 | 414 | |
| 355 | 415 | /* for the first descriptor we can be more accurate */ |
| 356 | 416 | if (desc_first->lli.dscr == dscr) |
| 357 | − return atc_calc_bytes_left(ret, ctrla, desc_first); | |
| 417 | + return atc_calc_bytes_left(ret, ctrla); | |
| 358 | 418 | |
| 359 | 419 | ret -= desc_first->len; |
| 360 | 420 | list_for_each_entry(desc, &desc_first->tx_list, desc_node) { |
| @@ -365,16 +425,14 @@ static int atc_get_bytes_left(struct dma_chan *chan, dma_cookie_t cookie) · 4 unmodified lines | ||
| 365 | 425 | } |
| 366 | 426 | |
| 367 | 427 | /* |
| 368 | − * For the last descriptor in the chain we can calculate | |
| 428 | + * For the current descriptor in the chain we can calculate | |
| 369 | 429 | * the remaining bytes using the channel's register. |
| 370 | − * Note that the transfer width of the first and last | |
| 371 | − * descriptor may differ. | |
| 372 | 430 | */ |
| 373 | − if (!desc->lli.dscr) | |
| 374 | − ret = atc_calc_bytes_left_from_reg(ret, atchan, desc); | |
| 431 | + ret = atc_calc_bytes_left(ret, ctrla); | |
| 375 | 432 | } else { |
| 376 | 433 | /* single transfer */ |
| 377 | − ret = atc_calc_bytes_left_from_reg(ret, atchan, desc_first); | |
| 434 | + ctrla = channel_readl(atchan, CTRLA); | |
| 435 | + ret = atc_calc_bytes_left(ret, ctrla); | |
| 378 | 436 | } |
| 379 | 437 | |
| 380 | 438 | return ret; |
| @@ -726,7 +784,6 @@ atc_prep_dma_interleaved(struct dma_chan *chan, · 345 unmodified lines | ||
| 726 | 784 | |
| 727 | 785 | desc->txd.cookie = -EBUSY; |
| 728 | 786 | desc->total_len = desc->len = len; |
| 729 | − desc->tx_width = dwidth; | |
| 730 | 787 | |
| 731 | 788 | /* set end-of-link to the last link descriptor of list*/ |
| 732 | 789 | set_desc_eol(desc); |
| @@ -804,10 +861,6 @@ atc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src, · 71 unmodified lines | ||
| 804 | 861 | first->txd.cookie = -EBUSY; |
| 805 | 862 | first->total_len = len; |
| 806 | 863 | |
| 807 | − /* set transfer width for the calculation of the residue */ | |
| 808 | − first->tx_width = src_width; | |
| 809 | − prev->tx_width = src_width; | |
| 810 | − | |
| 811 | 864 | /* set end-of-link to the last link descriptor of list*/ |
| 812 | 865 | set_desc_eol(desc); |
| 813 | 866 | |
| @@ -956,10 +1009,6 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, · 142 unmodified lines | ||
| 956 | 1009 | first->txd.cookie = -EBUSY; |
| 957 | 1010 | first->total_len = total_len; |
| 958 | 1011 | |
| 959 | − /* set transfer width for the calculation of the residue */ | |
| 960 | − first->tx_width = reg_width; | |
| 961 | − prev->tx_width = reg_width; | |
| 962 | − | |
| 963 | 1012 | /* first link descriptor of list is responsible of flags */ |
| 964 | 1013 | first->txd.flags = flags; /* client is in control of this ack */ |
| 965 | 1014 | |
| @@ -1077,12 +1126,6 @@ atc_prep_dma_sg(struct dma_chan *chan, · 111 unmodified lines | ||
| 1077 | 1126 | desc->txd.cookie = 0; |
| 1078 | 1127 | desc->len = len; |
| 1079 | 1128 | |
| 1080 | − /* | |
| 1081 | − * Although we only need the transfer width for the first and | |
| 1082 | − * the last descriptor, its easier to set it to all descriptors. | |
| 1083 | − */ | |
| 1084 | − desc->tx_width = src_width; | |
| 1085 | − | |
| 1086 | 1129 | atc_desc_chain(&first, &prev, desc); |
| 1087 | 1130 | |
| 1088 | 1131 | /* update the lengths and addresses for the next loop cycle */ |
| @@ -1256,7 +1299,6 @@ atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len, · 167 unmodified lines | ||
| 1256 | 1299 | /* First descriptor of the chain embedds additional information */ |
| 1257 | 1300 | first->txd.cookie = -EBUSY; |
| 1258 | 1301 | first->total_len = buf_len; |
| 1259 | − first->tx_width = reg_width; | |
| 1260 | 1302 | |
| 1261 | 1303 | return &first->txd; |
| 1262 | 1304 | |
| @@ -112,6 +112,7 @@ · 111 unmodified lines | ||
| 112 | 112 | #define ATC_SRC_WIDTH_BYTE (0x0 << 24) |
| 113 | 113 | #define ATC_SRC_WIDTH_HALFWORD (0x1 << 24) |
| 114 | 114 | #define ATC_SRC_WIDTH_WORD (0x2 << 24) |
| 115 | +#define ATC_REG_TO_SRC_WIDTH(r) (((r) >> 24) & 0x3) | |
| 115 | 116 | #define ATC_DST_WIDTH_MASK (0x3 << 28) /* Destination Single Transfer Size */ |
| 116 | 117 | #define ATC_DST_WIDTH(x) ((x) << 28) |
| 117 | 118 | #define ATC_DST_WIDTH_BYTE (0x0 << 28) |
| @@ -182,7 +183,6 @@ struct at_lli { · 64 unmodified lines | ||
| 182 | 183 | * @txd: support for the async_tx api |
| 183 | 184 | * @desc_node: node on the channed descriptors list |
| 184 | 185 | * @len: descriptor byte count |
| 185 | − * @tx_width: transfer width | |
| 186 | 186 | * @total_len: total transaction byte count |
| 187 | 187 | */ |
| 188 | 188 | struct at_desc { |
| @@ -194,7 +194,6 @@ struct at_desc { · 5 unmodified lines | ||
| 194 | 194 | struct dma_async_tx_descriptor txd; |
| 195 | 195 | struct list_head desc_node; |
| 196 | 196 | size_t len; |
| 197 | − u32 tx_width; | |
| 198 | 197 | size_t total_len; |
| 199 | 198 | |
| 200 | 199 | /* Interleaved data */ |
| @@ -359,18 +359,19 @@ static void at_xdmac_start_xfer(struct at_xdmac_chan *atchan, · 358 unmodified lines | ||
| 359 | 359 | * descriptor view 2 since some fields of the configuration register |
| 360 | 360 | * depend on transfer size and src/dest addresses. |
| 361 | 361 | */ |
| 362 | − if (at_xdmac_chan_is_cyclic(atchan)) { | |
| 362 | + if (at_xdmac_chan_is_cyclic(atchan)) | |
| 363 | 363 | reg = AT_XDMAC_CNDC_NDVIEW_NDV1; |
| 364 | − at_xdmac_chan_write(atchan, AT_XDMAC_CC, first->lld.mbr_cfg); | |
| 365 | − } else if (first->lld.mbr_ubc & AT_XDMAC_MBR_UBC_NDV3) { | |
| 364 | + else if (first->lld.mbr_ubc & AT_XDMAC_MBR_UBC_NDV3) | |
| 366 | 365 | reg = AT_XDMAC_CNDC_NDVIEW_NDV3; |
| 367 | − } else { | |
| 368 | − /* | |
| 369 | − * No need to write AT_XDMAC_CC reg, it will be done when the | |
| 370 | − * descriptor is fecthed. | |
| 371 | − */ | |
| 366 | + else | |
| 372 | 367 | reg = AT_XDMAC_CNDC_NDVIEW_NDV2; |
| 373 | − } | |
| 368 | + /* | |
| 369 | + * Even if the register will be updated from the configuration in the | |
| 370 | + * descriptor when using view 2 or higher, the PROT bit won't be set | |
| 371 | + * properly. This bit can be modified only by using the channel | |
| 372 | + * configuration register. | |
| 373 | + */ | |
| 374 | + at_xdmac_chan_write(atchan, AT_XDMAC_CC, first->lld.mbr_cfg); | |
| 374 | 375 | |
| 375 | 376 | reg |= AT_XDMAC_CNDC_NDDUP |
| 376 | 377 | | AT_XDMAC_CNDC_NDSUP |
| @@ -681,15 +682,16 @@ at_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, · 304 unmodified lines | ||
| 681 | 682 | desc->lld.mbr_sa = mem; |
| 682 | 683 | desc->lld.mbr_da = atchan->sconfig.dst_addr; |
| 683 | 684 | } |
| 684 | − desc->lld.mbr_cfg = atchan->cfg; | |
| 685 | − dwidth = at_xdmac_get_dwidth(desc->lld.mbr_cfg); | |
| 685 | + dwidth = at_xdmac_get_dwidth(atchan->cfg); | |
| 686 | 686 | fixed_dwidth = IS_ALIGNED(len, 1 << dwidth) |
| 687 | − ? at_xdmac_get_dwidth(desc->lld.mbr_cfg) | |
| 687 | + ? dwidth | |
| 688 | 688 | : AT_XDMAC_CC_DWIDTH_BYTE; |
| 689 | 689 | desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV2 /* next descriptor view */ |
| 690 | 690 | | AT_XDMAC_MBR_UBC_NDEN /* next descriptor dst parameter update */ |
| 691 | 691 | | AT_XDMAC_MBR_UBC_NSEN /* next descriptor src parameter update */ |
| 692 | 692 | | (len >> fixed_dwidth); /* microblock length */ |
| 693 | + desc->lld.mbr_cfg = (atchan->cfg & ~AT_XDMAC_CC_DWIDTH_MASK) | | |
| 694 | + AT_XDMAC_CC_DWIDTH(fixed_dwidth); | |
| 693 | 695 | dev_dbg(chan2dev(chan), |
| 694 | 696 | "%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n", |
| 695 | 697 | __func__, &desc->lld.mbr_sa, &desc->lld.mbr_da, desc->lld.mbr_ubc); |
| @@ -162,10 +162,11 @@ static void mv_chan_set_mode(struct mv_xor_chan *chan, · 161 unmodified lines | ||
| 162 | 162 | config &= ~0x7; |
| 163 | 163 | config |= op_mode; |
| 164 | 164 | |
| 165 | − if (IS_ENABLED(__BIG_ENDIAN)) | |
| 166 | − config |= XOR_DESCRIPTOR_SWAP; | |
| 167 | − else | |
| 168 | − config &= ~XOR_DESCRIPTOR_SWAP; | |
| 165 | +#if defined(__BIG_ENDIAN) | |
| 166 | + config |= XOR_DESCRIPTOR_SWAP; | |
| 167 | +#else | |
| 168 | + config &= ~XOR_DESCRIPTOR_SWAP; | |
| 169 | +#endif | |
| 169 | 170 | |
| 170 | 171 | writel_relaxed(config, XOR_CONFIG(chan)); |
| 171 | 172 | chan->current_type = type; |
| @@ -2328,7 +2328,7 @@ static dma_cookie_t pl330_tx_submit(struct dma_async_tx_descriptor *tx) · 2327 unmodified lines | ||
| 2328 | 2328 | desc->txd.callback = last->txd.callback; |
| 2329 | 2329 | desc->txd.callback_param = last->txd.callback_param; |
| 2330 | 2330 | } |
| 2331 | − last->last = false; | |
| 2331 | + desc->last = false; | |
| 2332 | 2332 | |
| 2333 | 2333 | dma_cookie_assign(&desc->txd); |
| 2334 | 2334 | |
| @@ -2623,6 +2623,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, · 288 unmodified lines | ||
| 2623 | 2623 | desc->rqcfg.brst_len = 1; |
| 2624 | 2624 | |
| 2625 | 2625 | desc->rqcfg.brst_len = get_burst_len(desc, len); |
| 2626 | + desc->bytes_requested = len; | |
| 2626 | 2627 | |
| 2627 | 2628 | desc->txd.flags = flags; |
| 2628 | 2629 | |
| @@ -29,7 +29,7 @@ dma_cookie_t vchan_tx_submit(struct dma_async_tx_descriptor *tx) · 28 unmodified lines | ||
| 29 | 29 | spin_lock_irqsave(&vc->lock, flags); |
| 30 | 30 | cookie = dma_cookie_assign(tx); |
| 31 | 31 | |
| 32 | − list_move_tail(&vd->node, &vc->desc_submitted); | |
| 32 | + list_add_tail(&vd->node, &vc->desc_submitted); | |
| 33 | 33 | spin_unlock_irqrestore(&vc->lock, flags); |
| 34 | 34 | |
| 35 | 35 | dev_dbg(vc->chan.device->dev, "vchan %p: txd %p[%x]: submitted\n", |
| @@ -83,10 +83,8 @@ static void vchan_complete(unsigned long arg) · 47 unmodified lines | ||
| 83 | 83 | cb_data = vd->tx.callback_param; |
| 84 | 84 | |
| 85 | 85 | list_del(&vd->node); |
| 86 | − if (async_tx_test_ack(&vd->tx)) | |
| 87 | − list_add(&vd->node, &vc->desc_allocated); | |
| 88 | − else | |
| 89 | − vc->desc_free(vd); | |
| 86 | + | |
| 87 | + vc->desc_free(vd); | |
| 90 | 88 | |
| 91 | 89 | if (cb) |
| 92 | 90 | cb(cb_data); |
| @@ -98,13 +96,9 @@ void vchan_dma_desc_free_list(struct virt_dma_chan *vc, struct list_head *head) · 5 unmodified lines | ||
| 98 | 96 | while (!list_empty(head)) { |
| 99 | 97 | struct virt_dma_desc *vd = list_first_entry(head, |
| 100 | 98 | struct virt_dma_desc, node); |
| 101 | − if (async_tx_test_ack(&vd->tx)) { | |
| 102 | − list_move_tail(&vd->node, &vc->desc_allocated); | |
| 103 | − } else { | |
| 104 | − dev_dbg(vc->chan.device->dev, "txd %p: freeing\n", vd); | |
| 105 | − list_del(&vd->node); | |
| 106 | − vc->desc_free(vd); | |
| 107 | − } | |
| 99 | + list_del(&vd->node); | |
| 100 | + dev_dbg(vc->chan.device->dev, "txd %p: freeing\n", vd); | |
| 101 | + vc->desc_free(vd); | |
| 108 | 102 | } |
| 109 | 103 | } |
| 110 | 104 | EXPORT_SYMBOL_GPL(vchan_dma_desc_free_list); |
| @@ -114,7 +108,6 @@ void vchan_init(struct virt_dma_chan *vc, struct dma_device *dmadev) · 3 unmodified lines | ||
| 114 | 108 | dma_cookie_init(&vc->chan); |
| 115 | 109 | |
| 116 | 110 | spin_lock_init(&vc->lock); |
| 117 | − INIT_LIST_HEAD(&vc->desc_allocated); | |
| 118 | 111 | INIT_LIST_HEAD(&vc->desc_submitted); |
| 119 | 112 | INIT_LIST_HEAD(&vc->desc_issued); |
| 120 | 113 | INIT_LIST_HEAD(&vc->desc_completed); |
| @@ -29,7 +29,6 @@ struct virt_dma_chan { · 28 unmodified lines | ||
| 29 | 29 | spinlock_t lock; |
| 30 | 30 | |
| 31 | 31 | /* protected by vc.lock */ |
| 32 | − struct list_head desc_allocated; | |
| 33 | 32 | struct list_head desc_submitted; |
| 34 | 33 | struct list_head desc_issued; |
| 35 | 34 | struct list_head desc_completed; |
| @@ -56,16 +55,11 @@ static inline struct dma_async_tx_descriptor *vchan_tx_prep(struct virt_dma_chan · 20 unmodified lines | ||
| 56 | 55 | struct virt_dma_desc *vd, unsigned long tx_flags) |
| 57 | 56 | { |
| 58 | 57 | extern dma_cookie_t vchan_tx_submit(struct dma_async_tx_descriptor *); |
| 59 | − unsigned long flags; | |
| 60 | 58 | |
| 61 | 59 | dma_async_tx_descriptor_init(&vd->tx, &vc->chan); |
| 62 | 60 | vd->tx.flags = tx_flags; |
| 63 | 61 | vd->tx.tx_submit = vchan_tx_submit; |
| 64 | 62 | |
| 65 | − spin_lock_irqsave(&vc->lock, flags); | |
| 66 | − list_add_tail(&vd->node, &vc->desc_allocated); | |
| 67 | − spin_unlock_irqrestore(&vc->lock, flags); | |
| 68 | − | |
| 69 | 63 | return &vd->tx; |
| 70 | 64 | } |
| 71 | 65 | |
| @@ -128,8 +122,7 @@ static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) · 56 unmodified lines | ||
| 128 | 122 | } |
| 129 | 123 | |
| 130 | 124 | /** |
| 131 | − * vchan_get_all_descriptors - obtain all allocated, submitted and issued | |
| 132 | − * descriptors | |
| 125 | + * vchan_get_all_descriptors - obtain all submitted and issued descriptors | |
| 133 | 126 | * vc: virtual channel to get descriptors from |
| 134 | 127 | * head: list of descriptors found |
| 135 | 128 | * |
| @@ -141,7 +134,6 @@ static inline struct virt_dma_desc *vchan_next_desc(struct virt_dma_chan *vc) · 5 unmodified lines | ||
| 141 | 134 | static inline void vchan_get_all_descriptors(struct virt_dma_chan *vc, |
| 142 | 135 | struct list_head *head) |
| 143 | 136 | { |
| 144 | − list_splice_tail_init(&vc->desc_allocated, head); | |
| 145 | 137 | list_splice_tail_init(&vc->desc_submitted, head); |
| 146 | 138 | list_splice_tail_init(&vc->desc_issued, head); |
| 147 | 139 | list_splice_tail_init(&vc->desc_completed, head); |
| @@ -149,14 +141,11 @@ static inline void vchan_get_all_descriptors(struct virt_dma_chan *vc, · 1 unmodified line | ||
| 149 | 141 | |
| 150 | 142 | static inline void vchan_free_chan_resources(struct virt_dma_chan *vc) |
| 151 | 143 | { |
| 152 | − struct virt_dma_desc *vd; | |
| 153 | 144 | unsigned long flags; |
| 154 | 145 | LIST_HEAD(head); |
| 155 | 146 | |
| 156 | 147 | spin_lock_irqsave(&vc->lock, flags); |
| 157 | 148 | vchan_get_all_descriptors(vc, &head); |
| 158 | − list_for_each_entry(vd, &head, node) | |
| 159 | − async_tx_clear_ack(&vd->tx); | |
| 160 | 149 | spin_unlock_irqrestore(&vc->lock, flags); |
| 161 | 150 | |
| 162 | 151 | vchan_dma_desc_free_list(vc, &head); |
| @@ -111,6 +111,7 @@ · 110 unmodified lines | ||
| 111 | 111 | #define XGENE_DMA_MEM_RAM_SHUTDOWN 0xD070 |
| 112 | 112 | #define XGENE_DMA_BLK_MEM_RDY 0xD074 |
| 113 | 113 | #define XGENE_DMA_BLK_MEM_RDY_VAL 0xFFFFFFFF |
| 114 | +#define XGENE_DMA_RING_CMD_SM_OFFSET 0x8000 | |
| 114 | 115 | |
| 115 | 116 | /* X-Gene SoC EFUSE csr register and bit defination */ |
| 116 | 117 | #define XGENE_SOC_JTAG1_SHADOW 0x18 |
| @@ -1887,6 +1888,8 @@ static int xgene_dma_get_resources(struct platform_device *pdev, · 1770 unmodified lines | ||
| 1887 | 1888 | return -ENOMEM; |
| 1888 | 1889 | } |
| 1889 | 1890 | |
| 1891 | + pdma->csr_ring_cmd += XGENE_DMA_RING_CMD_SM_OFFSET; | |
| 1892 | + | |
| 1890 | 1893 | /* Get efuse csr region */ |
| 1891 | 1894 | res = platform_get_resource(pdev, IORESOURCE_MEM, 3); |
| 1892 | 1895 | if (!res) { |
| @@ -920,7 +920,7 @@ static int ppc4xx_edac_init_csrows(struct mem_ctl_info *mci, u32 mcopt1) · 919 unmodified lines | ||
| 920 | 920 | */ |
| 921 | 921 | |
| 922 | 922 | for (row = 0; row < mci->nr_csrows; row++) { |
| 923 | − struct csrow_info *csi = &mci->csrows[row]; | |
| 923 | + struct csrow_info *csi = mci->csrows[row]; | |
| 924 | 924 | |
| 925 | 925 | /* |
| 926 | 926 | * Get the configuration settings for this |
| @@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 199 unmodified lines | ||
| 200 | 200 | status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev); |
| 201 | 201 | if (status) { |
| 202 | 202 | dev_err(&pdev->dev, "failed to register extcon device\n"); |
| 203 | − kfree(palmas_usb->edev->name); | |
| 204 | 203 | return status; |
| 205 | 204 | } |
| 206 | 205 | |
| @@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 214 | 213 | if (status < 0) { |
| 215 | 214 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", |
| 216 | 215 | palmas_usb->id_irq, status); |
| 217 | − kfree(palmas_usb->edev->name); | |
| 218 | 216 | return status; |
| 219 | 217 | } |
| 220 | 218 | } |
| @@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 8 unmodified lines | ||
| 229 | 227 | if (status < 0) { |
| 230 | 228 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", |
| 231 | 229 | palmas_usb->vbus_irq, status); |
| 232 | − kfree(palmas_usb->edev->name); | |
| 233 | 230 | return status; |
| 234 | 231 | } |
| 235 | 232 | } |
| @@ -239,15 +236,6 @@ static int palmas_usb_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 239 | 236 | return 0; |
| 240 | 237 | } |
| 241 | 238 | |
| 242 | −static int palmas_usb_remove(struct platform_device *pdev) | |
| 243 | −{ | |
| 244 | − struct palmas_usb *palmas_usb = platform_get_drvdata(pdev); | |
| 245 | − | |
| 246 | − kfree(palmas_usb->edev->name); | |
| 247 | − | |
| 248 | − return 0; | |
| 249 | −} | |
| 250 | − | |
| 251 | 239 | #ifdef CONFIG_PM_SLEEP |
| 252 | 240 | static int palmas_usb_suspend(struct device *dev) |
| 253 | 241 | { |
| @@ -288,7 +276,6 @@ static const struct of_device_id of_palmas_match_tbl[] = { · 34 unmodified lines | ||
| 288 | 276 | |
| 289 | 277 | static struct platform_driver palmas_usb_driver = { |
| 290 | 278 | .probe = palmas_usb_probe, |
| 291 | − .remove = palmas_usb_remove, | |
| 292 | 279 | .driver = { |
| 293 | 280 | .name = "palmas-usb", |
| 294 | 281 | .of_match_table = of_palmas_match_tbl, |
| @@ -124,25 +124,35 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id · 123 unmodified lines | ||
| 124 | 124 | return -EINVAL; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | −static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) | |
| 127 | +static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) | |
| 128 | 128 | { |
| 129 | − unsigned int id = EXTCON_NONE; | |
| 129 | + unsigned int id = -EINVAL; | |
| 130 | 130 | int i = 0; |
| 131 | 131 | |
| 132 | − if (edev->max_supported == 0) | |
| 133 | − return -EINVAL; | |
| 134 | − | |
| 135 | − /* Find the the number of extcon cable */ | |
| 132 | + /* Find the id of extcon cable */ | |
| 136 | 133 | while (extcon_name[i]) { |
| 137 | 134 | if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) { |
| 138 | 135 | id = i; |
| 139 | 136 | break; |
| 140 | 137 | } |
| 138 | + i++; | |
| 141 | 139 | } |
| 142 | 140 | |
| 143 | − if (id == EXTCON_NONE) | |
| 141 | + return id; | |
| 142 | +} | |
| 143 | + | |
| 144 | +static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) | |
| 145 | +{ | |
| 146 | + unsigned int id; | |
| 147 | + | |
| 148 | + if (edev->max_supported == 0) | |
| 144 | 149 | return -EINVAL; |
| 145 | 150 | |
| 151 | + /* Find the the number of extcon cable */ | |
| 152 | + id = find_cable_id_by_name(edev, name); | |
| 153 | + if (id < 0) | |
| 154 | + return id; | |
| 155 | + | |
| 146 | 156 | return find_cable_index_by_id(edev, id); |
| 147 | 157 | } |
| 148 | 158 | |
| @@ -228,9 +238,11 @@ static ssize_t cable_state_show(struct device *dev, · 79 unmodified lines | ||
| 228 | 238 | struct extcon_cable *cable = container_of(attr, struct extcon_cable, |
| 229 | 239 | attr_state); |
| 230 | 240 | |
| 241 | + int i = cable->cable_index; | |
| 242 | + | |
| 231 | 243 | return sprintf(buf, "%d\n", |
| 232 | 244 | extcon_get_cable_state_(cable->edev, |
| 233 | − cable->cable_index)); | |
| 245 | + cable->edev->supported_cable[i])); | |
| 234 | 246 | } |
| 235 | 247 | |
| 236 | 248 | /** |
| @@ -263,20 +275,25 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) · 26 unmodified lines | ||
| 263 | 275 | spin_lock_irqsave(&edev->lock, flags); |
| 264 | 276 | |
| 265 | 277 | if (edev->state != ((edev->state & ~mask) | (state & mask))) { |
| 278 | + u32 old_state; | |
| 279 | + | |
| 266 | 280 | if (check_mutually_exclusive(edev, (edev->state & ~mask) | |
| 267 | 281 | (state & mask))) { |
| 268 | 282 | spin_unlock_irqrestore(&edev->lock, flags); |
| 269 | 283 | return -EPERM; |
| 270 | 284 | } |
| 271 | 285 | |
| 272 | − for (index = 0; index < edev->max_supported; index++) { | |
| 273 | − if (is_extcon_changed(edev->state, state, index, &attached)) | |
| 274 | − raw_notifier_call_chain(&edev->nh[index], attached, edev); | |
| 275 | − } | |
| 276 | − | |
| 286 | + old_state = edev->state; | |
| 277 | 287 | edev->state &= ~mask; |
| 278 | 288 | edev->state |= state & mask; |
| 279 | 289 | |
| 290 | + for (index = 0; index < edev->max_supported; index++) { | |
| 291 | + if (is_extcon_changed(old_state, edev->state, index, | |
| 292 | + &attached)) | |
| 293 | + raw_notifier_call_chain(&edev->nh[index], | |
| 294 | + attached, edev); | |
| 295 | + } | |
| 296 | + | |
| 280 | 297 | /* This could be in interrupt handler */ |
| 281 | 298 | prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); |
| 282 | 299 | if (prop_buf) { |
| @@ -361,8 +378,13 @@ EXPORT_SYMBOL_GPL(extcon_get_cable_state_); · 78 unmodified lines | ||
| 361 | 378 | */ |
| 362 | 379 | int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) |
| 363 | 380 | { |
| 364 | − return extcon_get_cable_state_(edev, find_cable_index_by_name | |
| 365 | − (edev, cable_name)); | |
| 381 | + unsigned int id; | |
| 382 | + | |
| 383 | + id = find_cable_id_by_name(edev, cable_name); | |
| 384 | + if (id < 0) | |
| 385 | + return id; | |
| 386 | + | |
| 387 | + return extcon_get_cable_state_(edev, id); | |
| 366 | 388 | } |
| 367 | 389 | EXPORT_SYMBOL_GPL(extcon_get_cable_state); |
| 368 | 390 | |
| @@ -404,8 +426,13 @@ EXPORT_SYMBOL_GPL(extcon_set_cable_state_); · 35 unmodified lines | ||
| 404 | 426 | int extcon_set_cable_state(struct extcon_dev *edev, |
| 405 | 427 | const char *cable_name, bool cable_state) |
| 406 | 428 | { |
| 407 | − return extcon_set_cable_state_(edev, find_cable_index_by_name | |
| 408 | − (edev, cable_name), cable_state); | |
| 429 | + unsigned int id; | |
| 430 | + | |
| 431 | + id = find_cable_id_by_name(edev, cable_name); | |
| 432 | + if (id < 0) | |
| 433 | + return id; | |
| 434 | + | |
| 435 | + return extcon_set_cable_state_(edev, id, cable_state); | |
| 409 | 436 | } |
| 410 | 437 | EXPORT_SYMBOL_GPL(extcon_set_cable_state); |
| 411 | 438 | |
| @@ -58,6 +58,11 @@ bool efi_runtime_disabled(void) · 57 unmodified lines | ||
| 58 | 58 | |
| 59 | 59 | static int __init parse_efi_cmdline(char *str) |
| 60 | 60 | { |
| 61 | + if (!str) { | |
| 62 | + pr_warn("need at least one option\n"); | |
| 63 | + return -EINVAL; | |
| 64 | + } | |
| 65 | + | |
| 61 | 66 | if (parse_option_str(str, "noruntime")) |
| 62 | 67 | disable_runtime = true; |
| 63 | 68 | |
| @@ -1130,6 +1130,9 @@ struct amdgpu_gfx { · 1129 unmodified lines | ||
| 1130 | 1130 | uint32_t me_feature_version; |
| 1131 | 1131 | uint32_t ce_feature_version; |
| 1132 | 1132 | uint32_t pfp_feature_version; |
| 1133 | + uint32_t rlc_feature_version; | |
| 1134 | + uint32_t mec_feature_version; | |
| 1135 | + uint32_t mec2_feature_version; | |
| 1133 | 1136 | struct amdgpu_ring gfx_ring[AMDGPU_MAX_GFX_RINGS]; |
| 1134 | 1137 | unsigned num_gfx_rings; |
| 1135 | 1138 | struct amdgpu_ring compute_ring[AMDGPU_MAX_COMPUTE_RINGS]; |
| @@ -1639,6 +1642,7 @@ struct amdgpu_sdma { · 503 unmodified lines | ||
| 1639 | 1642 | /* SDMA firmware */ |
| 1640 | 1643 | const struct firmware *fw; |
| 1641 | 1644 | uint32_t fw_version; |
| 1645 | + uint32_t feature_version; | |
| 1642 | 1646 | |
| 1643 | 1647 | struct amdgpu_ring ring; |
| 1644 | 1648 | }; |
| @@ -317,16 +317,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 316 unmodified lines | ||
| 317 | 317 | break; |
| 318 | 318 | case AMDGPU_INFO_FW_GFX_RLC: |
| 319 | 319 | fw_info.ver = adev->gfx.rlc_fw_version; |
| 320 | − fw_info.feature = 0; | |
| 320 | + fw_info.feature = adev->gfx.rlc_feature_version; | |
| 321 | 321 | break; |
| 322 | 322 | case AMDGPU_INFO_FW_GFX_MEC: |
| 323 | − if (info->query_fw.index == 0) | |
| 323 | + if (info->query_fw.index == 0) { | |
| 324 | 324 | fw_info.ver = adev->gfx.mec_fw_version; |
| 325 | − else if (info->query_fw.index == 1) | |
| 325 | + fw_info.feature = adev->gfx.mec_feature_version; | |
| 326 | + } else if (info->query_fw.index == 1) { | |
| 326 | 327 | fw_info.ver = adev->gfx.mec2_fw_version; |
| 327 | − else | |
| 328 | + fw_info.feature = adev->gfx.mec2_feature_version; | |
| 329 | + } else | |
| 328 | 330 | return -EINVAL; |
| 329 | − fw_info.feature = 0; | |
| 330 | 331 | break; |
| 331 | 332 | case AMDGPU_INFO_FW_SMC: |
| 332 | 333 | fw_info.ver = adev->pm.fw_version; |
| @@ -336,7 +337,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · 3 unmodified lines | ||
| 336 | 337 | if (info->query_fw.index >= 2) |
| 337 | 338 | return -EINVAL; |
| 338 | 339 | fw_info.ver = adev->sdma[info->query_fw.index].fw_version; |
| 339 | − fw_info.feature = 0; | |
| 340 | + fw_info.feature = adev->sdma[info->query_fw.index].feature_version; | |
| 340 | 341 | break; |
| 341 | 342 | default: |
| 342 | 343 | return -EINVAL; |
| @@ -374,7 +374,7 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[]) · 373 unmodified lines | ||
| 374 | 374 | unsigned height_in_mb = ALIGN(height / 16, 2); |
| 375 | 375 | unsigned fs_in_mb = width_in_mb * height_in_mb; |
| 376 | 376 | |
| 377 | − unsigned image_size, tmp, min_dpb_size, num_dpb_buffer; | |
| 377 | + unsigned image_size, tmp, min_dpb_size, num_dpb_buffer, min_ctx_size; | |
| 378 | 378 | |
| 379 | 379 | image_size = width * height; |
| 380 | 380 | image_size += image_size / 2; |
| @@ -466,6 +466,8 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[]) · 85 unmodified lines | ||
| 466 | 466 | |
| 467 | 467 | num_dpb_buffer = (le32_to_cpu(msg[59]) & 0xff) + 2; |
| 468 | 468 | min_dpb_size = image_size * num_dpb_buffer; |
| 469 | + min_ctx_size = ((width + 255) / 16) * ((height + 255) / 16) | |
| 470 | + * 16 * num_dpb_buffer + 52 * 1024; | |
| 469 | 471 | break; |
| 470 | 472 | |
| 471 | 473 | default: |
| @@ -486,6 +488,7 @@ static int amdgpu_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[]) · 14 unmodified lines | ||
| 486 | 488 | |
| 487 | 489 | buf_sizes[0x1] = dpb_size; |
| 488 | 490 | buf_sizes[0x2] = image_size; |
| 491 | + buf_sizes[0x4] = min_ctx_size; | |
| 489 | 492 | return 0; |
| 490 | 493 | } |
| 491 | 494 | |
| @@ -628,6 +631,13 @@ static int amdgpu_uvd_cs_pass2(struct amdgpu_uvd_cs_ctx *ctx) · 136 unmodified lines | ||
| 628 | 631 | return -EINVAL; |
| 629 | 632 | } |
| 630 | 633 | |
| 634 | + } else if (cmd == 0x206) { | |
| 635 | + if ((end - start) < ctx->buf_sizes[4]) { | |
| 636 | + DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd, | |
| 637 | + (unsigned)(end - start), | |
| 638 | + ctx->buf_sizes[4]); | |
| 639 | + return -EINVAL; | |
| 640 | + } | |
| 631 | 641 | } else if ((cmd != 0x100) && (cmd != 0x204)) { |
| 632 | 642 | DRM_ERROR("invalid UVD command %X!\n", cmd); |
| 633 | 643 | return -EINVAL; |
| @@ -755,9 +765,10 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx) · 121 unmodified lines | ||
| 755 | 765 | struct amdgpu_uvd_cs_ctx ctx = {}; |
| 756 | 766 | unsigned buf_sizes[] = { |
| 757 | 767 | [0x00000000] = 2048, |
| 758 | − [0x00000001] = 32 * 1024 * 1024, | |
| 759 | − [0x00000002] = 2048 * 1152 * 3, | |
| 768 | + [0x00000001] = 0xFFFFFFFF, | |
| 769 | + [0x00000002] = 0xFFFFFFFF, | |
| 760 | 770 | [0x00000003] = 2048, |
| 771 | + [0x00000004] = 0xFFFFFFFF, | |
| 761 | 772 | }; |
| 762 | 773 | struct amdgpu_ib *ib = &parser->ibs[ib_idx]; |
| 763 | 774 | int r; |
| @@ -500,6 +500,7 @@ static int cik_sdma_load_microcode(struct amdgpu_device *adev) · 499 unmodified lines | ||
| 500 | 500 | amdgpu_ucode_print_sdma_hdr(&hdr->header); |
| 501 | 501 | fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; |
| 502 | 502 | adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version); |
| 503 | + adev->sdma[i].feature_version = le32_to_cpu(hdr->ucode_feature_version); | |
| 503 | 504 | fw_data = (const __le32 *) |
| 504 | 505 | (adev->sdma[i].fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes)); |
| 505 | 506 | WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], 0); |
| @@ -3080,6 +3080,8 @@ static int gfx_v7_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 3079 unmodified lines | ||
| 3080 | 3080 | mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; |
| 3081 | 3081 | amdgpu_ucode_print_gfx_hdr(&mec_hdr->header); |
| 3082 | 3082 | adev->gfx.mec_fw_version = le32_to_cpu(mec_hdr->header.ucode_version); |
| 3083 | + adev->gfx.mec_feature_version = le32_to_cpu( | |
| 3084 | + mec_hdr->ucode_feature_version); | |
| 3083 | 3085 | |
| 3084 | 3086 | gfx_v7_0_cp_compute_enable(adev, false); |
| 3085 | 3087 | |
| @@ -3102,6 +3104,8 @@ static int gfx_v7_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 16 unmodified lines | ||
| 3102 | 3104 | mec2_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data; |
| 3103 | 3105 | amdgpu_ucode_print_gfx_hdr(&mec2_hdr->header); |
| 3104 | 3106 | adev->gfx.mec2_fw_version = le32_to_cpu(mec2_hdr->header.ucode_version); |
| 3107 | + adev->gfx.mec2_feature_version = le32_to_cpu( | |
| 3108 | + mec2_hdr->ucode_feature_version); | |
| 3105 | 3109 | |
| 3106 | 3110 | /* MEC2 */ |
| 3107 | 3111 | fw_data = (const __le32 *) |
| @@ -4066,6 +4070,8 @@ static int gfx_v7_0_rlc_resume(struct amdgpu_device *adev) · 958 unmodified lines | ||
| 4066 | 4070 | hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data; |
| 4067 | 4071 | amdgpu_ucode_print_rlc_hdr(&hdr->header); |
| 4068 | 4072 | adev->gfx.rlc_fw_version = le32_to_cpu(hdr->header.ucode_version); |
| 4073 | + adev->gfx.rlc_feature_version = le32_to_cpu( | |
| 4074 | + hdr->ucode_feature_version); | |
| 4069 | 4075 | |
| 4070 | 4076 | gfx_v7_0_rlc_stop(adev); |
| 4071 | 4077 | |
| @@ -5122,7 +5128,7 @@ static void gfx_v7_0_print_status(void *handle) · 1050 unmodified lines | ||
| 5122 | 5128 | dev_info(adev->dev, " CP_HPD_EOP_CONTROL=0x%08X\n", |
| 5123 | 5129 | RREG32(mmCP_HPD_EOP_CONTROL)); |
| 5124 | 5130 | |
| 5125 | − for (queue = 0; queue < 8; i++) { | |
| 5131 | + for (queue = 0; queue < 8; queue++) { | |
| 5126 | 5132 | cik_srbm_select(adev, me, pipe, queue, 0); |
| 5127 | 5133 | dev_info(adev->dev, " queue: %d\n", queue); |
| 5128 | 5134 | dev_info(adev->dev, " CP_PQ_WPTR_POLL_CNTL=0x%08X\n", |
| @@ -587,6 +587,7 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 586 unmodified lines | ||
| 587 | 587 | int err; |
| 588 | 588 | struct amdgpu_firmware_info *info = NULL; |
| 589 | 589 | const struct common_firmware_header *header = NULL; |
| 590 | + const struct gfx_firmware_header_v1_0 *cp_hdr; | |
| 590 | 591 | |
| 591 | 592 | DRM_DEBUG("\n"); |
| 592 | 593 | |
| @@ -611,6 +612,9 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 18 unmodified lines | ||
| 611 | 612 | err = amdgpu_ucode_validate(adev->gfx.pfp_fw); |
| 612 | 613 | if (err) |
| 613 | 614 | goto out; |
| 615 | + cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data; | |
| 616 | + adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
| 617 | + adev->gfx.pfp_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
| 614 | 618 | |
| 615 | 619 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name); |
| 616 | 620 | err = request_firmware(&adev->gfx.me_fw, fw_name, adev->dev); |
| @@ -619,6 +623,9 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 2 unmodified lines | ||
| 619 | 623 | err = amdgpu_ucode_validate(adev->gfx.me_fw); |
| 620 | 624 | if (err) |
| 621 | 625 | goto out; |
| 626 | + cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data; | |
| 627 | + adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
| 628 | + adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
| 622 | 629 | |
| 623 | 630 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name); |
| 624 | 631 | err = request_firmware(&adev->gfx.ce_fw, fw_name, adev->dev); |
| @@ -627,12 +634,18 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 2 unmodified lines | ||
| 627 | 634 | err = amdgpu_ucode_validate(adev->gfx.ce_fw); |
| 628 | 635 | if (err) |
| 629 | 636 | goto out; |
| 637 | + cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data; | |
| 638 | + adev->gfx.ce_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
| 639 | + adev->gfx.ce_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
| 630 | 640 | |
| 631 | 641 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name); |
| 632 | 642 | err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev); |
| 633 | 643 | if (err) |
| 634 | 644 | goto out; |
| 635 | 645 | err = amdgpu_ucode_validate(adev->gfx.rlc_fw); |
| 646 | + cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.rlc_fw->data; | |
| 647 | + adev->gfx.rlc_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
| 648 | + adev->gfx.rlc_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
| 636 | 649 | |
| 637 | 650 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name); |
| 638 | 651 | err = request_firmware(&adev->gfx.mec_fw, fw_name, adev->dev); |
| @@ -641,6 +654,9 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 2 unmodified lines | ||
| 641 | 654 | err = amdgpu_ucode_validate(adev->gfx.mec_fw); |
| 642 | 655 | if (err) |
| 643 | 656 | goto out; |
| 657 | + cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; | |
| 658 | + adev->gfx.mec_fw_version = le32_to_cpu(cp_hdr->header.ucode_version); | |
| 659 | + adev->gfx.mec_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version); | |
| 644 | 660 | |
| 645 | 661 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name); |
| 646 | 662 | err = request_firmware(&adev->gfx.mec2_fw, fw_name, adev->dev); |
| @@ -648,6 +664,12 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev) · 1 unmodified line | ||
| 648 | 664 | err = amdgpu_ucode_validate(adev->gfx.mec2_fw); |
| 649 | 665 | if (err) |
| 650 | 666 | goto out; |
| 667 | + cp_hdr = (const struct gfx_firmware_header_v1_0 *) | |
| 668 | + adev->gfx.mec2_fw->data; | |
| 669 | + adev->gfx.mec2_fw_version = le32_to_cpu( | |
| 670 | + cp_hdr->header.ucode_version); | |
| 671 | + adev->gfx.mec2_feature_version = le32_to_cpu( | |
| 672 | + cp_hdr->ucode_feature_version); | |
| 651 | 673 | } else { |
| 652 | 674 | err = 0; |
| 653 | 675 | adev->gfx.mec2_fw = NULL; |
| @@ -1983,6 +2005,7 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 1329 unmodified lines | ||
| 1983 | 2005 | adev->gfx.config.max_shader_engines = 1; |
| 1984 | 2006 | adev->gfx.config.max_tile_pipes = 2; |
| 1985 | 2007 | adev->gfx.config.max_sh_per_se = 1; |
| 2008 | + adev->gfx.config.max_backends_per_se = 2; | |
| 1986 | 2009 | |
| 1987 | 2010 | switch (adev->pdev->revision) { |
| 1988 | 2011 | case 0xc4: |
| @@ -1991,7 +2014,6 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 2 unmodified lines | ||
| 1991 | 2014 | case 0xcc: |
| 1992 | 2015 | /* B10 */ |
| 1993 | 2016 | adev->gfx.config.max_cu_per_sh = 8; |
| 1994 | − adev->gfx.config.max_backends_per_se = 2; | |
| 1995 | 2017 | break; |
| 1996 | 2018 | case 0xc5: |
| 1997 | 2019 | case 0x81: |
| @@ -2000,14 +2022,12 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 2 unmodified lines | ||
| 2000 | 2022 | case 0xcd: |
| 2001 | 2023 | /* B8 */ |
| 2002 | 2024 | adev->gfx.config.max_cu_per_sh = 6; |
| 2003 | − adev->gfx.config.max_backends_per_se = 2; | |
| 2004 | 2025 | break; |
| 2005 | 2026 | case 0xc6: |
| 2006 | 2027 | case 0xca: |
| 2007 | 2028 | case 0xce: |
| 2008 | 2029 | /* B6 */ |
| 2009 | 2030 | adev->gfx.config.max_cu_per_sh = 6; |
| 2010 | − adev->gfx.config.max_backends_per_se = 2; | |
| 2011 | 2031 | break; |
| 2012 | 2032 | case 0xc7: |
| 2013 | 2033 | case 0x87: |
| @@ -2015,7 +2035,6 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev) · 1 unmodified line | ||
| 2015 | 2035 | default: |
| 2016 | 2036 | /* B4 */ |
| 2017 | 2037 | adev->gfx.config.max_cu_per_sh = 4; |
| 2018 | − adev->gfx.config.max_backends_per_se = 1; | |
| 2019 | 2038 | break; |
| 2020 | 2039 | } |
| 2021 | 2040 | |
| @@ -2275,7 +2294,6 @@ static int gfx_v8_0_rlc_load_microcode(struct amdgpu_device *adev) · 253 unmodified lines | ||
| 2275 | 2294 | |
| 2276 | 2295 | hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data; |
| 2277 | 2296 | amdgpu_ucode_print_rlc_hdr(&hdr->header); |
| 2278 | − adev->gfx.rlc_fw_version = le32_to_cpu(hdr->header.ucode_version); | |
| 2279 | 2297 | |
| 2280 | 2298 | fw_data = (const __le32 *)(adev->gfx.rlc_fw->data + |
| 2281 | 2299 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); |
| @@ -2361,12 +2379,6 @@ static int gfx_v8_0_cp_gfx_load_microcode(struct amdgpu_device *adev) · 79 unmodified lines | ||
| 2361 | 2379 | amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header); |
| 2362 | 2380 | amdgpu_ucode_print_gfx_hdr(&ce_hdr->header); |
| 2363 | 2381 | amdgpu_ucode_print_gfx_hdr(&me_hdr->header); |
| 2364 | − adev->gfx.pfp_fw_version = le32_to_cpu(pfp_hdr->header.ucode_version); | |
| 2365 | − adev->gfx.ce_fw_version = le32_to_cpu(ce_hdr->header.ucode_version); | |
| 2366 | − adev->gfx.me_fw_version = le32_to_cpu(me_hdr->header.ucode_version); | |
| 2367 | − adev->gfx.me_feature_version = le32_to_cpu(me_hdr->ucode_feature_version); | |
| 2368 | − adev->gfx.ce_feature_version = le32_to_cpu(ce_hdr->ucode_feature_version); | |
| 2369 | − adev->gfx.pfp_feature_version = le32_to_cpu(pfp_hdr->ucode_feature_version); | |
| 2370 | 2382 | |
| 2371 | 2383 | gfx_v8_0_cp_gfx_enable(adev, false); |
| 2372 | 2384 | |
| @@ -2622,7 +2634,6 @@ static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 249 unmodified lines | ||
| 2622 | 2634 | |
| 2623 | 2635 | mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data; |
| 2624 | 2636 | amdgpu_ucode_print_gfx_hdr(&mec_hdr->header); |
| 2625 | − adev->gfx.mec_fw_version = le32_to_cpu(mec_hdr->header.ucode_version); | |
| 2626 | 2637 | |
| 2627 | 2638 | fw_data = (const __le32 *) |
| 2628 | 2639 | (adev->gfx.mec_fw->data + |
| @@ -2641,7 +2652,6 @@ static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev) · 12 unmodified lines | ||
| 2641 | 2652 | |
| 2642 | 2653 | mec2_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data; |
| 2643 | 2654 | amdgpu_ucode_print_gfx_hdr(&mec2_hdr->header); |
| 2644 | − adev->gfx.mec2_fw_version = le32_to_cpu(mec2_hdr->header.ucode_version); | |
| 2645 | 2655 | |
| 2646 | 2656 | fw_data = (const __le32 *) |
| 2647 | 2657 | (adev->gfx.mec2_fw->data + |
| @@ -3125,7 +3135,7 @@ static int gfx_v8_0_cp_compute_resume(struct amdgpu_device *adev) · 477 unmodified lines | ||
| 3125 | 3135 | WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER, |
| 3126 | 3136 | AMDGPU_DOORBELL_KIQ << 2); |
| 3127 | 3137 | WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER, |
| 3128 | − 0x7FFFF << 2); | |
| 3138 | + AMDGPU_DOORBELL_MEC_RING7 << 2); | |
| 3129 | 3139 | } |
| 3130 | 3140 | tmp = RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL); |
| 3131 | 3141 | tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, |
| @@ -121,6 +121,7 @@ static int sdma_v2_4_init_microcode(struct amdgpu_device *adev) · 120 unmodified lines | ||
| 121 | 121 | int err, i; |
| 122 | 122 | struct amdgpu_firmware_info *info = NULL; |
| 123 | 123 | const struct common_firmware_header *header = NULL; |
| 124 | + const struct sdma_firmware_header_v1_0 *hdr; | |
| 124 | 125 | |
| 125 | 126 | DRM_DEBUG("\n"); |
| 126 | 127 | |
| @@ -142,6 +143,9 @@ static int sdma_v2_4_init_microcode(struct amdgpu_device *adev) · 15 unmodified lines | ||
| 142 | 143 | err = amdgpu_ucode_validate(adev->sdma[i].fw); |
| 143 | 144 | if (err) |
| 144 | 145 | goto out; |
| 146 | + hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data; | |
| 147 | + adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version); | |
| 148 | + adev->sdma[i].feature_version = le32_to_cpu(hdr->ucode_feature_version); | |
| 145 | 149 | |
| 146 | 150 | if (adev->firmware.smu_load) { |
| 147 | 151 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i]; |
| @@ -541,8 +545,6 @@ static int sdma_v2_4_load_microcode(struct amdgpu_device *adev) · 393 unmodified lines | ||
| 541 | 545 | hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data; |
| 542 | 546 | amdgpu_ucode_print_sdma_hdr(&hdr->header); |
| 543 | 547 | fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; |
| 544 | − adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version); | |
| 545 | − | |
| 546 | 548 | fw_data = (const __le32 *) |
| 547 | 549 | (adev->sdma[i].fw->data + |
| 548 | 550 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); |
| @@ -159,6 +159,7 @@ static int sdma_v3_0_init_microcode(struct amdgpu_device *adev) · 158 unmodified lines | ||
| 159 | 159 | int err, i; |
| 160 | 160 | struct amdgpu_firmware_info *info = NULL; |
| 161 | 161 | const struct common_firmware_header *header = NULL; |
| 162 | + const struct sdma_firmware_header_v1_0 *hdr; | |
| 162 | 163 | |
| 163 | 164 | DRM_DEBUG("\n"); |
| 164 | 165 | |
| @@ -183,6 +184,9 @@ static int sdma_v3_0_init_microcode(struct amdgpu_device *adev) · 18 unmodified lines | ||
| 183 | 184 | err = amdgpu_ucode_validate(adev->sdma[i].fw); |
| 184 | 185 | if (err) |
| 185 | 186 | goto out; |
| 187 | + hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data; | |
| 188 | + adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version); | |
| 189 | + adev->sdma[i].feature_version = le32_to_cpu(hdr->ucode_feature_version); | |
| 186 | 190 | |
| 187 | 191 | if (adev->firmware.smu_load) { |
| 188 | 192 | info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i]; |
| @@ -630,8 +634,6 @@ static int sdma_v3_0_load_microcode(struct amdgpu_device *adev) · 441 unmodified lines | ||
| 630 | 634 | hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma[i].fw->data; |
| 631 | 635 | amdgpu_ucode_print_sdma_hdr(&hdr->header); |
| 632 | 636 | fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4; |
| 633 | − adev->sdma[i].fw_version = le32_to_cpu(hdr->header.ucode_version); | |
| 634 | − | |
| 635 | 637 | fw_data = (const __le32 *) |
| 636 | 638 | (adev->sdma[i].fw->data + |
| 637 | 639 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); |
| @@ -196,7 +196,12 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) · 195 unmodified lines | ||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | funcs = connector->helper_private; |
| 199 | − new_encoder = funcs->best_encoder(connector); | |
| 199 | + | |
| 200 | + if (funcs->atomic_best_encoder) | |
| 201 | + new_encoder = funcs->atomic_best_encoder(connector, | |
| 202 | + connector_state); | |
| 203 | + else | |
| 204 | + new_encoder = funcs->best_encoder(connector); | |
| 200 | 205 | |
| 201 | 206 | if (!new_encoder) { |
| 202 | 207 | DRM_DEBUG_ATOMIC("No suitable encoder found for [CONNECTOR:%d:%s]\n", |
| @@ -229,6 +234,9 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx) · 26 unmodified lines | ||
| 229 | 234 | } |
| 230 | 235 | } |
| 231 | 236 | |
| 237 | + if (WARN_ON(!connector_state->crtc)) | |
| 238 | + return -EINVAL; | |
| 239 | + | |
| 232 | 240 | connector_state->best_encoder = new_encoder; |
| 233 | 241 | idx = drm_crtc_index(connector_state->crtc); |
| 234 | 242 | |
| @@ -1294,7 +1294,6 @@ retry: · 1293 unmodified lines | ||
| 1294 | 1294 | goto retry; |
| 1295 | 1295 | } |
| 1296 | 1296 | DRM_DEBUG_KMS("failed to dpcd write %d %d\n", tosend, ret); |
| 1297 | − WARN(1, "fail\n"); | |
| 1298 | 1297 | |
| 1299 | 1298 | return -EIO; |
| 1300 | 1299 | } |
| @@ -75,7 +75,7 @@ module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600) · 74 unmodified lines | ||
| 75 | 75 | module_param_named(timestamp_monotonic, drm_timestamp_monotonic, int, 0600); |
| 76 | 76 | |
| 77 | 77 | static void store_vblank(struct drm_device *dev, int crtc, |
| 78 | − unsigned vblank_count_inc, | |
| 78 | + u32 vblank_count_inc, | |
| 79 | 79 | struct timeval *t_vblank) |
| 80 | 80 | { |
| 81 | 81 | struct drm_vblank_crtc *vblank = &dev->vblank[crtc]; |
| @@ -606,8 +606,6 @@ static void · 605 unmodified lines | ||
| 606 | 606 | tda998x_write_if(struct tda998x_priv *priv, uint8_t bit, uint16_t addr, |
| 607 | 607 | uint8_t *buf, size_t size) |
| 608 | 608 | { |
| 609 | − buf[PB(0)] = tda998x_cksum(buf, size); | |
| 610 | − | |
| 611 | 609 | reg_clear(priv, REG_DIP_IF_FLAGS, bit); |
| 612 | 610 | reg_write_range(priv, addr, buf, size); |
| 613 | 611 | reg_set(priv, REG_DIP_IF_FLAGS, bit); |
| @@ -627,6 +625,8 @@ tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p) · 13 unmodified lines | ||
| 627 | 625 | buf[PB(4)] = p->audio_frame[4]; |
| 628 | 626 | buf[PB(5)] = p->audio_frame[5] & 0xf8; /* DM_INH + LSV */ |
| 629 | 627 | |
| 628 | + buf[PB(0)] = tda998x_cksum(buf, sizeof(buf)); | |
| 629 | + | |
| 630 | 630 | tda998x_write_if(priv, DIP_IF_FLAGS_IF4, REG_IF4_HB0, buf, |
| 631 | 631 | sizeof(buf)); |
| 632 | 632 | } |
| @@ -1075,15 +1075,34 @@ parse_device_mapping(struct drm_i915_private *dev_priv, · 1074 unmodified lines | ||
| 1075 | 1075 | const union child_device_config *p_child; |
| 1076 | 1076 | union child_device_config *child_dev_ptr; |
| 1077 | 1077 | int i, child_device_num, count; |
| 1078 | − u16 block_size; | |
| 1078 | + u8 expected_size; | |
| 1079 | + u16 block_size; | |
| 1079 | 1080 | |
| 1080 | 1081 | p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS); |
| 1081 | 1082 | if (!p_defs) { |
| 1082 | 1083 | DRM_DEBUG_KMS("No general definition block is found, no devices defined.\n"); |
| 1083 | 1084 | return; |
| 1084 | 1085 | } |
| 1085 | − if (p_defs->child_dev_size < sizeof(*p_child)) { | |
| 1086 | − DRM_ERROR("General definiton block child device size is too small.\n"); | |
| 1086 | + if (bdb->version < 195) { | |
| 1087 | + expected_size = 33; | |
| 1088 | + } else if (bdb->version == 195) { | |
| 1089 | + expected_size = 37; | |
| 1090 | + } else if (bdb->version <= 197) { | |
| 1091 | + expected_size = 38; | |
| 1092 | + } else { | |
| 1093 | + expected_size = 38; | |
| 1094 | + DRM_DEBUG_DRIVER("Expected child_device_config size for BDB version %u not known; assuming %u\n", | |
| 1095 | + expected_size, bdb->version); | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + if (expected_size > sizeof(*p_child)) { | |
| 1099 | + DRM_ERROR("child_device_config cannot fit in p_child\n"); | |
| 1100 | + return; | |
| 1101 | + } | |
| 1102 | + | |
| 1103 | + if (p_defs->child_dev_size != expected_size) { | |
| 1104 | + DRM_ERROR("Size mismatch; child_device_config size=%u (expected %u); bdb->version: %u\n", | |
| 1105 | + p_defs->child_dev_size, expected_size, bdb->version); | |
| 1087 | 1106 | return; |
| 1088 | 1107 | } |
| 1089 | 1108 | /* get the block size of general definitions */ |
| @@ -1130,7 +1149,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv, · 40 unmodified lines | ||
| 1130 | 1149 | |
| 1131 | 1150 | child_dev_ptr = dev_priv->vbt.child_dev + count; |
| 1132 | 1151 | count++; |
| 1133 | − memcpy(child_dev_ptr, p_child, sizeof(*p_child)); | |
| 1152 | + memcpy(child_dev_ptr, p_child, p_defs->child_dev_size); | |
| 1134 | 1153 | } |
| 1135 | 1154 | return; |
| 1136 | 1155 | } |
| @@ -357,6 +357,16 @@ intel_dp_mst_mode_valid(struct drm_connector *connector, · 356 unmodified lines | ||
| 357 | 357 | return MODE_OK; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | +static struct drm_encoder *intel_mst_atomic_best_encoder(struct drm_connector *connector, | |
| 361 | + struct drm_connector_state *state) | |
| 362 | +{ | |
| 363 | + struct intel_connector *intel_connector = to_intel_connector(connector); | |
| 364 | + struct intel_dp *intel_dp = intel_connector->mst_port; | |
| 365 | + struct intel_crtc *crtc = to_intel_crtc(state->crtc); | |
| 366 | + | |
| 367 | + return &intel_dp->mst_encoders[crtc->pipe]->base.base; | |
| 368 | +} | |
| 369 | + | |
| 360 | 370 | static struct drm_encoder *intel_mst_best_encoder(struct drm_connector *connector) |
| 361 | 371 | { |
| 362 | 372 | struct intel_connector *intel_connector = to_intel_connector(connector); |
| @@ -367,6 +377,7 @@ static struct drm_encoder *intel_mst_best_encoder(struct drm_connector *connecto · 4 unmodified lines | ||
| 367 | 377 | static const struct drm_connector_helper_funcs intel_dp_mst_connector_helper_funcs = { |
| 368 | 378 | .get_modes = intel_dp_mst_get_modes, |
| 369 | 379 | .mode_valid = intel_dp_mst_mode_valid, |
| 380 | + .atomic_best_encoder = intel_mst_atomic_best_encoder, | |
| 370 | 381 | .best_encoder = intel_mst_best_encoder, |
| 371 | 382 | }; |
| 372 | 383 | |
| @@ -462,12 +462,15 @@ out: · 461 unmodified lines | ||
| 462 | 462 | |
| 463 | 463 | static void hidinput_cleanup_battery(struct hid_device *dev) |
| 464 | 464 | { |
| 465 | + const struct power_supply_desc *psy_desc; | |
| 466 | + | |
| 465 | 467 | if (!dev->battery) |
| 466 | 468 | return; |
| 467 | 469 | |
| 470 | + psy_desc = dev->battery->desc; | |
| 468 | 471 | power_supply_unregister(dev->battery); |
| 469 | − kfree(dev->battery->desc->name); | |
| 470 | − kfree(dev->battery->desc); | |
| 472 | + kfree(psy_desc->name); | |
| 473 | + kfree(psy_desc); | |
| 471 | 474 | dev->battery = NULL; |
| 472 | 475 | } |
| 473 | 476 | #else /* !CONFIG_HID_BATTERY_STRENGTH */ |
| @@ -858,7 +858,7 @@ static int uclogic_tablet_enable(struct hid_device *hdev) · 857 unmodified lines | ||
| 858 | 858 | for (p = drvdata->rdesc; |
| 859 | 859 | p <= drvdata->rdesc + drvdata->rsize - 4;) { |
| 860 | 860 | if (p[0] == 0xFE && p[1] == 0xED && p[2] == 0x1D && |
| 861 | − p[3] < sizeof(params)) { | |
| 861 | + p[3] < ARRAY_SIZE(params)) { | |
| 862 | 862 | v = params[p[3]]; |
| 863 | 863 | put_unaligned(cpu_to_le32(v), (s32 *)p); |
| 864 | 864 | p += 4; |
| @@ -1284,6 +1284,39 @@ fail_register_pen_input: · 1283 unmodified lines | ||
| 1284 | 1284 | return error; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | +/* | |
| 1288 | + * Not all devices report physical dimensions from HID. | |
| 1289 | + * Compute the default from hardcoded logical dimension | |
| 1290 | + * and resolution before driver overwrites them. | |
| 1291 | + */ | |
| 1292 | +static void wacom_set_default_phy(struct wacom_features *features) | |
| 1293 | +{ | |
| 1294 | + if (features->x_resolution) { | |
| 1295 | + features->x_phy = (features->x_max * 100) / | |
| 1296 | + features->x_resolution; | |
| 1297 | + features->y_phy = (features->y_max * 100) / | |
| 1298 | + features->y_resolution; | |
| 1299 | + } | |
| 1300 | +} | |
| 1301 | + | |
| 1302 | +static void wacom_calculate_res(struct wacom_features *features) | |
| 1303 | +{ | |
| 1304 | + /* set unit to "100th of a mm" for devices not reported by HID */ | |
| 1305 | + if (!features->unit) { | |
| 1306 | + features->unit = 0x11; | |
| 1307 | + features->unitExpo = -3; | |
| 1308 | + } | |
| 1309 | + | |
| 1310 | + features->x_resolution = wacom_calc_hid_res(features->x_max, | |
| 1311 | + features->x_phy, | |
| 1312 | + features->unit, | |
| 1313 | + features->unitExpo); | |
| 1314 | + features->y_resolution = wacom_calc_hid_res(features->y_max, | |
| 1315 | + features->y_phy, | |
| 1316 | + features->unit, | |
| 1317 | + features->unitExpo); | |
| 1318 | +} | |
| 1319 | + | |
| 1287 | 1320 | static void wacom_wireless_work(struct work_struct *work) |
| 1288 | 1321 | { |
| 1289 | 1322 | struct wacom *wacom = container_of(work, struct wacom, work); |
| @@ -1341,6 +1374,8 @@ static void wacom_wireless_work(struct work_struct *work) · 51 unmodified lines | ||
| 1341 | 1374 | if (wacom_wac1->features.type != INTUOSHT && |
| 1342 | 1375 | wacom_wac1->features.type != BAMBOO_PT) |
| 1343 | 1376 | wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD; |
| 1377 | + wacom_set_default_phy(&wacom_wac1->features); | |
| 1378 | + wacom_calculate_res(&wacom_wac1->features); | |
| 1344 | 1379 | snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen", |
| 1345 | 1380 | wacom_wac1->features.name); |
| 1346 | 1381 | snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", |
| @@ -1359,7 +1394,9 @@ static void wacom_wireless_work(struct work_struct *work) · 12 unmodified lines | ||
| 1359 | 1394 | wacom_wac2->features = |
| 1360 | 1395 | *((struct wacom_features *)id->driver_data); |
| 1361 | 1396 | wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; |
| 1397 | + wacom_set_default_phy(&wacom_wac2->features); | |
| 1362 | 1398 | wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; |
| 1399 | + wacom_calculate_res(&wacom_wac2->features); | |
| 1363 | 1400 | snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX, |
| 1364 | 1401 | "%s (WL) Finger",wacom_wac2->features.name); |
| 1365 | 1402 | snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, |
| @@ -1407,39 +1444,6 @@ void wacom_battery_work(struct work_struct *work) · 41 unmodified lines | ||
| 1407 | 1444 | } |
| 1408 | 1445 | } |
| 1409 | 1446 | |
| 1410 | −/* | |
| 1411 | − * Not all devices report physical dimensions from HID. | |
| 1412 | − * Compute the default from hardcoded logical dimension | |
| 1413 | − * and resolution before driver overwrites them. | |
| 1414 | − */ | |
| 1415 | −static void wacom_set_default_phy(struct wacom_features *features) | |
| 1416 | −{ | |
| 1417 | − if (features->x_resolution) { | |
| 1418 | − features->x_phy = (features->x_max * 100) / | |
| 1419 | − features->x_resolution; | |
| 1420 | − features->y_phy = (features->y_max * 100) / | |
| 1421 | − features->y_resolution; | |
| 1422 | − } | |
| 1423 | −} | |
| 1424 | − | |
| 1425 | −static void wacom_calculate_res(struct wacom_features *features) | |
| 1426 | −{ | |
| 1427 | − /* set unit to "100th of a mm" for devices not reported by HID */ | |
| 1428 | − if (!features->unit) { | |
| 1429 | − features->unit = 0x11; | |
| 1430 | − features->unitExpo = -3; | |
| 1431 | − } | |
| 1432 | − | |
| 1433 | − features->x_resolution = wacom_calc_hid_res(features->x_max, | |
| 1434 | − features->x_phy, | |
| 1435 | − features->unit, | |
| 1436 | − features->unitExpo); | |
| 1437 | − features->y_resolution = wacom_calc_hid_res(features->y_max, | |
| 1438 | − features->y_phy, | |
| 1439 | − features->unit, | |
| 1440 | − features->unitExpo); | |
| 1441 | −} | |
| 1442 | − | |
| 1443 | 1447 | static size_t wacom_compute_pktlen(struct hid_device *hdev) |
| 1444 | 1448 | { |
| 1445 | 1449 | struct hid_report_enum *report_enum; |
| @@ -929,6 +929,21 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { · 928 unmodified lines | ||
| 929 | 929 | |
| 930 | 930 | MODULE_DEVICE_TABLE(dmi, i8k_dmi_table); |
| 931 | 931 | |
| 932 | +static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = { | |
| 933 | + { | |
| 934 | + /* | |
| 935 | + * CPU fan speed going up and down on Dell Studio XPS 8100 | |
| 936 | + * for unknown reasons. | |
| 937 | + */ | |
| 938 | + .ident = "Dell Studio XPS 8100", | |
| 939 | + .matches = { | |
| 940 | + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | |
| 941 | + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Studio XPS 8100"), | |
| 942 | + }, | |
| 943 | + }, | |
| 944 | + { } | |
| 945 | +}; | |
| 946 | + | |
| 932 | 947 | /* |
| 933 | 948 | * Probe for the presence of a supported laptop. |
| 934 | 949 | */ |
| @@ -940,7 +955,8 @@ static int __init i8k_probe(void) · 5 unmodified lines | ||
| 940 | 955 | /* |
| 941 | 956 | * Get DMI information |
| 942 | 957 | */ |
| 943 | − if (!dmi_check_system(i8k_dmi_table)) { | |
| 958 | + if (!dmi_check_system(i8k_dmi_table) || | |
| 959 | + dmi_check_system(i8k_blacklist_dmi_table)) { | |
| 944 | 960 | if (!ignore_dmi && !force) |
| 945 | 961 | return -ENODEV; |
| 946 | 962 | |
| @@ -582,6 +582,7 @@ static const struct of_device_id g762_dt_match[] = { · 581 unmodified lines | ||
| 582 | 582 | { .compatible = "gmt,g763" }, |
| 583 | 583 | { }, |
| 584 | 584 | }; |
| 585 | +MODULE_DEVICE_TABLE(of, g762_dt_match); | |
| 585 | 586 | |
| 586 | 587 | /* |
| 587 | 588 | * Grab clock (a required property), enable it, get (fixed) clock frequency |
| @@ -575,6 +575,7 @@ static const struct i2c_device_id nct7904_id[] = { · 574 unmodified lines | ||
| 575 | 575 | {"nct7904", 0}, |
| 576 | 576 | {} |
| 577 | 577 | }; |
| 578 | +MODULE_DEVICE_TABLE(i2c, nct7904_id); | |
| 578 | 579 | |
| 579 | 580 | static struct i2c_driver nct7904_driver = { |
| 580 | 581 | .class = I2C_CLASS_HWMON, |
| @@ -692,7 +692,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev) · 691 unmodified lines | ||
| 692 | 692 | |
| 693 | 693 | platform_set_drvdata(pdev, iface); |
| 694 | 694 | |
| 695 | − dev_info(&pdev->dev, "Blackfin BF5xx on-chip I2C TWI Contoller, " | |
| 695 | + dev_info(&pdev->dev, "Blackfin BF5xx on-chip I2C TWI Controller, " | |
| 696 | 696 | "regs_base@%p\n", iface->regs_base); |
| 697 | 697 | |
| 698 | 698 | return 0; |
| @@ -735,6 +735,6 @@ subsys_initcall(i2c_bfin_twi_init); · 36 unmodified lines | ||
| 735 | 735 | module_exit(i2c_bfin_twi_exit); |
| 736 | 736 | |
| 737 | 737 | MODULE_AUTHOR("Bryan Wu, Sonic Zhang"); |
| 738 | −MODULE_DESCRIPTION("Blackfin BF5xx on-chip I2C TWI Contoller Driver"); | |
| 738 | +MODULE_DESCRIPTION("Blackfin BF5xx on-chip I2C TWI Controller Driver"); | |
| 739 | 739 | MODULE_LICENSE("GPL"); |
| 740 | 740 | MODULE_ALIAS("platform:i2c-bfin-twi"); |
| @@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap) · 1246 unmodified lines | ||
| 1247 | 1247 | u32 reg; |
| 1248 | 1248 | |
| 1249 | 1249 | reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG); |
| 1250 | + /* enable test mode */ | |
| 1250 | 1251 | reg |= OMAP_I2C_SYSTEST_ST_EN; |
| 1252 | + /* select SDA/SCL IO mode */ | |
| 1253 | + reg |= 3 << OMAP_I2C_SYSTEST_TMODE_SHIFT; | |
| 1254 | + /* set SCL to high-impedance state (reset value is 0) */ | |
| 1255 | + reg |= OMAP_I2C_SYSTEST_SCL_O; | |
| 1256 | + /* set SDA to high-impedance state (reset value is 0) */ | |
| 1257 | + reg |= OMAP_I2C_SYSTEST_SDA_O; | |
| 1251 | 1258 | omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg); |
| 1252 | 1259 | } |
| 1253 | 1260 | |
| @@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap) · 3 unmodified lines | ||
| 1257 | 1264 | u32 reg; |
| 1258 | 1265 | |
| 1259 | 1266 | reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG); |
| 1267 | + /* restore reset values */ | |
| 1260 | 1268 | reg &= ~OMAP_I2C_SYSTEST_ST_EN; |
| 1269 | + reg &= ~OMAP_I2C_SYSTEST_TMODE_MASK; | |
| 1270 | + reg &= ~OMAP_I2C_SYSTEST_SCL_O; | |
| 1271 | + reg &= ~OMAP_I2C_SYSTEST_SDA_O; | |
| 1261 | 1272 | omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg); |
| 1262 | 1273 | } |
| 1263 | 1274 | |
| @@ -567,6 +567,9 @@ static int i2c_generic_recovery(struct i2c_adapter *adap) · 566 unmodified lines | ||
| 567 | 567 | if (bri->prepare_recovery) |
| 568 | 568 | bri->prepare_recovery(adap); |
| 569 | 569 | |
| 570 | + bri->set_scl(adap, val); | |
| 571 | + ndelay(RECOVERY_NDELAY); | |
| 572 | + | |
| 570 | 573 | /* |
| 571 | 574 | * By this time SCL is high, as we need to give 9 falling-rising edges |
| 572 | 575 | */ |
| @@ -597,7 +600,6 @@ static int i2c_generic_recovery(struct i2c_adapter *adap) · 24 unmodified lines | ||
| 597 | 600 | |
| 598 | 601 | int i2c_generic_scl_recovery(struct i2c_adapter *adap) |
| 599 | 602 | { |
| 600 | − adap->bus_recovery_info->set_scl(adap, 1); | |
| 601 | 603 | return i2c_generic_recovery(adap); |
| 602 | 604 | } |
| 603 | 605 | EXPORT_SYMBOL_GPL(i2c_generic_scl_recovery); |
| @@ -1338,13 +1340,17 @@ static int of_dev_node_match(struct device *dev, void *data) · 734 unmodified lines | ||
| 1338 | 1340 | struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) |
| 1339 | 1341 | { |
| 1340 | 1342 | struct device *dev; |
| 1343 | + struct i2c_client *client; | |
| 1341 | 1344 | |
| 1342 | − dev = bus_find_device(&i2c_bus_type, NULL, node, | |
| 1343 | − of_dev_node_match); | |
| 1345 | + dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match); | |
| 1344 | 1346 | if (!dev) |
| 1345 | 1347 | return NULL; |
| 1346 | 1348 | |
| 1347 | − return i2c_verify_client(dev); | |
| 1349 | + client = i2c_verify_client(dev); | |
| 1350 | + if (!client) | |
| 1351 | + put_device(dev); | |
| 1352 | + | |
| 1353 | + return client; | |
| 1348 | 1354 | } |
| 1349 | 1355 | EXPORT_SYMBOL(of_find_i2c_device_by_node); |
| 1350 | 1356 | |
| @@ -1352,13 +1358,17 @@ EXPORT_SYMBOL(of_find_i2c_device_by_node); · 1 unmodified line | ||
| 1352 | 1358 | struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) |
| 1353 | 1359 | { |
| 1354 | 1360 | struct device *dev; |
| 1361 | + struct i2c_adapter *adapter; | |
| 1355 | 1362 | |
| 1356 | − dev = bus_find_device(&i2c_bus_type, NULL, node, | |
| 1357 | − of_dev_node_match); | |
| 1363 | + dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match); | |
| 1358 | 1364 | if (!dev) |
| 1359 | 1365 | return NULL; |
| 1360 | 1366 | |
| 1361 | − return i2c_verify_adapter(dev); | |
| 1367 | + adapter = i2c_verify_adapter(dev); | |
| 1368 | + if (!adapter) | |
| 1369 | + put_device(dev); | |
| 1370 | + | |
| 1371 | + return adapter; | |
| 1362 | 1372 | } |
| 1363 | 1373 | EXPORT_SYMBOL(of_find_i2c_adapter_by_node); |
| 1364 | 1374 | #else |
| @@ -80,9 +80,6 @@ static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj · 79 unmodified lines | ||
| 80 | 80 | struct eeprom_data *eeprom; |
| 81 | 81 | unsigned long flags; |
| 82 | 82 | |
| 83 | − if (off + count > attr->size) | |
| 84 | − return -EFBIG; | |
| 85 | − | |
| 86 | 83 | eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj)); |
| 87 | 84 | |
| 88 | 85 | spin_lock_irqsave(&eeprom->buffer_lock, flags); |
| @@ -98,9 +95,6 @@ static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kob · 9 unmodified lines | ||
| 98 | 95 | struct eeprom_data *eeprom; |
| 99 | 96 | unsigned long flags; |
| 100 | 97 | |
| 101 | − if (off + count > attr->size) | |
| 102 | − return -EFBIG; | |
| 103 | − | |
| 104 | 98 | eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj)); |
| 105 | 99 | |
| 106 | 100 | spin_lock_irqsave(&eeprom->buffer_lock, flags); |
| @@ -196,7 +196,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) · 195 unmodified lines | ||
| 196 | 196 | if (n_buttons[i] < 1) |
| 197 | 197 | continue; |
| 198 | 198 | |
| 199 | − if (n_buttons[i] > 6) { | |
| 199 | + if (n_buttons[i] > ARRAY_SIZE(tgfx_buttons)) { | |
| 200 | 200 | printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); |
| 201 | 201 | err = -EINVAL; |
| 202 | 202 | goto err_unreg_devs; |
| @@ -292,3 +292,4 @@ module_platform_driver(axp20x_pek_driver); · 291 unmodified lines | ||
| 292 | 292 | MODULE_DESCRIPTION("axp20x Power Button"); |
| 293 | 293 | MODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); |
| 294 | 294 | MODULE_LICENSE("GPL"); |
| 295 | +MODULE_ALIAS("platform:axp20x-pek"); | |
| @@ -183,7 +183,8 @@ static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata, · 182 unmodified lines | ||
| 183 | 183 | if (pdata && pdata->coexist) |
| 184 | 184 | return true; |
| 185 | 185 | |
| 186 | − if (of_find_node_by_name(node, "codec")) { | |
| 186 | + node = of_find_node_by_name(node, "codec"); | |
| 187 | + if (node) { | |
| 187 | 188 | of_node_put(node); |
| 188 | 189 | return true; |
| 189 | 190 | } |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <linux/input/mt.h> |
| 21 | 21 | #include <linux/serio.h> |
| 22 | 22 | #include <linux/libps2.h> |
| 23 | +#include <linux/dmi.h> | |
| 23 | 24 | |
| 24 | 25 | #include "psmouse.h" |
| 25 | 26 | #include "alps.h" |
| @@ -99,6 +100,7 @@ static const struct alps_nibble_commands alps_v6_nibble_commands[] = { · 73 unmodified lines | ||
| 99 | 100 | #define ALPS_FOUR_BUTTONS 0x40 /* 4 direction button present */ |
| 100 | 101 | #define ALPS_PS2_INTERLEAVED 0x80 /* 3-byte PS/2 packet interleaved with |
| 101 | 102 | 6-byte ALPS packet */ |
| 103 | +#define ALPS_DELL 0x100 /* device is a Dell laptop */ | |
| 102 | 104 | #define ALPS_BUTTONPAD 0x200 /* device is a clickpad */ |
| 103 | 105 | |
| 104 | 106 | static const struct alps_model_info alps_model_data[] = { |
| @@ -251,9 +253,9 @@ static void alps_process_packet_v1_v2(struct psmouse *psmouse) · 146 unmodified lines | ||
| 251 | 253 | return; |
| 252 | 254 | } |
| 253 | 255 | |
| 254 | − /* Non interleaved V2 dualpoint has separate stick button bits */ | |
| 256 | + /* Dell non interleaved V2 dualpoint has separate stick button bits */ | |
| 255 | 257 | if (priv->proto_version == ALPS_PROTO_V2 && |
| 256 | − priv->flags == (ALPS_PASS | ALPS_DUALPOINT)) { | |
| 258 | + priv->flags == (ALPS_DELL | ALPS_PASS | ALPS_DUALPOINT)) { | |
| 257 | 259 | left |= packet[0] & 1; |
| 258 | 260 | right |= packet[0] & 2; |
| 259 | 261 | middle |= packet[0] & 4; |
| @@ -2550,6 +2552,8 @@ static int alps_set_protocol(struct psmouse *psmouse, · 2290 unmodified lines | ||
| 2550 | 2552 | priv->byte0 = protocol->byte0; |
| 2551 | 2553 | priv->mask0 = protocol->mask0; |
| 2552 | 2554 | priv->flags = protocol->flags; |
| 2555 | + if (dmi_name_in_vendors("Dell")) | |
| 2556 | + priv->flags |= ALPS_DELL; | |
| 2553 | 2557 | |
| 2554 | 2558 | priv->x_max = 2000; |
| 2555 | 2559 | priv->y_max = 1400; |
| @@ -783,19 +783,26 @@ static int elantech_packet_check_v4(struct psmouse *psmouse) · 782 unmodified lines | ||
| 783 | 783 | struct elantech_data *etd = psmouse->private; |
| 784 | 784 | unsigned char *packet = psmouse->packet; |
| 785 | 785 | unsigned char packet_type = packet[3] & 0x03; |
| 786 | + unsigned int ic_version; | |
| 786 | 787 | bool sanity_check; |
| 787 | 788 | |
| 788 | 789 | if (etd->tp_dev && (packet[3] & 0x0f) == 0x06) |
| 789 | 790 | return PACKET_TRACKPOINT; |
| 790 | 791 | |
| 792 | + /* This represents the version of IC body. */ | |
| 793 | + ic_version = (etd->fw_version & 0x0f0000) >> 16; | |
| 794 | + | |
| 791 | 795 | /* |
| 792 | 796 | * Sanity check based on the constant bits of a packet. |
| 793 | 797 | * The constant bits change depending on the value of |
| 794 | − * the hardware flag 'crc_enabled' but are the same for | |
| 795 | − * every packet, regardless of the type. | |
| 798 | + * the hardware flag 'crc_enabled' and the version of | |
| 799 | + * the IC body, but are the same for every packet, | |
| 800 | + * regardless of the type. | |
| 796 | 801 | */ |
| 797 | 802 | if (etd->crc_enabled) |
| 798 | 803 | sanity_check = ((packet[3] & 0x08) == 0x00); |
| 804 | + else if (ic_version == 7 && etd->samples[1] == 0x2A) | |
| 805 | + sanity_check = ((packet[3] & 0x1c) == 0x10); | |
| 799 | 806 | else |
| 800 | 807 | sanity_check = ((packet[0] & 0x0c) == 0x04 && |
| 801 | 808 | (packet[3] & 0x1c) == 0x10); |
| @@ -1116,6 +1123,7 @@ static int elantech_get_resolution_v4(struct psmouse *psmouse, · 314 unmodified lines | ||
| 1116 | 1123 | * Avatar AVIU-145A2 0x361f00 ? clickpad |
| 1117 | 1124 | * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons |
| 1118 | 1125 | * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons |
| 1126 | + * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons | |
| 1119 | 1127 | * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) |
| 1120 | 1128 | * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons |
| 1121 | 1129 | * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*) |
| @@ -1651,6 +1659,16 @@ int elantech_init(struct psmouse *psmouse) · 529 unmodified lines | ||
| 1651 | 1659 | etd->capabilities[0], etd->capabilities[1], |
| 1652 | 1660 | etd->capabilities[2]); |
| 1653 | 1661 | |
| 1662 | + if (etd->hw_version != 1) { | |
| 1663 | + if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, etd->samples)) { | |
| 1664 | + psmouse_err(psmouse, "failed to query sample data\n"); | |
| 1665 | + goto init_fail; | |
| 1666 | + } | |
| 1667 | + psmouse_info(psmouse, | |
| 1668 | + "Elan sample query result %02x, %02x, %02x\n", | |
| 1669 | + etd->samples[0], etd->samples[1], etd->samples[2]); | |
| 1670 | + } | |
| 1671 | + | |
| 1654 | 1672 | if (elantech_set_absolute_mode(psmouse)) { |
| 1655 | 1673 | psmouse_err(psmouse, |
| 1656 | 1674 | "failed to put touchpad into absolute mode.\n"); |
| @@ -129,6 +129,7 @@ struct elantech_data { · 128 unmodified lines | ||
| 129 | 129 | unsigned char reg_26; |
| 130 | 130 | unsigned char debug; |
| 131 | 131 | unsigned char capabilities[3]; |
| 132 | + unsigned char samples[3]; | |
| 132 | 133 | bool paritycheck; |
| 133 | 134 | bool jumpy_cursor; |
| 134 | 135 | bool reports_pressure; |
| @@ -538,7 +538,7 @@ static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) · 537 unmodified lines | ||
| 538 | 538 | |
| 539 | 539 | static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) |
| 540 | 540 | { |
| 541 | − smp_call_function_interrupt(); | |
| 541 | + generic_smp_call_function_interrupt(); | |
| 542 | 542 | |
| 543 | 543 | return IRQ_HANDLED; |
| 544 | 544 | } |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #include <linux/kernel.h> |
| 8 | 8 | #include <linux/miscdevice.h> |
| 9 | 9 | #include <linux/fcntl.h> |
| 10 | −#include <linux/init.h> | |
| 10 | +#include <linux/module.h> | |
| 11 | 11 | #include <linux/delay.h> |
| 12 | 12 | #include <linux/fs.h> |
| 13 | 13 | |
| @@ -1471,5 +1471,3 @@ module_exit(mq_exit); · 1470 unmodified lines | ||
| 1471 | 1471 | MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>"); |
| 1472 | 1472 | MODULE_LICENSE("GPL"); |
| 1473 | 1473 | MODULE_DESCRIPTION("mq cache policy"); |
| 1474 | − | |
| 1475 | −MODULE_ALIAS("dm-cache-default"); | |
| @@ -1789,3 +1789,5 @@ module_exit(smq_exit); · 1788 unmodified lines | ||
| 1789 | 1789 | MODULE_AUTHOR("Joe Thornber <dm-devel@redhat.com>"); |
| 1790 | 1790 | MODULE_LICENSE("GPL"); |
| 1791 | 1791 | MODULE_DESCRIPTION("smq cache policy"); |
| 1792 | + | |
| 1793 | +MODULE_ALIAS("dm-cache-default"); | |
| @@ -1293,8 +1293,8 @@ static int __release_metadata_snap(struct dm_pool_metadata *pmd) · 1292 unmodified lines | ||
| 1293 | 1293 | return r; |
| 1294 | 1294 | |
| 1295 | 1295 | disk_super = dm_block_data(copy); |
| 1296 | − dm_sm_dec_block(pmd->metadata_sm, le64_to_cpu(disk_super->data_mapping_root)); | |
| 1297 | − dm_sm_dec_block(pmd->metadata_sm, le64_to_cpu(disk_super->device_details_root)); | |
| 1296 | + dm_btree_del(&pmd->info, le64_to_cpu(disk_super->data_mapping_root)); | |
| 1297 | + dm_btree_del(&pmd->details_info, le64_to_cpu(disk_super->device_details_root)); | |
| 1298 | 1298 | dm_sm_dec_block(pmd->metadata_sm, held_root); |
| 1299 | 1299 | |
| 1300 | 1300 | return dm_tm_unlock(pmd->tm, copy); |
| @@ -1729,7 +1729,8 @@ static int dm_merge_bvec(struct request_queue *q, · 1728 unmodified lines | ||
| 1729 | 1729 | struct mapped_device *md = q->queuedata; |
| 1730 | 1730 | struct dm_table *map = dm_get_live_table_fast(md); |
| 1731 | 1731 | struct dm_target *ti; |
| 1732 | − sector_t max_sectors, max_size = 0; | |
| 1732 | + sector_t max_sectors; | |
| 1733 | + int max_size = 0; | |
| 1733 | 1734 | |
| 1734 | 1735 | if (unlikely(!map)) |
| 1735 | 1736 | goto out; |
| @@ -1742,18 +1743,10 @@ static int dm_merge_bvec(struct request_queue *q, · 6 unmodified lines | ||
| 1742 | 1743 | * Find maximum amount of I/O that won't need splitting |
| 1743 | 1744 | */ |
| 1744 | 1745 | max_sectors = min(max_io_len(bvm->bi_sector, ti), |
| 1745 | − (sector_t) queue_max_sectors(q)); | |
| 1746 | + (sector_t) BIO_MAX_SECTORS); | |
| 1746 | 1747 | max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size; |
| 1747 | − | |
| 1748 | − /* | |
| 1749 | − * FIXME: this stop-gap fix _must_ be cleaned up (by passing a sector_t | |
| 1750 | − * to the targets' merge function since it holds sectors not bytes). | |
| 1751 | − * Just doing this as an interim fix for stable@ because the more | |
| 1752 | − * comprehensive cleanup of switching to sector_t will impact every | |
| 1753 | − * DM target that implements a ->merge hook. | |
| 1754 | − */ | |
| 1755 | − if (max_size > INT_MAX) | |
| 1756 | − max_size = INT_MAX; | |
| 1748 | + if (max_size < 0) | |
| 1749 | + max_size = 0; | |
| 1757 | 1750 | |
| 1758 | 1751 | /* |
| 1759 | 1752 | * merge_bvec_fn() returns number of bytes |
| @@ -1761,13 +1754,13 @@ static int dm_merge_bvec(struct request_queue *q, · 1 unmodified line | ||
| 1761 | 1754 | * max is precomputed maximal io size |
| 1762 | 1755 | */ |
| 1763 | 1756 | if (max_size && ti->type->merge) |
| 1764 | − max_size = ti->type->merge(ti, bvm, biovec, (int) max_size); | |
| 1757 | + max_size = ti->type->merge(ti, bvm, biovec, max_size); | |
| 1765 | 1758 | /* |
| 1766 | 1759 | * If the target doesn't support merge method and some of the devices |
| 1767 | − * provided their merge_bvec method (we know this by looking for the | |
| 1768 | − * max_hw_sectors that dm_set_device_limits may set), then we can't | |
| 1769 | − * allow bios with multiple vector entries. So always set max_size | |
| 1770 | − * to 0, and the code below allows just one page. | |
| 1760 | + * provided their merge_bvec method (we know this by looking at | |
| 1761 | + * queue_max_hw_sectors), then we can't allow bios with multiple vector | |
| 1762 | + * entries. So always set max_size to 0, and the code below allows | |
| 1763 | + * just one page. | |
| 1771 | 1764 | */ |
| 1772 | 1765 | else if (queue_max_hw_sectors(q) <= PAGE_SIZE >> 9) |
| 1773 | 1766 | max_size = 0; |
| @@ -5759,7 +5759,7 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg) · 5758 unmodified lines | ||
| 5759 | 5759 | char *ptr; |
| 5760 | 5760 | int err; |
| 5761 | 5761 | |
| 5762 | − file = kmalloc(sizeof(*file), GFP_NOIO); | |
| 5762 | + file = kzalloc(sizeof(*file), GFP_NOIO); | |
| 5763 | 5763 | if (!file) |
| 5764 | 5764 | return -ENOMEM; |
| 5765 | 5765 | |
| @@ -138,4 +138,10 @@ int lower_bound(struct btree_node *n, uint64_t key); · 137 unmodified lines | ||
| 138 | 138 | |
| 139 | 139 | extern struct dm_block_validator btree_node_validator; |
| 140 | 140 | |
| 141 | +/* | |
| 142 | + * Value type for upper levels of multi-level btrees. | |
| 143 | + */ | |
| 144 | +extern void init_le64_type(struct dm_transaction_manager *tm, | |
| 145 | + struct dm_btree_value_type *vt); | |
| 146 | + | |
| 141 | 147 | #endif /* DM_BTREE_INTERNAL_H */ |
| @@ -544,14 +544,6 @@ static int remove_raw(struct shadow_spine *s, struct dm_btree_info *info, · 543 unmodified lines | ||
| 544 | 544 | return r; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | −static struct dm_btree_value_type le64_type = { | |
| 548 | − .context = NULL, | |
| 549 | − .size = sizeof(__le64), | |
| 550 | − .inc = NULL, | |
| 551 | − .dec = NULL, | |
| 552 | − .equal = NULL | |
| 553 | −}; | |
| 554 | − | |
| 555 | 547 | int dm_btree_remove(struct dm_btree_info *info, dm_block_t root, |
| 556 | 548 | uint64_t *keys, dm_block_t *new_root) |
| 557 | 549 | { |
| @@ -559,12 +551,14 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root, · 1 unmodified line | ||
| 559 | 551 | int index = 0, r = 0; |
| 560 | 552 | struct shadow_spine spine; |
| 561 | 553 | struct btree_node *n; |
| 554 | + struct dm_btree_value_type le64_vt; | |
| 562 | 555 | |
| 556 | + init_le64_type(info->tm, &le64_vt); | |
| 563 | 557 | init_shadow_spine(&spine, info); |
| 564 | 558 | for (level = 0; level < info->levels; level++) { |
| 565 | 559 | r = remove_raw(&spine, info, |
| 566 | 560 | (level == last_level ? |
| 567 | − &info->value_type : &le64_type), | |
| 561 | + &info->value_type : &le64_vt), | |
| 568 | 562 | root, keys[level], (unsigned *)&index); |
| 569 | 563 | if (r < 0) |
| 570 | 564 | break; |
| @@ -654,11 +648,13 @@ static int remove_one(struct dm_btree_info *info, dm_block_t root, · 83 unmodified lines | ||
| 654 | 648 | int index = 0, r = 0; |
| 655 | 649 | struct shadow_spine spine; |
| 656 | 650 | struct btree_node *n; |
| 651 | + struct dm_btree_value_type le64_vt; | |
| 657 | 652 | uint64_t k; |
| 658 | 653 | |
| 654 | + init_le64_type(info->tm, &le64_vt); | |
| 659 | 655 | init_shadow_spine(&spine, info); |
| 660 | 656 | for (level = 0; level < last_level; level++) { |
| 661 | − r = remove_raw(&spine, info, &le64_type, | |
| 657 | + r = remove_raw(&spine, info, &le64_vt, | |
| 662 | 658 | root, keys[level], (unsigned *) &index); |
| 663 | 659 | if (r < 0) |
| 664 | 660 | goto out; |
| @@ -689,6 +685,7 @@ static int remove_one(struct dm_btree_info *info, dm_block_t root, · 24 unmodified lines | ||
| 689 | 685 | value_ptr(n, index)); |
| 690 | 686 | |
| 691 | 687 | delete_at(n, index); |
| 688 | + keys[last_level] = k + 1ull; | |
| 692 | 689 | |
| 693 | 690 | } else |
| 694 | 691 | r = -ENODATA; |
| @@ -249,3 +249,40 @@ int shadow_root(struct shadow_spine *s) · 248 unmodified lines | ||
| 249 | 249 | { |
| 250 | 250 | return s->root; |
| 251 | 251 | } |
| 252 | + | |
| 253 | +static void le64_inc(void *context, const void *value_le) | |
| 254 | +{ | |
| 255 | + struct dm_transaction_manager *tm = context; | |
| 256 | + __le64 v_le; | |
| 257 | + | |
| 258 | + memcpy(&v_le, value_le, sizeof(v_le)); | |
| 259 | + dm_tm_inc(tm, le64_to_cpu(v_le)); | |
| 260 | +} | |
| 261 | + | |
| 262 | +static void le64_dec(void *context, const void *value_le) | |
| 263 | +{ | |
| 264 | + struct dm_transaction_manager *tm = context; | |
| 265 | + __le64 v_le; | |
| 266 | + | |
| 267 | + memcpy(&v_le, value_le, sizeof(v_le)); | |
| 268 | + dm_tm_dec(tm, le64_to_cpu(v_le)); | |
| 269 | +} | |
| 270 | + | |
| 271 | +static int le64_equal(void *context, const void *value1_le, const void *value2_le) | |
| 272 | +{ | |
| 273 | + __le64 v1_le, v2_le; | |
| 274 | + | |
| 275 | + memcpy(&v1_le, value1_le, sizeof(v1_le)); | |
| 276 | + memcpy(&v2_le, value2_le, sizeof(v2_le)); | |
| 277 | + return v1_le == v2_le; | |
| 278 | +} | |
| 279 | + | |
| 280 | +void init_le64_type(struct dm_transaction_manager *tm, | |
| 281 | + struct dm_btree_value_type *vt) | |
| 282 | +{ | |
| 283 | + vt->context = tm; | |
| 284 | + vt->size = sizeof(__le64); | |
| 285 | + vt->inc = le64_inc; | |
| 286 | + vt->dec = le64_dec; | |
| 287 | + vt->equal = le64_equal; | |
| 288 | +} | |
| @@ -667,12 +667,7 @@ static int insert(struct dm_btree_info *info, dm_block_t root, · 666 unmodified lines | ||
| 667 | 667 | struct btree_node *n; |
| 668 | 668 | struct dm_btree_value_type le64_type; |
| 669 | 669 | |
| 670 | − le64_type.context = NULL; | |
| 671 | − le64_type.size = sizeof(__le64); | |
| 672 | − le64_type.inc = NULL; | |
| 673 | − le64_type.dec = NULL; | |
| 674 | − le64_type.equal = NULL; | |
| 675 | − | |
| 670 | + init_le64_type(info->tm, &le64_type); | |
| 676 | 671 | init_shadow_spine(&spine, info); |
| 677 | 672 | |
| 678 | 673 | for (level = 0; level < (info->levels - 1); level++) { |
| @@ -1476,6 +1476,7 @@ static void error(struct mddev *mddev, struct md_rdev *rdev) · 1475 unmodified lines | ||
| 1476 | 1476 | { |
| 1477 | 1477 | char b[BDEVNAME_SIZE]; |
| 1478 | 1478 | struct r1conf *conf = mddev->private; |
| 1479 | + unsigned long flags; | |
| 1479 | 1480 | |
| 1480 | 1481 | /* |
| 1481 | 1482 | * If it is not operational, then we have already marked it as dead |
| @@ -1495,14 +1496,13 @@ static void error(struct mddev *mddev, struct md_rdev *rdev) · 13 unmodified lines | ||
| 1495 | 1496 | return; |
| 1496 | 1497 | } |
| 1497 | 1498 | set_bit(Blocked, &rdev->flags); |
| 1499 | + spin_lock_irqsave(&conf->device_lock, flags); | |
| 1498 | 1500 | if (test_and_clear_bit(In_sync, &rdev->flags)) { |
| 1499 | − unsigned long flags; | |
| 1500 | − spin_lock_irqsave(&conf->device_lock, flags); | |
| 1501 | 1501 | mddev->degraded++; |
| 1502 | 1502 | set_bit(Faulty, &rdev->flags); |
| 1503 | − spin_unlock_irqrestore(&conf->device_lock, flags); | |
| 1504 | 1503 | } else |
| 1505 | 1504 | set_bit(Faulty, &rdev->flags); |
| 1505 | + spin_unlock_irqrestore(&conf->device_lock, flags); | |
| 1506 | 1506 | /* |
| 1507 | 1507 | * if recovery is running, make sure it aborts. |
| 1508 | 1508 | */ |
| @@ -1568,7 +1568,10 @@ static int raid1_spare_active(struct mddev *mddev) · 59 unmodified lines | ||
| 1568 | 1568 | * Find all failed disks within the RAID1 configuration |
| 1569 | 1569 | * and mark them readable. |
| 1570 | 1570 | * Called under mddev lock, so rcu protection not needed. |
| 1571 | + * device_lock used to avoid races with raid1_end_read_request | |
| 1572 | + * which expects 'In_sync' flags and ->degraded to be consistent. | |
| 1571 | 1573 | */ |
| 1574 | + spin_lock_irqsave(&conf->device_lock, flags); | |
| 1572 | 1575 | for (i = 0; i < conf->raid_disks; i++) { |
| 1573 | 1576 | struct md_rdev *rdev = conf->mirrors[i].rdev; |
| 1574 | 1577 | struct md_rdev *repl = conf->mirrors[conf->raid_disks + i].rdev; |
| @@ -1599,7 +1602,6 @@ static int raid1_spare_active(struct mddev *mddev) · 24 unmodified lines | ||
| 1599 | 1602 | sysfs_notify_dirent_safe(rdev->sysfs_state); |
| 1600 | 1603 | } |
| 1601 | 1604 | } |
| 1602 | − spin_lock_irqsave(&conf->device_lock, flags); | |
| 1603 | 1605 | mddev->degraded -= count; |
| 1604 | 1606 | spin_unlock_irqrestore(&conf->device_lock, flags); |
| 1605 | 1607 | |
| @@ -2256,7 +2256,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) · 2255 unmodified lines | ||
| 2256 | 2256 | static int drop_one_stripe(struct r5conf *conf) |
| 2257 | 2257 | { |
| 2258 | 2258 | struct stripe_head *sh; |
| 2259 | − int hash = (conf->max_nr_stripes - 1) % NR_STRIPE_HASH_LOCKS; | |
| 2259 | + int hash = (conf->max_nr_stripes - 1) & STRIPE_HASH_LOCKS_MASK; | |
| 2260 | 2260 | |
| 2261 | 2261 | spin_lock_irq(conf->hash_locks + hash); |
| 2262 | 2262 | sh = get_free_stripe(conf, hash); |
| @@ -6388,7 +6388,8 @@ static unsigned long raid5_cache_scan(struct shrinker *shrink, · 4125 unmodified lines | ||
| 6388 | 6388 | |
| 6389 | 6389 | if (mutex_trylock(&conf->cache_size_mutex)) { |
| 6390 | 6390 | ret= 0; |
| 6391 | − while (ret < sc->nr_to_scan) { | |
| 6391 | + while (ret < sc->nr_to_scan && | |
| 6392 | + conf->max_nr_stripes > conf->min_nr_stripes) { | |
| 6392 | 6393 | if (drop_one_stripe(conf) == 0) { |
| 6393 | 6394 | ret = SHRINK_STOP; |
| 6394 | 6395 | break; |
| @@ -115,7 +115,7 @@ config MFD_CROS_EC_I2C · 114 unmodified lines | ||
| 115 | 115 | |
| 116 | 116 | config MFD_CROS_EC_SPI |
| 117 | 117 | tristate "ChromeOS Embedded Controller (SPI)" |
| 118 | − depends on MFD_CROS_EC && CROS_EC_PROTO && SPI && OF | |
| 118 | + depends on MFD_CROS_EC && CROS_EC_PROTO && SPI | |
| 119 | 119 | |
| 120 | 120 | ---help--- |
| 121 | 121 | If you say Y here, you get support for talking to the ChromeOS EC |
| @@ -651,7 +651,7 @@ static int arizona_runtime_suspend(struct device *dev) · 650 unmodified lines | ||
| 651 | 651 | |
| 652 | 652 | arizona->has_fully_powered_off = true; |
| 653 | 653 | |
| 654 | − disable_irq(arizona->irq); | |
| 654 | + disable_irq_nosync(arizona->irq); | |
| 655 | 655 | arizona_enable_reset(arizona); |
| 656 | 656 | regulator_bulk_disable(arizona->num_core_supplies, |
| 657 | 657 | arizona->core_supplies); |
| @@ -1141,10 +1141,6 @@ int arizona_dev_init(struct arizona *arizona) · 483 unmodified lines | ||
| 1141 | 1141 | arizona->pdata.gpio_defaults[i]); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | − pm_runtime_set_autosuspend_delay(arizona->dev, 100); | |
| 1145 | − pm_runtime_use_autosuspend(arizona->dev); | |
| 1146 | − pm_runtime_enable(arizona->dev); | |
| 1147 | − | |
| 1148 | 1144 | /* Chip default */ |
| 1149 | 1145 | if (!arizona->pdata.clk32k_src) |
| 1150 | 1146 | arizona->pdata.clk32k_src = ARIZONA_32KZ_MCLK2; |
| @@ -1245,11 +1241,17 @@ int arizona_dev_init(struct arizona *arizona) · 94 unmodified lines | ||
| 1245 | 1241 | arizona->pdata.spk_fmt[i]); |
| 1246 | 1242 | } |
| 1247 | 1243 | |
| 1244 | + pm_runtime_set_active(arizona->dev); | |
| 1245 | + pm_runtime_enable(arizona->dev); | |
| 1246 | + | |
| 1248 | 1247 | /* Set up for interrupts */ |
| 1249 | 1248 | ret = arizona_irq_init(arizona); |
| 1250 | 1249 | if (ret != 0) |
| 1251 | 1250 | goto err_reset; |
| 1252 | 1251 | |
| 1252 | + pm_runtime_set_autosuspend_delay(arizona->dev, 100); | |
| 1253 | + pm_runtime_use_autosuspend(arizona->dev); | |
| 1254 | + | |
| 1253 | 1255 | arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error", |
| 1254 | 1256 | arizona_clkgen_err, arizona); |
| 1255 | 1257 | arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked", |
| @@ -1278,10 +1280,6 @@ int arizona_dev_init(struct arizona *arizona) · 22 unmodified lines | ||
| 1278 | 1280 | goto err_irq; |
| 1279 | 1281 | } |
| 1280 | 1282 | |
| 1281 | −#ifdef CONFIG_PM | |
| 1282 | − regulator_disable(arizona->dcvdd); | |
| 1283 | −#endif | |
| 1284 | − | |
| 1285 | 1283 | return 0; |
| 1286 | 1284 | |
| 1287 | 1285 | err_irq: |
| @@ -438,9 +438,6 @@ static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj, · 437 unmodified lines | ||
| 438 | 438 | { |
| 439 | 439 | struct at24_data *at24; |
| 440 | 440 | |
| 441 | − if (unlikely(off >= attr->size)) | |
| 442 | − return -EFBIG; | |
| 443 | − | |
| 444 | 441 | at24 = dev_get_drvdata(container_of(kobj, struct device, kobj)); |
| 445 | 442 | return at24_write(at24, buf, off, count); |
| 446 | 443 | } |
| @@ -786,6 +786,7 @@ static bool bond_should_notify_peers(struct bonding *bond) · 785 unmodified lines | ||
| 786 | 786 | slave ? slave->dev->name : "NULL"); |
| 787 | 787 | |
| 788 | 788 | if (!slave || !bond->send_peer_notif || |
| 789 | + !netif_carrier_ok(bond->dev) || | |
| 789 | 790 | test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state)) |
| 790 | 791 | return false; |
| 791 | 792 | |
| @@ -1763,16 +1763,9 @@ vortex_open(struct net_device *dev) · 1762 unmodified lines | ||
| 1763 | 1763 | vp->rx_ring[i].addr = cpu_to_le32(pci_map_single(VORTEX_PCI(vp), skb->data, PKT_BUF_SZ, PCI_DMA_FROMDEVICE)); |
| 1764 | 1764 | } |
| 1765 | 1765 | if (i != RX_RING_SIZE) { |
| 1766 | − int j; | |
| 1767 | 1766 | pr_emerg("%s: no memory for rx ring\n", dev->name); |
| 1768 | − for (j = 0; j < i; j++) { | |
| 1769 | − if (vp->rx_skbuff[j]) { | |
| 1770 | − dev_kfree_skb(vp->rx_skbuff[j]); | |
| 1771 | − vp->rx_skbuff[j] = NULL; | |
| 1772 | − } | |
| 1773 | − } | |
| 1774 | 1767 | retval = -ENOMEM; |
| 1775 | − goto err_free_irq; | |
| 1768 | + goto err_free_skb; | |
| 1776 | 1769 | } |
| 1777 | 1770 | /* Wrap the ring. */ |
| 1778 | 1771 | vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma); |
| @@ -1782,7 +1775,13 @@ vortex_open(struct net_device *dev) · 3 unmodified lines | ||
| 1782 | 1775 | if (!retval) |
| 1783 | 1776 | goto out; |
| 1784 | 1777 | |
| 1785 | −err_free_irq: | |
| 1778 | +err_free_skb: | |
| 1779 | + for (i = 0; i < RX_RING_SIZE; i++) { | |
| 1780 | + if (vp->rx_skbuff[i]) { | |
| 1781 | + dev_kfree_skb(vp->rx_skbuff[i]); | |
| 1782 | + vp->rx_skbuff[i] = NULL; | |
| 1783 | + } | |
| 1784 | + } | |
| 1786 | 1785 | free_irq(dev->irq, dev); |
| 1787 | 1786 | err: |
| 1788 | 1787 | if (vortex_debug > 1) |
| @@ -264,9 +264,9 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, · 263 unmodified lines | ||
| 264 | 264 | if (likely(skb)) { |
| 265 | 265 | (*pkts_compl)++; |
| 266 | 266 | (*bytes_compl) += skb->len; |
| 267 | + dev_kfree_skb_any(skb); | |
| 267 | 268 | } |
| 268 | 269 | |
| 269 | − dev_kfree_skb_any(skb); | |
| 270 | 270 | tx_buf->first_bd = 0; |
| 271 | 271 | tx_buf->skb = NULL; |
| 272 | 272 | |
| @@ -1723,6 +1723,22 @@ static int bnx2x_nvram_write(struct bnx2x *bp, u32 offset, u8 *data_buf, · 1722 unmodified lines | ||
| 1723 | 1723 | offset += sizeof(u32); |
| 1724 | 1724 | data_buf += sizeof(u32); |
| 1725 | 1725 | written_so_far += sizeof(u32); |
| 1726 | + | |
| 1727 | + /* At end of each 4Kb page, release nvram lock to allow MFW | |
| 1728 | + * chance to take it for its own use. | |
| 1729 | + */ | |
| 1730 | + if ((cmd_flags & MCPR_NVM_COMMAND_LAST) && | |
| 1731 | + (written_so_far < buf_size)) { | |
| 1732 | + DP(BNX2X_MSG_ETHTOOL | BNX2X_MSG_NVM, | |
| 1733 | + "Releasing NVM lock after offset 0x%x\n", | |
| 1734 | + (u32)(offset - sizeof(u32))); | |
| 1735 | + bnx2x_release_nvram_lock(bp); | |
| 1736 | + usleep_range(1000, 2000); | |
| 1737 | + rc = bnx2x_acquire_nvram_lock(bp); | |
| 1738 | + if (rc) | |
| 1739 | + return rc; | |
| 1740 | + } | |
| 1741 | + | |
| 1726 | 1742 | cmd_flags = 0; |
| 1727 | 1743 | } |
| 1728 | 1744 | |
| @@ -676,6 +676,7 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) · 675 unmodified lines | ||
| 676 | 676 | if (!next_cmpl->valid) |
| 677 | 677 | break; |
| 678 | 678 | } |
| 679 | + packets++; | |
| 679 | 680 | |
| 680 | 681 | /* TODO: BNA_CQ_EF_LOCAL ? */ |
| 681 | 682 | if (unlikely(flags & (BNA_CQ_EF_MAC_ERROR | |
| @@ -692,7 +693,6 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) · 10 unmodified lines | ||
| 692 | 693 | else |
| 693 | 694 | bnad_cq_setup_skb_frags(rcb, skb, sop_ci, nvecs, len); |
| 694 | 695 | |
| 695 | − packets++; | |
| 696 | 696 | rcb->rxq->rx_packets++; |
| 697 | 697 | rcb->rxq->rx_bytes += totlen; |
| 698 | 698 | ccb->bytes_per_intr += totlen; |
| @@ -16,7 +16,6 @@ if NET_VENDOR_CAVIUM · 15 unmodified lines | ||
| 16 | 16 | config THUNDER_NIC_PF |
| 17 | 17 | tristate "Thunder Physical function driver" |
| 18 | 18 | depends on 64BIT |
| 19 | − default ARCH_THUNDER | |
| 20 | 19 | select THUNDER_NIC_BGX |
| 21 | 20 | ---help--- |
| 22 | 21 | This driver supports Thunder's NIC physical function. |
| @@ -29,14 +28,12 @@ config THUNDER_NIC_PF · 6 unmodified lines | ||
| 29 | 28 | config THUNDER_NIC_VF |
| 30 | 29 | tristate "Thunder Virtual function driver" |
| 31 | 30 | depends on 64BIT |
| 32 | − default ARCH_THUNDER | |
| 33 | 31 | ---help--- |
| 34 | 32 | This driver supports Thunder's NIC virtual function |
| 35 | 33 | |
| 36 | 34 | config THUNDER_NIC_BGX |
| 37 | 35 | tristate "Thunder MAC interface driver (BGX)" |
| 38 | 36 | depends on 64BIT |
| 39 | − default ARCH_THUNDER | |
| 40 | 37 | select PHYLIB |
| 41 | 38 | select MDIO_OCTEON |
| 42 | 39 | ---help--- |
| @@ -2778,10 +2778,11 @@ int t4_setup_debugfs(struct adapter *adap) · 2777 unmodified lines | ||
| 2778 | 2778 | EXT_MEM1_SIZE_G(size)); |
| 2779 | 2779 | } |
| 2780 | 2780 | } else { |
| 2781 | − if (i & EXT_MEM_ENABLE_F) | |
| 2781 | + if (i & EXT_MEM_ENABLE_F) { | |
| 2782 | 2782 | size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A); |
| 2783 | 2783 | add_debugfs_mem(adap, "mc", MEM_MC, |
| 2784 | 2784 | EXT_MEM_SIZE_G(size)); |
| 2785 | + } | |
| 2785 | 2786 | } |
| 2786 | 2787 | |
| 2787 | 2788 | de = debugfs_create_file_size("flash", S_IRUSR, adap->debugfs_root, adap, |
| @@ -620,6 +620,11 @@ enum be_if_flags { · 619 unmodified lines | ||
| 620 | 620 | BE_IF_FLAGS_VLAN_PROMISCUOUS |\ |
| 621 | 621 | BE_IF_FLAGS_MCAST_PROMISCUOUS) |
| 622 | 622 | |
| 623 | +#define BE_IF_EN_FLAGS (BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |\ | |
| 624 | + BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_UNTAGGED) | |
| 625 | + | |
| 626 | +#define BE_IF_ALL_FILT_FLAGS (BE_IF_EN_FLAGS | BE_IF_FLAGS_ALL_PROMISCUOUS) | |
| 627 | + | |
| 623 | 628 | /* An RX interface is an object with one or more MAC addresses and |
| 624 | 629 | * filtering capabilities. */ |
| 625 | 630 | struct be_cmd_req_if_create { |
| @@ -273,6 +273,10 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) · 272 unmodified lines | ||
| 273 | 273 | if (ether_addr_equal(addr->sa_data, netdev->dev_addr)) |
| 274 | 274 | return 0; |
| 275 | 275 | |
| 276 | + /* if device is not running, copy MAC to netdev->dev_addr */ | |
| 277 | + if (!netif_running(netdev)) | |
| 278 | + goto done; | |
| 279 | + | |
| 276 | 280 | /* The PMAC_ADD cmd may fail if the VF doesn't have FILTMGMT |
| 277 | 281 | * privilege or if PF did not provision the new MAC address. |
| 278 | 282 | * On BE3, this cmd will always fail if the VF doesn't have the |
| @@ -307,9 +311,9 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) · 28 unmodified lines | ||
| 307 | 311 | status = -EPERM; |
| 308 | 312 | goto err; |
| 309 | 313 | } |
| 310 | − | |
| 311 | − memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | |
| 312 | − dev_info(dev, "MAC address changed to %pM\n", mac); | |
| 314 | +done: | |
| 315 | + ether_addr_copy(netdev->dev_addr, addr->sa_data); | |
| 316 | + dev_info(dev, "MAC address changed to %pM\n", addr->sa_data); | |
| 313 | 317 | return 0; |
| 314 | 318 | err: |
| 315 | 319 | dev_warn(dev, "MAC address change to %pM failed\n", addr->sa_data); |
| @@ -2452,10 +2456,24 @@ static void be_eq_clean(struct be_eq_obj *eqo) · 2136 unmodified lines | ||
| 2452 | 2456 | be_eq_notify(eqo->adapter, eqo->q.id, false, true, num, 0); |
| 2453 | 2457 | } |
| 2454 | 2458 | |
| 2455 | −static void be_rx_cq_clean(struct be_rx_obj *rxo) | |
| 2459 | +/* Free posted rx buffers that were not used */ | |
| 2460 | +static void be_rxq_clean(struct be_rx_obj *rxo) | |
| 2456 | 2461 | { |
| 2457 | − struct be_rx_page_info *page_info; | |
| 2458 | 2462 | struct be_queue_info *rxq = &rxo->q; |
| 2463 | + struct be_rx_page_info *page_info; | |
| 2464 | + | |
| 2465 | + while (atomic_read(&rxq->used) > 0) { | |
| 2466 | + page_info = get_rx_page_info(rxo); | |
| 2467 | + put_page(page_info->page); | |
| 2468 | + memset(page_info, 0, sizeof(*page_info)); | |
| 2469 | + } | |
| 2470 | + BUG_ON(atomic_read(&rxq->used)); | |
| 2471 | + rxq->tail = 0; | |
| 2472 | + rxq->head = 0; | |
| 2473 | +} | |
| 2474 | + | |
| 2475 | +static void be_rx_cq_clean(struct be_rx_obj *rxo) | |
| 2476 | +{ | |
| 2459 | 2477 | struct be_queue_info *rx_cq = &rxo->cq; |
| 2460 | 2478 | struct be_rx_compl_info *rxcp; |
| 2461 | 2479 | struct be_adapter *adapter = rxo->adapter; |
| @@ -2492,16 +2510,6 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo) · 30 unmodified lines | ||
| 2492 | 2510 | |
| 2493 | 2511 | /* After cleanup, leave the CQ in unarmed state */ |
| 2494 | 2512 | be_cq_notify(adapter, rx_cq->id, false, 0); |
| 2495 | − | |
| 2496 | − /* Then free posted rx buffers that were not used */ | |
| 2497 | − while (atomic_read(&rxq->used) > 0) { | |
| 2498 | − page_info = get_rx_page_info(rxo); | |
| 2499 | − put_page(page_info->page); | |
| 2500 | − memset(page_info, 0, sizeof(*page_info)); | |
| 2501 | − } | |
| 2502 | − BUG_ON(atomic_read(&rxq->used)); | |
| 2503 | − rxq->tail = 0; | |
| 2504 | − rxq->head = 0; | |
| 2505 | 2513 | } |
| 2506 | 2514 | |
| 2507 | 2515 | static void be_tx_compl_clean(struct be_adapter *adapter) |
| @@ -2581,8 +2589,8 @@ static void be_evt_queues_destroy(struct be_adapter *adapter) · 73 unmodified lines | ||
| 2581 | 2589 | be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); |
| 2582 | 2590 | napi_hash_del(&eqo->napi); |
| 2583 | 2591 | netif_napi_del(&eqo->napi); |
| 2592 | + free_cpumask_var(eqo->affinity_mask); | |
| 2584 | 2593 | } |
| 2585 | − free_cpumask_var(eqo->affinity_mask); | |
| 2586 | 2594 | be_queue_free(adapter, &eqo->q); |
| 2587 | 2595 | } |
| 2588 | 2596 | } |
| @@ -2599,13 +2607,7 @@ static int be_evt_queues_create(struct be_adapter *adapter) · 10 unmodified lines | ||
| 2599 | 2607 | |
| 2600 | 2608 | for_all_evt_queues(adapter, eqo, i) { |
| 2601 | 2609 | int numa_node = dev_to_node(&adapter->pdev->dev); |
| 2602 | − if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL)) | |
| 2603 | − return -ENOMEM; | |
| 2604 | − cpumask_set_cpu(cpumask_local_spread(i, numa_node), | |
| 2605 | − eqo->affinity_mask); | |
| 2606 | − netif_napi_add(adapter->netdev, &eqo->napi, be_poll, | |
| 2607 | − BE_NAPI_WEIGHT); | |
| 2608 | − napi_hash_add(&eqo->napi); | |
| 2610 | + | |
| 2609 | 2611 | aic = &adapter->aic_obj[i]; |
| 2610 | 2612 | eqo->adapter = adapter; |
| 2611 | 2613 | eqo->idx = i; |
| @@ -2621,6 +2623,14 @@ static int be_evt_queues_create(struct be_adapter *adapter) · 9 unmodified lines | ||
| 2621 | 2623 | rc = be_cmd_eq_create(adapter, eqo); |
| 2622 | 2624 | if (rc) |
| 2623 | 2625 | return rc; |
| 2626 | + | |
| 2627 | + if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL)) | |
| 2628 | + return -ENOMEM; | |
| 2629 | + cpumask_set_cpu(cpumask_local_spread(i, numa_node), | |
| 2630 | + eqo->affinity_mask); | |
| 2631 | + netif_napi_add(adapter->netdev, &eqo->napi, be_poll, | |
| 2632 | + BE_NAPI_WEIGHT); | |
| 2633 | + napi_hash_add(&eqo->napi); | |
| 2624 | 2634 | } |
| 2625 | 2635 | return 0; |
| 2626 | 2636 | } |
| @@ -3359,13 +3369,54 @@ static void be_rx_qs_destroy(struct be_adapter *adapter) · 732 unmodified lines | ||
| 3359 | 3369 | for_all_rx_queues(adapter, rxo, i) { |
| 3360 | 3370 | q = &rxo->q; |
| 3361 | 3371 | if (q->created) { |
| 3372 | + /* If RXQs are destroyed while in an "out of buffer" | |
| 3373 | + * state, there is a possibility of an HW stall on | |
| 3374 | + * Lancer. So, post 64 buffers to each queue to relieve | |
| 3375 | + * the "out of buffer" condition. | |
| 3376 | + * Make sure there's space in the RXQ before posting. | |
| 3377 | + */ | |
| 3378 | + if (lancer_chip(adapter)) { | |
| 3379 | + be_rx_cq_clean(rxo); | |
| 3380 | + if (atomic_read(&q->used) == 0) | |
| 3381 | + be_post_rx_frags(rxo, GFP_KERNEL, | |
| 3382 | + MAX_RX_POST); | |
| 3383 | + } | |
| 3384 | + | |
| 3362 | 3385 | be_cmd_rxq_destroy(adapter, q); |
| 3363 | 3386 | be_rx_cq_clean(rxo); |
| 3387 | + be_rxq_clean(rxo); | |
| 3364 | 3388 | } |
| 3365 | 3389 | be_queue_free(adapter, q); |
| 3366 | 3390 | } |
| 3367 | 3391 | } |
| 3368 | 3392 | |
| 3393 | +static void be_disable_if_filters(struct be_adapter *adapter) | |
| 3394 | +{ | |
| 3395 | + be_cmd_pmac_del(adapter, adapter->if_handle, | |
| 3396 | + adapter->pmac_id[0], 0); | |
| 3397 | + | |
| 3398 | + be_clear_uc_list(adapter); | |
| 3399 | + | |
| 3400 | + /* The IFACE flags are enabled in the open path and cleared | |
| 3401 | + * in the close path. When a VF gets detached from the host and | |
| 3402 | + * assigned to a VM the following happens: | |
| 3403 | + * - VF's IFACE flags get cleared in the detach path | |
| 3404 | + * - IFACE create is issued by the VF in the attach path | |
| 3405 | + * Due to a bug in the BE3/Skyhawk-R FW | |
| 3406 | + * (Lancer FW doesn't have the bug), the IFACE capability flags | |
| 3407 | + * specified along with the IFACE create cmd issued by a VF are not | |
| 3408 | + * honoured by FW. As a consequence, if a *new* driver | |
| 3409 | + * (that enables/disables IFACE flags in open/close) | |
| 3410 | + * is loaded in the host and an *old* driver is * used by a VM/VF, | |
| 3411 | + * the IFACE gets created *without* the needed flags. | |
| 3412 | + * To avoid this, disable RX-filter flags only for Lancer. | |
| 3413 | + */ | |
| 3414 | + if (lancer_chip(adapter)) { | |
| 3415 | + be_cmd_rx_filter(adapter, BE_IF_ALL_FILT_FLAGS, OFF); | |
| 3416 | + adapter->if_flags &= ~BE_IF_ALL_FILT_FLAGS; | |
| 3417 | + } | |
| 3418 | +} | |
| 3419 | + | |
| 3369 | 3420 | static int be_close(struct net_device *netdev) |
| 3370 | 3421 | { |
| 3371 | 3422 | struct be_adapter *adapter = netdev_priv(netdev); |
| @@ -3378,6 +3429,8 @@ static int be_close(struct net_device *netdev) · 6 unmodified lines | ||
| 3378 | 3429 | if (!(adapter->flags & BE_FLAGS_SETUP_DONE)) |
| 3379 | 3430 | return 0; |
| 3380 | 3431 | |
| 3432 | + be_disable_if_filters(adapter); | |
| 3433 | + | |
| 3381 | 3434 | be_roce_dev_close(adapter); |
| 3382 | 3435 | |
| 3383 | 3436 | if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { |
| @@ -3397,7 +3450,6 @@ static int be_close(struct net_device *netdev) · 13 unmodified lines | ||
| 3397 | 3450 | be_tx_compl_clean(adapter); |
| 3398 | 3451 | |
| 3399 | 3452 | be_rx_qs_destroy(adapter); |
| 3400 | − be_clear_uc_list(adapter); | |
| 3401 | 3453 | |
| 3402 | 3454 | for_all_evt_queues(adapter, eqo, i) { |
| 3403 | 3455 | if (msix_enabled(adapter)) |
| @@ -3482,6 +3534,31 @@ static int be_rx_qs_create(struct be_adapter *adapter) · 78 unmodified lines | ||
| 3482 | 3534 | return 0; |
| 3483 | 3535 | } |
| 3484 | 3536 | |
| 3537 | +static int be_enable_if_filters(struct be_adapter *adapter) | |
| 3538 | +{ | |
| 3539 | + int status; | |
| 3540 | + | |
| 3541 | + status = be_cmd_rx_filter(adapter, BE_IF_EN_FLAGS, ON); | |
| 3542 | + if (status) | |
| 3543 | + return status; | |
| 3544 | + | |
| 3545 | + /* For BE3 VFs, the PF programs the initial MAC address */ | |
| 3546 | + if (!(BEx_chip(adapter) && be_virtfn(adapter))) { | |
| 3547 | + status = be_cmd_pmac_add(adapter, adapter->netdev->dev_addr, | |
| 3548 | + adapter->if_handle, | |
| 3549 | + &adapter->pmac_id[0], 0); | |
| 3550 | + if (status) | |
| 3551 | + return status; | |
| 3552 | + } | |
| 3553 | + | |
| 3554 | + if (adapter->vlans_added) | |
| 3555 | + be_vid_config(adapter); | |
| 3556 | + | |
| 3557 | + be_set_rx_mode(adapter->netdev); | |
| 3558 | + | |
| 3559 | + return 0; | |
| 3560 | +} | |
| 3561 | + | |
| 3485 | 3562 | static int be_open(struct net_device *netdev) |
| 3486 | 3563 | { |
| 3487 | 3564 | struct be_adapter *adapter = netdev_priv(netdev); |
| @@ -3495,6 +3572,10 @@ static int be_open(struct net_device *netdev) · 7 unmodified lines | ||
| 3495 | 3572 | if (status) |
| 3496 | 3573 | goto err; |
| 3497 | 3574 | |
| 3575 | + status = be_enable_if_filters(adapter); | |
| 3576 | + if (status) | |
| 3577 | + goto err; | |
| 3578 | + | |
| 3498 | 3579 | status = be_irq_register(adapter); |
| 3499 | 3580 | if (status) |
| 3500 | 3581 | goto err; |
| @@ -3685,16 +3766,6 @@ static void be_cancel_err_detection(struct be_adapter *adapter) · 184 unmodified lines | ||
| 3685 | 3766 | } |
| 3686 | 3767 | } |
| 3687 | 3768 | |
| 3688 | −static void be_mac_clear(struct be_adapter *adapter) | |
| 3689 | −{ | |
| 3690 | − if (adapter->pmac_id) { | |
| 3691 | − be_cmd_pmac_del(adapter, adapter->if_handle, | |
| 3692 | − adapter->pmac_id[0], 0); | |
| 3693 | − kfree(adapter->pmac_id); | |
| 3694 | − adapter->pmac_id = NULL; | |
| 3695 | − } | |
| 3696 | −} | |
| 3697 | − | |
| 3698 | 3769 | #ifdef CONFIG_BE2NET_VXLAN |
| 3699 | 3770 | static void be_disable_vxlan_offloads(struct be_adapter *adapter) |
| 3700 | 3771 | { |
| @@ -3769,8 +3840,8 @@ static int be_clear(struct be_adapter *adapter) · 68 unmodified lines | ||
| 3769 | 3840 | #ifdef CONFIG_BE2NET_VXLAN |
| 3770 | 3841 | be_disable_vxlan_offloads(adapter); |
| 3771 | 3842 | #endif |
| 3772 | − /* delete the primary mac along with the uc-mac list */ | |
| 3773 | − be_mac_clear(adapter); | |
| 3843 | + kfree(adapter->pmac_id); | |
| 3844 | + adapter->pmac_id = NULL; | |
| 3774 | 3845 | |
| 3775 | 3846 | be_cmd_if_destroy(adapter, adapter->if_handle, 0); |
| 3776 | 3847 | |
| @@ -3781,25 +3852,11 @@ static int be_clear(struct be_adapter *adapter) · 4 unmodified lines | ||
| 3781 | 3852 | return 0; |
| 3782 | 3853 | } |
| 3783 | 3854 | |
| 3784 | −static int be_if_create(struct be_adapter *adapter, u32 *if_handle, | |
| 3785 | − u32 cap_flags, u32 vf) | |
| 3786 | −{ | |
| 3787 | − u32 en_flags; | |
| 3788 | − | |
| 3789 | − en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | | |
| 3790 | − BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS | | |
| 3791 | − BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS; | |
| 3792 | − | |
| 3793 | − en_flags &= cap_flags; | |
| 3794 | − | |
| 3795 | − return be_cmd_if_create(adapter, cap_flags, en_flags, if_handle, vf); | |
| 3796 | −} | |
| 3797 | − | |
| 3798 | 3855 | static int be_vfs_if_create(struct be_adapter *adapter) |
| 3799 | 3856 | { |
| 3800 | 3857 | struct be_resources res = {0}; |
| 3858 | + u32 cap_flags, en_flags, vf; | |
| 3801 | 3859 | struct be_vf_cfg *vf_cfg; |
| 3802 | − u32 cap_flags, vf; | |
| 3803 | 3860 | int status; |
| 3804 | 3861 | |
| 3805 | 3862 | /* If a FW profile exists, then cap_flags are updated */ |
| @@ -3820,8 +3877,12 @@ static int be_vfs_if_create(struct be_adapter *adapter) · 14 unmodified lines | ||
| 3820 | 3877 | } |
| 3821 | 3878 | } |
| 3822 | 3879 | |
| 3823 | − status = be_if_create(adapter, &vf_cfg->if_handle, | |
| 3824 | − cap_flags, vf + 1); | |
| 3880 | + en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED | | |
| 3881 | + BE_IF_FLAGS_BROADCAST | | |
| 3882 | + BE_IF_FLAGS_MULTICAST | | |
| 3883 | + BE_IF_FLAGS_PASS_L3L4_ERRORS); | |
| 3884 | + status = be_cmd_if_create(adapter, cap_flags, en_flags, | |
| 3885 | + &vf_cfg->if_handle, vf + 1); | |
| 3825 | 3886 | if (status) |
| 3826 | 3887 | return status; |
| 3827 | 3888 | } |
| @@ -4193,15 +4254,8 @@ static int be_mac_setup(struct be_adapter *adapter) · 365 unmodified lines | ||
| 4193 | 4254 | |
| 4194 | 4255 | memcpy(adapter->netdev->dev_addr, mac, ETH_ALEN); |
| 4195 | 4256 | memcpy(adapter->netdev->perm_addr, mac, ETH_ALEN); |
| 4196 | − } else { | |
| 4197 | − /* Maybe the HW was reset; dev_addr must be re-programmed */ | |
| 4198 | − memcpy(mac, adapter->netdev->dev_addr, ETH_ALEN); | |
| 4199 | 4257 | } |
| 4200 | 4258 | |
| 4201 | − /* For BE3-R VFs, the PF programs the initial MAC address */ | |
| 4202 | − if (!(BEx_chip(adapter) && be_virtfn(adapter))) | |
| 4203 | − be_cmd_pmac_add(adapter, mac, adapter->if_handle, | |
| 4204 | − &adapter->pmac_id[0], 0); | |
| 4205 | 4259 | return 0; |
| 4206 | 4260 | } |
| 4207 | 4261 | |
| @@ -4341,6 +4395,7 @@ static int be_func_init(struct be_adapter *adapter) · 133 unmodified lines | ||
| 4341 | 4395 | static int be_setup(struct be_adapter *adapter) |
| 4342 | 4396 | { |
| 4343 | 4397 | struct device *dev = &adapter->pdev->dev; |
| 4398 | + u32 en_flags; | |
| 4344 | 4399 | int status; |
| 4345 | 4400 | |
| 4346 | 4401 | status = be_func_init(adapter); |
| @@ -4363,8 +4418,11 @@ static int be_setup(struct be_adapter *adapter) · 16 unmodified lines | ||
| 4363 | 4418 | if (status) |
| 4364 | 4419 | goto err; |
| 4365 | 4420 | |
| 4366 | − status = be_if_create(adapter, &adapter->if_handle, | |
| 4367 | − be_if_cap_flags(adapter), 0); | |
| 4421 | + /* will enable all the needed filter flags in be_open() */ | |
| 4422 | + en_flags = BE_IF_FLAGS_RSS | BE_IF_FLAGS_DEFQ_RSS; | |
| 4423 | + en_flags = en_flags & be_if_cap_flags(adapter); | |
| 4424 | + status = be_cmd_if_create(adapter, be_if_cap_flags(adapter), en_flags, | |
| 4425 | + &adapter->if_handle, 0); | |
| 4368 | 4426 | if (status) |
| 4369 | 4427 | goto err; |
| 4370 | 4428 | |
| @@ -4390,11 +4448,6 @@ static int be_setup(struct be_adapter *adapter) · 19 unmodified lines | ||
| 4390 | 4448 | dev_err(dev, "Please upgrade firmware to version >= 4.0\n"); |
| 4391 | 4449 | } |
| 4392 | 4450 | |
| 4393 | − if (adapter->vlans_added) | |
| 4394 | − be_vid_config(adapter); | |
| 4395 | − | |
| 4396 | − be_set_rx_mode(adapter->netdev); | |
| 4397 | − | |
| 4398 | 4451 | status = be_cmd_set_flow_control(adapter, adapter->tx_fc, |
| 4399 | 4452 | adapter->rx_fc); |
| 4400 | 4453 | if (status) |
| @@ -3438,6 +3438,7 @@ fec_probe(struct platform_device *pdev) · 3437 unmodified lines | ||
| 3438 | 3438 | |
| 3439 | 3439 | pm_runtime_set_autosuspend_delay(&pdev->dev, FEC_MDIO_PM_TIMEOUT); |
| 3440 | 3440 | pm_runtime_use_autosuspend(&pdev->dev); |
| 3441 | + pm_runtime_get_noresume(&pdev->dev); | |
| 3441 | 3442 | pm_runtime_set_active(&pdev->dev); |
| 3442 | 3443 | pm_runtime_enable(&pdev->dev); |
| 3443 | 3444 | |
| @@ -586,7 +586,8 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) · 585 unmodified lines | ||
| 586 | 586 | frag = skb_shinfo(skb)->frags; |
| 587 | 587 | while (nr_frags) { |
| 588 | 588 | CBDC_SC(bdp, |
| 589 | − BD_ENET_TX_STATS | BD_ENET_TX_LAST | BD_ENET_TX_TC); | |
| 589 | + BD_ENET_TX_STATS | BD_ENET_TX_INTR | BD_ENET_TX_LAST | | |
| 590 | + BD_ENET_TX_TC); | |
| 590 | 591 | CBDS_SC(bdp, BD_ENET_TX_READY); |
| 591 | 592 | |
| 592 | 593 | if ((CBDR_SC(bdp) & BD_ENET_TX_WRAP) == 0) |
| @@ -110,7 +110,7 @@ static int do_pd_setup(struct fs_enet_private *fep) · 109 unmodified lines | ||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | #define FEC_NAPI_RX_EVENT_MSK (FEC_ENET_RXF | FEC_ENET_RXB) |
| 113 | −#define FEC_NAPI_TX_EVENT_MSK (FEC_ENET_TXF | FEC_ENET_TXB) | |
| 113 | +#define FEC_NAPI_TX_EVENT_MSK (FEC_ENET_TXF) | |
| 114 | 114 | #define FEC_RX_EVENT (FEC_ENET_RXF) |
| 115 | 115 | #define FEC_TX_EVENT (FEC_ENET_TXF) |
| 116 | 116 | #define FEC_ERR_EVENT_MSK (FEC_ENET_HBERR | FEC_ENET_BABR | \ |
| @@ -902,27 +902,6 @@ static int gfar_check_filer_hardware(struct gfar_private *priv) · 901 unmodified lines | ||
| 902 | 902 | return 0; |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | −static int gfar_comp_asc(const void *a, const void *b) | |
| 906 | −{ | |
| 907 | − return memcmp(a, b, 4); | |
| 908 | −} | |
| 909 | − | |
| 910 | −static int gfar_comp_desc(const void *a, const void *b) | |
| 911 | −{ | |
| 912 | − return -memcmp(a, b, 4); | |
| 913 | −} | |
| 914 | − | |
| 915 | −static void gfar_swap(void *a, void *b, int size) | |
| 916 | −{ | |
| 917 | − u32 *_a = a; | |
| 918 | − u32 *_b = b; | |
| 919 | − | |
| 920 | − swap(_a[0], _b[0]); | |
| 921 | − swap(_a[1], _b[1]); | |
| 922 | − swap(_a[2], _b[2]); | |
| 923 | − swap(_a[3], _b[3]); | |
| 924 | −} | |
| 925 | − | |
| 926 | 905 | /* Write a mask to filer cache */ |
| 927 | 906 | static void gfar_set_mask(u32 mask, struct filer_table *tab) |
| 928 | 907 | { |
| @@ -1272,310 +1251,6 @@ static int gfar_convert_to_filer(struct ethtool_rx_flow_spec *rule, · 343 unmodified lines | ||
| 1272 | 1251 | return 0; |
| 1273 | 1252 | } |
| 1274 | 1253 | |
| 1275 | −/* Copy size filer entries */ | |
| 1276 | −static void gfar_copy_filer_entries(struct gfar_filer_entry dst[0], | |
| 1277 | − struct gfar_filer_entry src[0], s32 size) | |
| 1278 | −{ | |
| 1279 | − while (size > 0) { | |
| 1280 | − size--; | |
| 1281 | − dst[size].ctrl = src[size].ctrl; | |
| 1282 | − dst[size].prop = src[size].prop; | |
| 1283 | − } | |
| 1284 | −} | |
| 1285 | − | |
| 1286 | −/* Delete the contents of the filer-table between start and end | |
| 1287 | − * and collapse them | |
| 1288 | − */ | |
| 1289 | −static int gfar_trim_filer_entries(u32 begin, u32 end, struct filer_table *tab) | |
| 1290 | −{ | |
| 1291 | − int length; | |
| 1292 | − | |
| 1293 | − if (end > MAX_FILER_CACHE_IDX || end < begin) | |
| 1294 | − return -EINVAL; | |
| 1295 | − | |
| 1296 | − end++; | |
| 1297 | − length = end - begin; | |
| 1298 | − | |
| 1299 | − /* Copy */ | |
| 1300 | − while (end < tab->index) { | |
| 1301 | − tab->fe[begin].ctrl = tab->fe[end].ctrl; | |
| 1302 | − tab->fe[begin++].prop = tab->fe[end++].prop; | |
| 1303 | − | |
| 1304 | − } | |
| 1305 | − /* Fill up with don't cares */ | |
| 1306 | − while (begin < tab->index) { | |
| 1307 | − tab->fe[begin].ctrl = 0x60; | |
| 1308 | − tab->fe[begin].prop = 0xFFFFFFFF; | |
| 1309 | − begin++; | |
| 1310 | − } | |
| 1311 | − | |
| 1312 | − tab->index -= length; | |
| 1313 | − return 0; | |
| 1314 | −} | |
| 1315 | − | |
| 1316 | −/* Make space on the wanted location */ | |
| 1317 | −static int gfar_expand_filer_entries(u32 begin, u32 length, | |
| 1318 | − struct filer_table *tab) | |
| 1319 | −{ | |
| 1320 | − if (length == 0 || length + tab->index > MAX_FILER_CACHE_IDX || | |
| 1321 | − begin > MAX_FILER_CACHE_IDX) | |
| 1322 | − return -EINVAL; | |
| 1323 | − | |
| 1324 | − gfar_copy_filer_entries(&(tab->fe[begin + length]), &(tab->fe[begin]), | |
| 1325 | − tab->index - length + 1); | |
| 1326 | − | |
| 1327 | − tab->index += length; | |
| 1328 | − return 0; | |
| 1329 | −} | |
| 1330 | − | |
| 1331 | −static int gfar_get_next_cluster_start(int start, struct filer_table *tab) | |
| 1332 | −{ | |
| 1333 | − for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1); | |
| 1334 | − start++) { | |
| 1335 | − if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE)) == | |
| 1336 | − (RQFCR_AND | RQFCR_CLE)) | |
| 1337 | − return start; | |
| 1338 | − } | |
| 1339 | − return -1; | |
| 1340 | −} | |
| 1341 | − | |
| 1342 | −static int gfar_get_next_cluster_end(int start, struct filer_table *tab) | |
| 1343 | −{ | |
| 1344 | − for (; (start < tab->index) && (start < MAX_FILER_CACHE_IDX - 1); | |
| 1345 | − start++) { | |
| 1346 | − if ((tab->fe[start].ctrl & (RQFCR_AND | RQFCR_CLE)) == | |
| 1347 | − (RQFCR_CLE)) | |
| 1348 | − return start; | |
| 1349 | − } | |
| 1350 | − return -1; | |
| 1351 | −} | |
| 1352 | − | |
| 1353 | −/* Uses hardwares clustering option to reduce | |
| 1354 | − * the number of filer table entries | |
| 1355 | − */ | |
| 1356 | −static void gfar_cluster_filer(struct filer_table *tab) | |
| 1357 | −{ | |
| 1358 | − s32 i = -1, j, iend, jend; | |
| 1359 | − | |
| 1360 | − while ((i = gfar_get_next_cluster_start(++i, tab)) != -1) { | |
| 1361 | − j = i; | |
| 1362 | − while ((j = gfar_get_next_cluster_start(++j, tab)) != -1) { | |
| 1363 | − /* The cluster entries self and the previous one | |
| 1364 | − * (a mask) must be identical! | |
| 1365 | − */ | |
| 1366 | − if (tab->fe[i].ctrl != tab->fe[j].ctrl) | |
| 1367 | − break; | |
| 1368 | − if (tab->fe[i].prop != tab->fe[j].prop) | |
| 1369 | − break; | |
| 1370 | − if (tab->fe[i - 1].ctrl != tab->fe[j - 1].ctrl) | |
| 1371 | − break; | |
| 1372 | − if (tab->fe[i - 1].prop != tab->fe[j - 1].prop) | |
| 1373 | − break; | |
| 1374 | − iend = gfar_get_next_cluster_end(i, tab); | |
| 1375 | − jend = gfar_get_next_cluster_end(j, tab); | |
| 1376 | − if (jend == -1 || iend == -1) | |
| 1377 | − break; | |
| 1378 | − | |
| 1379 | − /* First we make some free space, where our cluster | |
| 1380 | − * element should be. Then we copy it there and finally | |
| 1381 | − * delete in from its old location. | |
| 1382 | − */ | |
| 1383 | − if (gfar_expand_filer_entries(iend, (jend - j), tab) == | |
| 1384 | − -EINVAL) | |
| 1385 | − break; | |
| 1386 | − | |
| 1387 | − gfar_copy_filer_entries(&(tab->fe[iend + 1]), | |
| 1388 | − &(tab->fe[jend + 1]), jend - j); | |
| 1389 | − | |
| 1390 | − if (gfar_trim_filer_entries(jend - 1, | |
| 1391 | − jend + (jend - j), | |
| 1392 | − tab) == -EINVAL) | |
| 1393 | − return; | |
| 1394 | − | |
| 1395 | − /* Mask out cluster bit */ | |
| 1396 | − tab->fe[iend].ctrl &= ~(RQFCR_CLE); | |
| 1397 | − } | |
| 1398 | − } | |
| 1399 | −} | |
| 1400 | − | |
| 1401 | −/* Swaps the masked bits of a1<>a2 and b1<>b2 */ | |
| 1402 | −static void gfar_swap_bits(struct gfar_filer_entry *a1, | |
| 1403 | − struct gfar_filer_entry *a2, | |
| 1404 | − struct gfar_filer_entry *b1, | |
| 1405 | − struct gfar_filer_entry *b2, u32 mask) | |
| 1406 | −{ | |
| 1407 | − u32 temp[4]; | |
| 1408 | − temp[0] = a1->ctrl & mask; | |
| 1409 | − temp[1] = a2->ctrl & mask; | |
| 1410 | − temp[2] = b1->ctrl & mask; | |
| 1411 | − temp[3] = b2->ctrl & mask; | |
| 1412 | − | |
| 1413 | − a1->ctrl &= ~mask; | |
| 1414 | − a2->ctrl &= ~mask; | |
| 1415 | − b1->ctrl &= ~mask; | |
| 1416 | − b2->ctrl &= ~mask; | |
| 1417 | − | |
| 1418 | − a1->ctrl |= temp[1]; | |
| 1419 | − a2->ctrl |= temp[0]; | |
| 1420 | − b1->ctrl |= temp[3]; | |
| 1421 | − b2->ctrl |= temp[2]; | |
| 1422 | −} | |
| 1423 | − | |
| 1424 | −/* Generate a list consisting of masks values with their start and | |
| 1425 | − * end of validity and block as indicator for parts belonging | |
| 1426 | − * together (glued by ANDs) in mask_table | |
| 1427 | − */ | |
| 1428 | −static u32 gfar_generate_mask_table(struct gfar_mask_entry *mask_table, | |
| 1429 | − struct filer_table *tab) | |
| 1430 | −{ | |
| 1431 | − u32 i, and_index = 0, block_index = 1; | |
| 1432 | − | |
| 1433 | − for (i = 0; i < tab->index; i++) { | |
| 1434 | − | |
| 1435 | − /* LSByte of control = 0 sets a mask */ | |
| 1436 | − if (!(tab->fe[i].ctrl & 0xF)) { | |
| 1437 | − mask_table[and_index].mask = tab->fe[i].prop; | |
| 1438 | − mask_table[and_index].start = i; | |
| 1439 | − mask_table[and_index].block = block_index; | |
| 1440 | − if (and_index >= 1) | |
| 1441 | − mask_table[and_index - 1].end = i - 1; | |
| 1442 | − and_index++; | |
| 1443 | − } | |
| 1444 | − /* cluster starts and ends will be separated because they should | |
| 1445 | − * hold their position | |
| 1446 | − */ | |
| 1447 | − if (tab->fe[i].ctrl & RQFCR_CLE) | |
| 1448 | − block_index++; | |
| 1449 | − /* A not set AND indicates the end of a depended block */ | |
| 1450 | − if (!(tab->fe[i].ctrl & RQFCR_AND)) | |
| 1451 | − block_index++; | |
| 1452 | − } | |
| 1453 | − | |
| 1454 | − mask_table[and_index - 1].end = i - 1; | |
| 1455 | − | |
| 1456 | − return and_index; | |
| 1457 | −} | |
| 1458 | − | |
| 1459 | −/* Sorts the entries of mask_table by the values of the masks. | |
| 1460 | − * Important: The 0xFF80 flags of the first and last entry of a | |
| 1461 | − * block must hold their position (which queue, CLusterEnable, ReJEct, | |
| 1462 | − * AND) | |
| 1463 | − */ | |
| 1464 | −static void gfar_sort_mask_table(struct gfar_mask_entry *mask_table, | |
| 1465 | − struct filer_table *temp_table, u32 and_index) | |
| 1466 | −{ | |
| 1467 | − /* Pointer to compare function (_asc or _desc) */ | |
| 1468 | − int (*gfar_comp)(const void *, const void *); | |
| 1469 | − | |
| 1470 | − u32 i, size = 0, start = 0, prev = 1; | |
| 1471 | − u32 old_first, old_last, new_first, new_last; | |
| 1472 | − | |
| 1473 | − gfar_comp = &gfar_comp_desc; | |
| 1474 | − | |
| 1475 | − for (i = 0; i < and_index; i++) { | |
| 1476 | − if (prev != mask_table[i].block) { | |
| 1477 | − old_first = mask_table[start].start + 1; | |
| 1478 | − old_last = mask_table[i - 1].end; | |
| 1479 | − sort(mask_table + start, size, | |
| 1480 | − sizeof(struct gfar_mask_entry), | |
| 1481 | − gfar_comp, &gfar_swap); | |
| 1482 | − | |
| 1483 | − /* Toggle order for every block. This makes the | |
| 1484 | − * thing more efficient! | |
| 1485 | − */ | |
| 1486 | − if (gfar_comp == gfar_comp_desc) | |
| 1487 | − gfar_comp = &gfar_comp_asc; | |
| 1488 | − else | |
| 1489 | − gfar_comp = &gfar_comp_desc; | |
| 1490 | − | |
| 1491 | − new_first = mask_table[start].start + 1; | |
| 1492 | − new_last = mask_table[i - 1].end; | |
| 1493 | − | |
| 1494 | − gfar_swap_bits(&temp_table->fe[new_first], | |
| 1495 | − &temp_table->fe[old_first], | |
| 1496 | − &temp_table->fe[new_last], | |
| 1497 | − &temp_table->fe[old_last], | |
| 1498 | − RQFCR_QUEUE | RQFCR_CLE | | |
| 1499 | − RQFCR_RJE | RQFCR_AND); | |
| 1500 | − | |
| 1501 | − start = i; | |
| 1502 | − size = 0; | |
| 1503 | − } | |
| 1504 | − size++; | |
| 1505 | − prev = mask_table[i].block; | |
| 1506 | − } | |
| 1507 | −} | |
| 1508 | − | |
| 1509 | −/* Reduces the number of masks needed in the filer table to save entries | |
| 1510 | − * This is done by sorting the masks of a depended block. A depended block is | |
| 1511 | − * identified by gluing ANDs or CLE. The sorting order toggles after every | |
| 1512 | − * block. Of course entries in scope of a mask must change their location with | |
| 1513 | − * it. | |
| 1514 | − */ | |
| 1515 | −static int gfar_optimize_filer_masks(struct filer_table *tab) | |
| 1516 | −{ | |
| 1517 | − struct filer_table *temp_table; | |
| 1518 | − struct gfar_mask_entry *mask_table; | |
| 1519 | − | |
| 1520 | − u32 and_index = 0, previous_mask = 0, i = 0, j = 0, size = 0; | |
| 1521 | − s32 ret = 0; | |
| 1522 | − | |
| 1523 | − /* We need a copy of the filer table because | |
| 1524 | − * we want to change its order | |
| 1525 | − */ | |
| 1526 | − temp_table = kmemdup(tab, sizeof(*temp_table), GFP_KERNEL); | |
| 1527 | − if (temp_table == NULL) | |
| 1528 | − return -ENOMEM; | |
| 1529 | − | |
| 1530 | − mask_table = kcalloc(MAX_FILER_CACHE_IDX / 2 + 1, | |
| 1531 | − sizeof(struct gfar_mask_entry), GFP_KERNEL); | |
| 1532 | − | |
| 1533 | − if (mask_table == NULL) { | |
| 1534 | − ret = -ENOMEM; | |
| 1535 | − goto end; | |
| 1536 | − } | |
| 1537 | − | |
| 1538 | − and_index = gfar_generate_mask_table(mask_table, tab); | |
| 1539 | − | |
| 1540 | − gfar_sort_mask_table(mask_table, temp_table, and_index); | |
| 1541 | − | |
| 1542 | − /* Now we can copy the data from our duplicated filer table to | |
| 1543 | − * the real one in the order the mask table says | |
| 1544 | − */ | |
| 1545 | − for (i = 0; i < and_index; i++) { | |
| 1546 | − size = mask_table[i].end - mask_table[i].start + 1; | |
| 1547 | − gfar_copy_filer_entries(&(tab->fe[j]), | |
| 1548 | − &(temp_table->fe[mask_table[i].start]), size); | |
| 1549 | − j += size; | |
| 1550 | − } | |
| 1551 | − | |
| 1552 | − /* And finally we just have to check for duplicated masks and drop the | |
| 1553 | − * second ones | |
| 1554 | − */ | |
| 1555 | − for (i = 0; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) { | |
| 1556 | − if (tab->fe[i].ctrl == 0x80) { | |
| 1557 | − previous_mask = i++; | |
| 1558 | − break; | |
| 1559 | − } | |
| 1560 | − } | |
| 1561 | − for (; i < tab->index && i < MAX_FILER_CACHE_IDX; i++) { | |
| 1562 | − if (tab->fe[i].ctrl == 0x80) { | |
| 1563 | − if (tab->fe[i].prop == tab->fe[previous_mask].prop) { | |
| 1564 | − /* Two identical ones found! | |
| 1565 | − * So drop the second one! | |
| 1566 | − */ | |
| 1567 | − gfar_trim_filer_entries(i, i, tab); | |
| 1568 | − } else | |
| 1569 | − /* Not identical! */ | |
| 1570 | − previous_mask = i; | |
| 1571 | − } | |
| 1572 | − } | |
| 1573 | − | |
| 1574 | − kfree(mask_table); | |
| 1575 | −end: kfree(temp_table); | |
| 1576 | − return ret; | |
| 1577 | −} | |
| 1578 | − | |
| 1579 | 1254 | /* Write the bit-pattern from software's buffer to hardware registers */ |
| 1580 | 1255 | static int gfar_write_filer_table(struct gfar_private *priv, |
| 1581 | 1256 | struct filer_table *tab) |
| @@ -1585,11 +1260,10 @@ static int gfar_write_filer_table(struct gfar_private *priv, · 3 unmodified lines | ||
| 1585 | 1260 | return -EBUSY; |
| 1586 | 1261 | |
| 1587 | 1262 | /* Fill regular entries */ |
| 1588 | − for (; i < MAX_FILER_IDX - 1 && (tab->fe[i].ctrl | tab->fe[i].prop); | |
| 1589 | − i++) | |
| 1263 | + for (; i < MAX_FILER_IDX && (tab->fe[i].ctrl | tab->fe[i].prop); i++) | |
| 1590 | 1264 | gfar_write_filer(priv, i, tab->fe[i].ctrl, tab->fe[i].prop); |
| 1591 | 1265 | /* Fill the rest with fall-troughs */ |
| 1592 | − for (; i < MAX_FILER_IDX - 1; i++) | |
| 1266 | + for (; i < MAX_FILER_IDX; i++) | |
| 1593 | 1267 | gfar_write_filer(priv, i, 0x60, 0xFFFFFFFF); |
| 1594 | 1268 | /* Last entry must be default accept |
| 1595 | 1269 | * because that's what people expect |
| @@ -1623,7 +1297,6 @@ static int gfar_process_filer_changes(struct gfar_private *priv) · 27 unmodified lines | ||
| 1623 | 1297 | { |
| 1624 | 1298 | struct ethtool_flow_spec_container *j; |
| 1625 | 1299 | struct filer_table *tab; |
| 1626 | − s32 i = 0; | |
| 1627 | 1300 | s32 ret = 0; |
| 1628 | 1301 | |
| 1629 | 1302 | /* So index is set to zero, too! */ |
| @@ -1648,17 +1321,6 @@ static int gfar_process_filer_changes(struct gfar_private *priv) · 18 unmodified lines | ||
| 1648 | 1321 | } |
| 1649 | 1322 | } |
| 1650 | 1323 | |
| 1651 | − i = tab->index; | |
| 1652 | − | |
| 1653 | − /* Optimizations to save entries */ | |
| 1654 | − gfar_cluster_filer(tab); | |
| 1655 | − gfar_optimize_filer_masks(tab); | |
| 1656 | − | |
| 1657 | − pr_debug("\tSummary:\n" | |
| 1658 | − "\tData on hardware: %d\n" | |
| 1659 | − "\tCompression rate: %d%%\n", | |
| 1660 | − tab->index, 100 - (100 * tab->index) / i); | |
| 1661 | − | |
| 1662 | 1324 | /* Write everything to hardware */ |
| 1663 | 1325 | ret = gfar_write_filer_table(priv, tab); |
| 1664 | 1326 | if (ret == -EBUSY) { |
| @@ -1724,13 +1386,14 @@ static int gfar_add_cls(struct gfar_private *priv, · 59 unmodified lines | ||
| 1724 | 1386 | } |
| 1725 | 1387 | |
| 1726 | 1388 | process: |
| 1389 | + priv->rx_list.count++; | |
| 1727 | 1390 | ret = gfar_process_filer_changes(priv); |
| 1728 | 1391 | if (ret) |
| 1729 | 1392 | goto clean_list; |
| 1730 | − priv->rx_list.count++; | |
| 1731 | 1393 | return ret; |
| 1732 | 1394 | |
| 1733 | 1395 | clean_list: |
| 1396 | + priv->rx_list.count--; | |
| 1734 | 1397 | list_del(&temp->list); |
| 1735 | 1398 | clean_mem: |
| 1736 | 1399 | kfree(temp); |
| @@ -27,6 +27,8 @@ · 26 unmodified lines | ||
| 27 | 27 | #include <linux/of_address.h> |
| 28 | 28 | #include <linux/phy.h> |
| 29 | 29 | #include <linux/clk.h> |
| 30 | +#include <linux/hrtimer.h> | |
| 31 | +#include <linux/ktime.h> | |
| 30 | 32 | #include <uapi/linux/ppp_defs.h> |
| 31 | 33 | #include <net/ip.h> |
| 32 | 34 | #include <net/ipv6.h> |
| @@ -299,6 +301,7 @@ · 266 unmodified lines | ||
| 299 | 301 | |
| 300 | 302 | /* Coalescing */ |
| 301 | 303 | #define MVPP2_TXDONE_COAL_PKTS_THRESH 15 |
| 304 | +#define MVPP2_TXDONE_HRTIMER_PERIOD_NS 1000000UL | |
| 302 | 305 | #define MVPP2_RX_COAL_PKTS 32 |
| 303 | 306 | #define MVPP2_RX_COAL_USEC 100 |
| 304 | 307 | |
| @@ -660,6 +663,14 @@ struct mvpp2_pcpu_stats { · 355 unmodified lines | ||
| 660 | 663 | u64 tx_bytes; |
| 661 | 664 | }; |
| 662 | 665 | |
| 666 | +/* Per-CPU port control */ | |
| 667 | +struct mvpp2_port_pcpu { | |
| 668 | + struct hrtimer tx_done_timer; | |
| 669 | + bool timer_scheduled; | |
| 670 | + /* Tasklet for egress finalization */ | |
| 671 | + struct tasklet_struct tx_done_tasklet; | |
| 672 | +}; | |
| 673 | + | |
| 663 | 674 | struct mvpp2_port { |
| 664 | 675 | u8 id; |
| 665 | 676 | |
| @@ -679,6 +690,9 @@ struct mvpp2_port { · 13 unmodified lines | ||
| 679 | 690 | u32 pending_cause_rx; |
| 680 | 691 | struct napi_struct napi; |
| 681 | 692 | |
| 693 | + /* Per-CPU port control */ | |
| 694 | + struct mvpp2_port_pcpu __percpu *pcpu; | |
| 695 | + | |
| 682 | 696 | /* Flags */ |
| 683 | 697 | unsigned long flags; |
| 684 | 698 | |
| @@ -776,6 +790,9 @@ struct mvpp2_txq_pcpu { · 91 unmodified lines | ||
| 776 | 790 | /* Array of transmitted skb */ |
| 777 | 791 | struct sk_buff **tx_skb; |
| 778 | 792 | |
| 793 | + /* Array of transmitted buffers' physical addresses */ | |
| 794 | + dma_addr_t *tx_buffs; | |
| 795 | + | |
| 779 | 796 | /* Index of last TX DMA descriptor that was inserted */ |
| 780 | 797 | int txq_put_index; |
| 781 | 798 | |
| @@ -913,8 +930,6 @@ struct mvpp2_bm_pool { · 131 unmodified lines | ||
| 913 | 930 | /* Occupied buffers indicator */ |
| 914 | 931 | atomic_t in_use; |
| 915 | 932 | int in_use_thresh; |
| 916 | − | |
| 917 | − spinlock_t lock; | |
| 918 | 933 | }; |
| 919 | 934 | |
| 920 | 935 | struct mvpp2_buff_hdr { |
| @@ -963,9 +978,13 @@ static void mvpp2_txq_inc_get(struct mvpp2_txq_pcpu *txq_pcpu) · 42 unmodified lines | ||
| 963 | 978 | } |
| 964 | 979 | |
| 965 | 980 | static void mvpp2_txq_inc_put(struct mvpp2_txq_pcpu *txq_pcpu, |
| 966 | − struct sk_buff *skb) | |
| 981 | + struct sk_buff *skb, | |
| 982 | + struct mvpp2_tx_desc *tx_desc) | |
| 967 | 983 | { |
| 968 | 984 | txq_pcpu->tx_skb[txq_pcpu->txq_put_index] = skb; |
| 985 | + if (skb) | |
| 986 | + txq_pcpu->tx_buffs[txq_pcpu->txq_put_index] = | |
| 987 | + tx_desc->buf_phys_addr; | |
| 969 | 988 | txq_pcpu->txq_put_index++; |
| 970 | 989 | if (txq_pcpu->txq_put_index == txq_pcpu->size) |
| 971 | 990 | txq_pcpu->txq_put_index = 0; |
| @@ -3376,7 +3395,6 @@ static int mvpp2_bm_pool_create(struct platform_device *pdev, · 2404 unmodified lines | ||
| 3376 | 3395 | bm_pool->pkt_size = 0; |
| 3377 | 3396 | bm_pool->buf_num = 0; |
| 3378 | 3397 | atomic_set(&bm_pool->in_use, 0); |
| 3379 | − spin_lock_init(&bm_pool->lock); | |
| 3380 | 3398 | |
| 3381 | 3399 | return 0; |
| 3382 | 3400 | } |
| @@ -3647,7 +3665,6 @@ static struct mvpp2_bm_pool * · 264 unmodified lines | ||
| 3647 | 3665 | mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, |
| 3648 | 3666 | int pkt_size) |
| 3649 | 3667 | { |
| 3650 | − unsigned long flags = 0; | |
| 3651 | 3668 | struct mvpp2_bm_pool *new_pool = &port->priv->bm_pools[pool]; |
| 3652 | 3669 | int num; |
| 3653 | 3670 | |
| @@ -3656,8 +3673,6 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, · 2 unmodified lines | ||
| 3656 | 3673 | return NULL; |
| 3657 | 3674 | } |
| 3658 | 3675 | |
| 3659 | − spin_lock_irqsave(&new_pool->lock, flags); | |
| 3660 | − | |
| 3661 | 3676 | if (new_pool->type == MVPP2_BM_FREE) |
| 3662 | 3677 | new_pool->type = type; |
| 3663 | 3678 | |
| @@ -3686,8 +3701,6 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, · 22 unmodified lines | ||
| 3686 | 3701 | if (num != pkts_num) { |
| 3687 | 3702 | WARN(1, "pool %d: %d of %d allocated\n", |
| 3688 | 3703 | new_pool->id, num, pkts_num); |
| 3689 | − /* We need to undo the bufs_add() allocations */ | |
| 3690 | − spin_unlock_irqrestore(&new_pool->lock, flags); | |
| 3691 | 3704 | return NULL; |
| 3692 | 3705 | } |
| 3693 | 3706 | } |
| @@ -3695,15 +3708,12 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, · 1 unmodified line | ||
| 3695 | 3708 | mvpp2_bm_pool_bufsize_set(port->priv, new_pool, |
| 3696 | 3709 | MVPP2_RX_BUF_SIZE(new_pool->pkt_size)); |
| 3697 | 3710 | |
| 3698 | − spin_unlock_irqrestore(&new_pool->lock, flags); | |
| 3699 | − | |
| 3700 | 3711 | return new_pool; |
| 3701 | 3712 | } |
| 3702 | 3713 | |
| 3703 | 3714 | /* Initialize pools for swf */ |
| 3704 | 3715 | static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) |
| 3705 | 3716 | { |
| 3706 | − unsigned long flags = 0; | |
| 3707 | 3717 | int rxq; |
| 3708 | 3718 | |
| 3709 | 3719 | if (!port->pool_long) { |
| @@ -3714,9 +3724,7 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) · 4 unmodified lines | ||
| 3714 | 3724 | if (!port->pool_long) |
| 3715 | 3725 | return -ENOMEM; |
| 3716 | 3726 | |
| 3717 | − spin_lock_irqsave(&port->pool_long->lock, flags); | |
| 3718 | 3727 | port->pool_long->port_map |= (1 << port->id); |
| 3719 | − spin_unlock_irqrestore(&port->pool_long->lock, flags); | |
| 3720 | 3728 | |
| 3721 | 3729 | for (rxq = 0; rxq < rxq_number; rxq++) |
| 3722 | 3730 | mvpp2_rxq_long_pool_set(port, rxq, port->pool_long->id); |
| @@ -3730,9 +3738,7 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) · 7 unmodified lines | ||
| 3730 | 3738 | if (!port->pool_short) |
| 3731 | 3739 | return -ENOMEM; |
| 3732 | 3740 | |
| 3733 | − spin_lock_irqsave(&port->pool_short->lock, flags); | |
| 3734 | 3741 | port->pool_short->port_map |= (1 << port->id); |
| 3735 | − spin_unlock_irqrestore(&port->pool_short->lock, flags); | |
| 3736 | 3742 | |
| 3737 | 3743 | for (rxq = 0; rxq < rxq_number; rxq++) |
| 3738 | 3744 | mvpp2_rxq_short_pool_set(port, rxq, |
| @@ -3806,7 +3812,6 @@ static void mvpp2_interrupts_unmask(void *arg) · 67 unmodified lines | ||
| 3806 | 3812 | |
| 3807 | 3813 | mvpp2_write(port->priv, MVPP2_ISR_RX_TX_MASK_REG(port->id), |
| 3808 | 3814 | (MVPP2_CAUSE_MISC_SUM_MASK | |
| 3809 | − MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK | | |
| 3810 | 3815 | MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK)); |
| 3811 | 3816 | } |
| 3812 | 3817 | |
| @@ -4382,23 +4387,6 @@ static void mvpp2_rx_time_coal_set(struct mvpp2_port *port, · 569 unmodified lines | ||
| 4382 | 4387 | rxq->time_coal = usec; |
| 4383 | 4388 | } |
| 4384 | 4389 | |
| 4385 | −/* Set threshold for TX_DONE pkts coalescing */ | |
| 4386 | −static void mvpp2_tx_done_pkts_coal_set(void *arg) | |
| 4387 | −{ | |
| 4388 | − struct mvpp2_port *port = arg; | |
| 4389 | − int queue; | |
| 4390 | − u32 val; | |
| 4391 | − | |
| 4392 | − for (queue = 0; queue < txq_number; queue++) { | |
| 4393 | − struct mvpp2_tx_queue *txq = port->txqs[queue]; | |
| 4394 | − | |
| 4395 | − val = (txq->done_pkts_coal << MVPP2_TRANSMITTED_THRESH_OFFSET) & | |
| 4396 | − MVPP2_TRANSMITTED_THRESH_MASK; | |
| 4397 | − mvpp2_write(port->priv, MVPP2_TXQ_NUM_REG, txq->id); | |
| 4398 | − mvpp2_write(port->priv, MVPP2_TXQ_THRESH_REG, val); | |
| 4399 | − } | |
| 4400 | −} | |
| 4401 | − | |
| 4402 | 4390 | /* Free Tx queue skbuffs */ |
| 4403 | 4391 | static void mvpp2_txq_bufs_free(struct mvpp2_port *port, |
| 4404 | 4392 | struct mvpp2_tx_queue *txq, |
| @@ -4407,8 +4395,8 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port, · 2 unmodified lines | ||
| 4407 | 4395 | int i; |
| 4408 | 4396 | |
| 4409 | 4397 | for (i = 0; i < num; i++) { |
| 4410 | − struct mvpp2_tx_desc *tx_desc = txq->descs + | |
| 4411 | − txq_pcpu->txq_get_index; | |
| 4398 | + dma_addr_t buf_phys_addr = | |
| 4399 | + txq_pcpu->tx_buffs[txq_pcpu->txq_get_index]; | |
| 4412 | 4400 | struct sk_buff *skb = txq_pcpu->tx_skb[txq_pcpu->txq_get_index]; |
| 4413 | 4401 | |
| 4414 | 4402 | mvpp2_txq_inc_get(txq_pcpu); |
| @@ -4416,8 +4404,8 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port, · 1 unmodified line | ||
| 4416 | 4404 | if (!skb) |
| 4417 | 4405 | continue; |
| 4418 | 4406 | |
| 4419 | − dma_unmap_single(port->dev->dev.parent, tx_desc->buf_phys_addr, | |
| 4420 | − tx_desc->data_size, DMA_TO_DEVICE); | |
| 4407 | + dma_unmap_single(port->dev->dev.parent, buf_phys_addr, | |
| 4408 | + skb_headlen(skb), DMA_TO_DEVICE); | |
| 4421 | 4409 | dev_kfree_skb_any(skb); |
| 4422 | 4410 | } |
| 4423 | 4411 | } |
| @@ -4433,7 +4421,7 @@ static inline struct mvpp2_rx_queue *mvpp2_get_rx_queue(struct mvpp2_port *port, · 9 unmodified lines | ||
| 4433 | 4421 | static inline struct mvpp2_tx_queue *mvpp2_get_tx_queue(struct mvpp2_port *port, |
| 4434 | 4422 | u32 cause) |
| 4435 | 4423 | { |
| 4436 | − int queue = fls(cause >> 16) - 1; | |
| 4424 | + int queue = fls(cause) - 1; | |
| 4437 | 4425 | |
| 4438 | 4426 | return port->txqs[queue]; |
| 4439 | 4427 | } |
| @@ -4460,6 +4448,29 @@ static void mvpp2_txq_done(struct mvpp2_port *port, struct mvpp2_tx_queue *txq, · 20 unmodified lines | ||
| 4460 | 4448 | netif_tx_wake_queue(nq); |
| 4461 | 4449 | } |
| 4462 | 4450 | |
| 4451 | +static unsigned int mvpp2_tx_done(struct mvpp2_port *port, u32 cause) | |
| 4452 | +{ | |
| 4453 | + struct mvpp2_tx_queue *txq; | |
| 4454 | + struct mvpp2_txq_pcpu *txq_pcpu; | |
| 4455 | + unsigned int tx_todo = 0; | |
| 4456 | + | |
| 4457 | + while (cause) { | |
| 4458 | + txq = mvpp2_get_tx_queue(port, cause); | |
| 4459 | + if (!txq) | |
| 4460 | + break; | |
| 4461 | + | |
| 4462 | + txq_pcpu = this_cpu_ptr(txq->pcpu); | |
| 4463 | + | |
| 4464 | + if (txq_pcpu->count) { | |
| 4465 | + mvpp2_txq_done(port, txq, txq_pcpu); | |
| 4466 | + tx_todo += txq_pcpu->count; | |
| 4467 | + } | |
| 4468 | + | |
| 4469 | + cause &= ~(1 << txq->log_id); | |
| 4470 | + } | |
| 4471 | + return tx_todo; | |
| 4472 | +} | |
| 4473 | + | |
| 4463 | 4474 | /* Rx/Tx queue initialization/cleanup methods */ |
| 4464 | 4475 | |
| 4465 | 4476 | /* Allocate and initialize descriptors for aggr TXQ */ |
| @@ -4649,12 +4660,13 @@ static int mvpp2_txq_init(struct mvpp2_port *port, · 183 unmodified lines | ||
| 4649 | 4660 | txq_pcpu->tx_skb = kmalloc(txq_pcpu->size * |
| 4650 | 4661 | sizeof(*txq_pcpu->tx_skb), |
| 4651 | 4662 | GFP_KERNEL); |
| 4652 | − if (!txq_pcpu->tx_skb) { | |
| 4653 | − dma_free_coherent(port->dev->dev.parent, | |
| 4654 | − txq->size * MVPP2_DESC_ALIGNED_SIZE, | |
| 4655 | − txq->descs, txq->descs_phys); | |
| 4656 | − return -ENOMEM; | |
| 4657 | − } | |
| 4663 | + if (!txq_pcpu->tx_skb) | |
| 4664 | + goto error; | |
| 4665 | + | |
| 4666 | + txq_pcpu->tx_buffs = kmalloc(txq_pcpu->size * | |
| 4667 | + sizeof(dma_addr_t), GFP_KERNEL); | |
| 4668 | + if (!txq_pcpu->tx_buffs) | |
| 4669 | + goto error; | |
| 4658 | 4670 | |
| 4659 | 4671 | txq_pcpu->count = 0; |
| 4660 | 4672 | txq_pcpu->reserved_num = 0; |
| @@ -4663,6 +4675,19 @@ static int mvpp2_txq_init(struct mvpp2_port *port, · 2 unmodified lines | ||
| 4663 | 4675 | } |
| 4664 | 4676 | |
| 4665 | 4677 | return 0; |
| 4678 | + | |
| 4679 | +error: | |
| 4680 | + for_each_present_cpu(cpu) { | |
| 4681 | + txq_pcpu = per_cpu_ptr(txq->pcpu, cpu); | |
| 4682 | + kfree(txq_pcpu->tx_skb); | |
| 4683 | + kfree(txq_pcpu->tx_buffs); | |
| 4684 | + } | |
| 4685 | + | |
| 4686 | + dma_free_coherent(port->dev->dev.parent, | |
| 4687 | + txq->size * MVPP2_DESC_ALIGNED_SIZE, | |
| 4688 | + txq->descs, txq->descs_phys); | |
| 4689 | + | |
| 4690 | + return -ENOMEM; | |
| 4666 | 4691 | } |
| 4667 | 4692 | |
| 4668 | 4693 | /* Free allocated TXQ resources */ |
| @@ -4675,6 +4700,7 @@ static void mvpp2_txq_deinit(struct mvpp2_port *port, · 6 unmodified lines | ||
| 4675 | 4700 | for_each_present_cpu(cpu) { |
| 4676 | 4701 | txq_pcpu = per_cpu_ptr(txq->pcpu, cpu); |
| 4677 | 4702 | kfree(txq_pcpu->tx_skb); |
| 4703 | + kfree(txq_pcpu->tx_buffs); | |
| 4678 | 4704 | } |
| 4679 | 4705 | |
| 4680 | 4706 | if (txq->descs) |
| @@ -4805,7 +4831,6 @@ static int mvpp2_setup_txqs(struct mvpp2_port *port) · 124 unmodified lines | ||
| 4805 | 4831 | goto err_cleanup; |
| 4806 | 4832 | } |
| 4807 | 4833 | |
| 4808 | − on_each_cpu(mvpp2_tx_done_pkts_coal_set, port, 1); | |
| 4809 | 4834 | on_each_cpu(mvpp2_txq_sent_counter_clear, port, 1); |
| 4810 | 4835 | return 0; |
| 4811 | 4836 | |
| @@ -4887,6 +4912,49 @@ static void mvpp2_link_event(struct net_device *dev) · 75 unmodified lines | ||
| 4887 | 4912 | } |
| 4888 | 4913 | } |
| 4889 | 4914 | |
| 4915 | +static void mvpp2_timer_set(struct mvpp2_port_pcpu *port_pcpu) | |
| 4916 | +{ | |
| 4917 | + ktime_t interval; | |
| 4918 | + | |
| 4919 | + if (!port_pcpu->timer_scheduled) { | |
| 4920 | + port_pcpu->timer_scheduled = true; | |
| 4921 | + interval = ktime_set(0, MVPP2_TXDONE_HRTIMER_PERIOD_NS); | |
| 4922 | + hrtimer_start(&port_pcpu->tx_done_timer, interval, | |
| 4923 | + HRTIMER_MODE_REL_PINNED); | |
| 4924 | + } | |
| 4925 | +} | |
| 4926 | + | |
| 4927 | +static void mvpp2_tx_proc_cb(unsigned long data) | |
| 4928 | +{ | |
| 4929 | + struct net_device *dev = (struct net_device *)data; | |
| 4930 | + struct mvpp2_port *port = netdev_priv(dev); | |
| 4931 | + struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu); | |
| 4932 | + unsigned int tx_todo, cause; | |
| 4933 | + | |
| 4934 | + if (!netif_running(dev)) | |
| 4935 | + return; | |
| 4936 | + port_pcpu->timer_scheduled = false; | |
| 4937 | + | |
| 4938 | + /* Process all the Tx queues */ | |
| 4939 | + cause = (1 << txq_number) - 1; | |
| 4940 | + tx_todo = mvpp2_tx_done(port, cause); | |
| 4941 | + | |
| 4942 | + /* Set the timer in case not all the packets were processed */ | |
| 4943 | + if (tx_todo) | |
| 4944 | + mvpp2_timer_set(port_pcpu); | |
| 4945 | +} | |
| 4946 | + | |
| 4947 | +static enum hrtimer_restart mvpp2_hr_timer_cb(struct hrtimer *timer) | |
| 4948 | +{ | |
| 4949 | + struct mvpp2_port_pcpu *port_pcpu = container_of(timer, | |
| 4950 | + struct mvpp2_port_pcpu, | |
| 4951 | + tx_done_timer); | |
| 4952 | + | |
| 4953 | + tasklet_schedule(&port_pcpu->tx_done_tasklet); | |
| 4954 | + | |
| 4955 | + return HRTIMER_NORESTART; | |
| 4956 | +} | |
| 4957 | + | |
| 4890 | 4958 | /* Main RX/TX processing routines */ |
| 4891 | 4959 | |
| 4892 | 4960 | /* Display more error info */ |
| @@ -5144,11 +5212,11 @@ static int mvpp2_tx_frag_process(struct mvpp2_port *port, struct sk_buff *skb, · 251 unmodified lines | ||
| 5144 | 5212 | if (i == (skb_shinfo(skb)->nr_frags - 1)) { |
| 5145 | 5213 | /* Last descriptor */ |
| 5146 | 5214 | tx_desc->command = MVPP2_TXD_L_DESC; |
| 5147 | − mvpp2_txq_inc_put(txq_pcpu, skb); | |
| 5215 | + mvpp2_txq_inc_put(txq_pcpu, skb, tx_desc); | |
| 5148 | 5216 | } else { |
| 5149 | 5217 | /* Descriptor in the middle: Not First, Not Last */ |
| 5150 | 5218 | tx_desc->command = 0; |
| 5151 | − mvpp2_txq_inc_put(txq_pcpu, NULL); | |
| 5219 | + mvpp2_txq_inc_put(txq_pcpu, NULL, tx_desc); | |
| 5152 | 5220 | } |
| 5153 | 5221 | } |
| 5154 | 5222 | |
| @@ -5214,12 +5282,12 @@ static int mvpp2_tx(struct sk_buff *skb, struct net_device *dev) · 59 unmodified lines | ||
| 5214 | 5282 | /* First and Last descriptor */ |
| 5215 | 5283 | tx_cmd |= MVPP2_TXD_F_DESC | MVPP2_TXD_L_DESC; |
| 5216 | 5284 | tx_desc->command = tx_cmd; |
| 5217 | − mvpp2_txq_inc_put(txq_pcpu, skb); | |
| 5285 | + mvpp2_txq_inc_put(txq_pcpu, skb, tx_desc); | |
| 5218 | 5286 | } else { |
| 5219 | 5287 | /* First but not Last */ |
| 5220 | 5288 | tx_cmd |= MVPP2_TXD_F_DESC | MVPP2_TXD_PADDING_DISABLE; |
| 5221 | 5289 | tx_desc->command = tx_cmd; |
| 5222 | − mvpp2_txq_inc_put(txq_pcpu, NULL); | |
| 5290 | + mvpp2_txq_inc_put(txq_pcpu, NULL, tx_desc); | |
| 5223 | 5291 | |
| 5224 | 5292 | /* Continue with other skb fragments */ |
| 5225 | 5293 | if (mvpp2_tx_frag_process(port, skb, aggr_txq, txq)) { |
| @@ -5255,6 +5323,17 @@ out: · 29 unmodified lines | ||
| 5255 | 5323 | dev_kfree_skb_any(skb); |
| 5256 | 5324 | } |
| 5257 | 5325 | |
| 5326 | + /* Finalize TX processing */ | |
| 5327 | + if (txq_pcpu->count >= txq->done_pkts_coal) | |
| 5328 | + mvpp2_txq_done(port, txq, txq_pcpu); | |
| 5329 | + | |
| 5330 | + /* Set the timer in case not all frags were processed */ | |
| 5331 | + if (txq_pcpu->count <= frags && txq_pcpu->count > 0) { | |
| 5332 | + struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu); | |
| 5333 | + | |
| 5334 | + mvpp2_timer_set(port_pcpu); | |
| 5335 | + } | |
| 5336 | + | |
| 5258 | 5337 | return NETDEV_TX_OK; |
| 5259 | 5338 | } |
| 5260 | 5339 | |
| @@ -5268,10 +5347,11 @@ static inline void mvpp2_cause_error(struct net_device *dev, int cause) · 7 unmodified lines | ||
| 5268 | 5347 | netdev_err(dev, "tx fifo underrun error\n"); |
| 5269 | 5348 | } |
| 5270 | 5349 | |
| 5271 | −static void mvpp2_txq_done_percpu(void *arg) | |
| 5350 | +static int mvpp2_poll(struct napi_struct *napi, int budget) | |
| 5272 | 5351 | { |
| 5273 | − struct mvpp2_port *port = arg; | |
| 5274 | − u32 cause_rx_tx, cause_tx, cause_misc; | |
| 5352 | + u32 cause_rx_tx, cause_rx, cause_misc; | |
| 5353 | + int rx_done = 0; | |
| 5354 | + struct mvpp2_port *port = netdev_priv(napi->dev); | |
| 5275 | 5355 | |
| 5276 | 5356 | /* Rx/Tx cause register |
| 5277 | 5357 | * |
| @@ -5285,7 +5365,7 @@ static void mvpp2_txq_done_percpu(void *arg) · 7 unmodified lines | ||
| 5285 | 5365 | */ |
| 5286 | 5366 | cause_rx_tx = mvpp2_read(port->priv, |
| 5287 | 5367 | MVPP2_ISR_RX_TX_CAUSE_REG(port->id)); |
| 5288 | − cause_tx = cause_rx_tx & MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK; | |
| 5368 | + cause_rx_tx &= ~MVPP2_CAUSE_TXQ_OCCUP_DESC_ALL_MASK; | |
| 5289 | 5369 | cause_misc = cause_rx_tx & MVPP2_CAUSE_MISC_SUM_MASK; |
| 5290 | 5370 | |
| 5291 | 5371 | if (cause_misc) { |
| @@ -5297,26 +5377,6 @@ static void mvpp2_txq_done_percpu(void *arg) · 5 unmodified lines | ||
| 5297 | 5377 | cause_rx_tx & ~MVPP2_CAUSE_MISC_SUM_MASK); |
| 5298 | 5378 | } |
| 5299 | 5379 | |
| 5300 | − /* Release TX descriptors */ | |
| 5301 | − if (cause_tx) { | |
| 5302 | − struct mvpp2_tx_queue *txq = mvpp2_get_tx_queue(port, cause_tx); | |
| 5303 | − struct mvpp2_txq_pcpu *txq_pcpu = this_cpu_ptr(txq->pcpu); | |
| 5304 | − | |
| 5305 | − if (txq_pcpu->count) | |
| 5306 | − mvpp2_txq_done(port, txq, txq_pcpu); | |
| 5307 | − } | |
| 5308 | −} | |
| 5309 | − | |
| 5310 | −static int mvpp2_poll(struct napi_struct *napi, int budget) | |
| 5311 | −{ | |
| 5312 | − u32 cause_rx_tx, cause_rx; | |
| 5313 | − int rx_done = 0; | |
| 5314 | − struct mvpp2_port *port = netdev_priv(napi->dev); | |
| 5315 | − | |
| 5316 | − on_each_cpu(mvpp2_txq_done_percpu, port, 1); | |
| 5317 | − | |
| 5318 | − cause_rx_tx = mvpp2_read(port->priv, | |
| 5319 | − MVPP2_ISR_RX_TX_CAUSE_REG(port->id)); | |
| 5320 | 5380 | cause_rx = cause_rx_tx & MVPP2_CAUSE_RXQ_OCCUP_DESC_ALL_MASK; |
| 5321 | 5381 | |
| 5322 | 5382 | /* Process RX packets */ |
| @@ -5561,6 +5621,8 @@ err_cleanup_rxqs: · 238 unmodified lines | ||
| 5561 | 5621 | static int mvpp2_stop(struct net_device *dev) |
| 5562 | 5622 | { |
| 5563 | 5623 | struct mvpp2_port *port = netdev_priv(dev); |
| 5624 | + struct mvpp2_port_pcpu *port_pcpu; | |
| 5625 | + int cpu; | |
| 5564 | 5626 | |
| 5565 | 5627 | mvpp2_stop_dev(port); |
| 5566 | 5628 | mvpp2_phy_disconnect(port); |
| @@ -5569,6 +5631,13 @@ static int mvpp2_stop(struct net_device *dev) · 2 unmodified lines | ||
| 5569 | 5631 | on_each_cpu(mvpp2_interrupts_mask, port, 1); |
| 5570 | 5632 | |
| 5571 | 5633 | free_irq(port->irq, port); |
| 5634 | + for_each_present_cpu(cpu) { | |
| 5635 | + port_pcpu = per_cpu_ptr(port->pcpu, cpu); | |
| 5636 | + | |
| 5637 | + hrtimer_cancel(&port_pcpu->tx_done_timer); | |
| 5638 | + port_pcpu->timer_scheduled = false; | |
| 5639 | + tasklet_kill(&port_pcpu->tx_done_tasklet); | |
| 5640 | + } | |
| 5572 | 5641 | mvpp2_cleanup_rxqs(port); |
| 5573 | 5642 | mvpp2_cleanup_txqs(port); |
| 5574 | 5643 | |
| @@ -5784,7 +5853,6 @@ static int mvpp2_ethtool_set_coalesce(struct net_device *dev, · 209 unmodified lines | ||
| 5784 | 5853 | txq->done_pkts_coal = c->tx_max_coalesced_frames; |
| 5785 | 5854 | } |
| 5786 | 5855 | |
| 5787 | − on_each_cpu(mvpp2_tx_done_pkts_coal_set, port, 1); | |
| 5788 | 5856 | return 0; |
| 5789 | 5857 | } |
| 5790 | 5858 | |
| @@ -6035,6 +6103,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 244 unmodified lines | ||
| 6035 | 6103 | { |
| 6036 | 6104 | struct device_node *phy_node; |
| 6037 | 6105 | struct mvpp2_port *port; |
| 6106 | + struct mvpp2_port_pcpu *port_pcpu; | |
| 6038 | 6107 | struct net_device *dev; |
| 6039 | 6108 | struct resource *res; |
| 6040 | 6109 | const char *dt_mac_addr; |
| @@ -6044,7 +6113,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 3 unmodified lines | ||
| 6044 | 6113 | int features; |
| 6045 | 6114 | int phy_mode; |
| 6046 | 6115 | int priv_common_regs_num = 2; |
| 6047 | − int err, i; | |
| 6116 | + int err, i, cpu; | |
| 6048 | 6117 | |
| 6049 | 6118 | dev = alloc_etherdev_mqs(sizeof(struct mvpp2_port), txq_number, |
| 6050 | 6119 | rxq_number); |
| @@ -6135,6 +6204,24 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 84 unmodified lines | ||
| 6135 | 6204 | } |
| 6136 | 6205 | mvpp2_port_power_up(port); |
| 6137 | 6206 | |
| 6207 | + port->pcpu = alloc_percpu(struct mvpp2_port_pcpu); | |
| 6208 | + if (!port->pcpu) { | |
| 6209 | + err = -ENOMEM; | |
| 6210 | + goto err_free_txq_pcpu; | |
| 6211 | + } | |
| 6212 | + | |
| 6213 | + for_each_present_cpu(cpu) { | |
| 6214 | + port_pcpu = per_cpu_ptr(port->pcpu, cpu); | |
| 6215 | + | |
| 6216 | + hrtimer_init(&port_pcpu->tx_done_timer, CLOCK_MONOTONIC, | |
| 6217 | + HRTIMER_MODE_REL_PINNED); | |
| 6218 | + port_pcpu->tx_done_timer.function = mvpp2_hr_timer_cb; | |
| 6219 | + port_pcpu->timer_scheduled = false; | |
| 6220 | + | |
| 6221 | + tasklet_init(&port_pcpu->tx_done_tasklet, mvpp2_tx_proc_cb, | |
| 6222 | + (unsigned long)dev); | |
| 6223 | + } | |
| 6224 | + | |
| 6138 | 6225 | netif_napi_add(dev, &port->napi, mvpp2_poll, NAPI_POLL_WEIGHT); |
| 6139 | 6226 | features = NETIF_F_SG | NETIF_F_IP_CSUM; |
| 6140 | 6227 | dev->features = features | NETIF_F_RXCSUM; |
| @@ -6144,7 +6231,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 3 unmodified lines | ||
| 6144 | 6231 | err = register_netdev(dev); |
| 6145 | 6232 | if (err < 0) { |
| 6146 | 6233 | dev_err(&pdev->dev, "failed to register netdev\n"); |
| 6147 | − goto err_free_txq_pcpu; | |
| 6234 | + goto err_free_port_pcpu; | |
| 6148 | 6235 | } |
| 6149 | 6236 | netdev_info(dev, "Using %s mac address %pM\n", mac_from, dev->dev_addr); |
| 6150 | 6237 | |
| @@ -6153,6 +6240,8 @@ static int mvpp2_port_probe(struct platform_device *pdev, · 2 unmodified lines | ||
| 6153 | 6240 | priv->port_list[id] = port; |
| 6154 | 6241 | return 0; |
| 6155 | 6242 | |
| 6243 | +err_free_port_pcpu: | |
| 6244 | + free_percpu(port->pcpu); | |
| 6156 | 6245 | err_free_txq_pcpu: |
| 6157 | 6246 | for (i = 0; i < txq_number; i++) |
| 6158 | 6247 | free_percpu(port->txqs[i]->pcpu); |
| @@ -6171,6 +6260,7 @@ static void mvpp2_port_remove(struct mvpp2_port *port) · 12 unmodified lines | ||
| 6171 | 6260 | int i; |
| 6172 | 6261 | |
| 6173 | 6262 | unregister_netdev(port->dev); |
| 6263 | + free_percpu(port->pcpu); | |
| 6174 | 6264 | free_percpu(port->stats); |
| 6175 | 6265 | for (i = 0; i < txq_number; i++) |
| 6176 | 6266 | free_percpu(port->txqs[i]->pcpu); |
| @@ -391,6 +391,8 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) · 390 unmodified lines | ||
| 391 | 391 | /* disable cmdif checksum */ |
| 392 | 392 | MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0); |
| 393 | 393 | |
| 394 | + MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12); | |
| 395 | + | |
| 394 | 396 | err = set_caps(dev, set_ctx, set_sz); |
| 395 | 397 | |
| 396 | 398 | query_ex: |
| @@ -4875,10 +4875,12 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp) · 4874 unmodified lines | ||
| 4875 | 4875 | case RTL_GIGA_MAC_VER_46: |
| 4876 | 4876 | case RTL_GIGA_MAC_VER_47: |
| 4877 | 4877 | case RTL_GIGA_MAC_VER_48: |
| 4878 | + RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); | |
| 4879 | + break; | |
| 4878 | 4880 | case RTL_GIGA_MAC_VER_49: |
| 4879 | 4881 | case RTL_GIGA_MAC_VER_50: |
| 4880 | 4882 | case RTL_GIGA_MAC_VER_51: |
| 4881 | − RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF); | |
| 4883 | + RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); | |
| 4882 | 4884 | break; |
| 4883 | 4885 | default: |
| 4884 | 4886 | RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST); |
| @@ -4927,6 +4927,7 @@ static void rocker_remove_ports(const struct rocker *rocker) · 4926 unmodified lines | ||
| 4927 | 4927 | rocker_port_ig_tbl(rocker_port, SWITCHDEV_TRANS_NONE, |
| 4928 | 4928 | ROCKER_OP_FLAG_REMOVE); |
| 4929 | 4929 | unregister_netdev(rocker_port->dev); |
| 4930 | + free_netdev(rocker_port->dev); | |
| 4930 | 4931 | } |
| 4931 | 4932 | kfree(rocker->ports); |
| 4932 | 4933 | } |
| @@ -42,7 +42,7 @@ · 41 unmodified lines | ||
| 42 | 42 | #define NSS_COMMON_CLK_DIV_MASK 0x7f |
| 43 | 43 | |
| 44 | 44 | #define NSS_COMMON_CLK_SRC_CTRL 0x14 |
| 45 | −#define NSS_COMMON_CLK_SRC_CTRL_OFFSET(x) (1 << x) | |
| 45 | +#define NSS_COMMON_CLK_SRC_CTRL_OFFSET(x) (x) | |
| 46 | 46 | /* Mode is coded on 1 bit but is different depending on the MAC ID: |
| 47 | 47 | * MAC0: QSGMII=0 RGMII=1 |
| 48 | 48 | * MAC1: QSGMII=0 SGMII=0 RGMII=1 |
| @@ -308,7 +308,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev) · 259 unmodified lines | ||
| 308 | 308 | |
| 309 | 309 | /* Configure the clock src according to the mode */ |
| 310 | 310 | regmap_read(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, &val); |
| 311 | − val &= ~NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id); | |
| 311 | + val &= ~(1 << NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id)); | |
| 312 | 312 | switch (gmac->phy_mode) { |
| 313 | 313 | case PHY_INTERFACE_MODE_RGMII: |
| 314 | 314 | val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) << |
| @@ -85,7 +85,6 @@ struct netcp_intf { · 84 unmodified lines | ||
| 85 | 85 | struct list_head rxhook_list_head; |
| 86 | 86 | unsigned int rx_queue_id; |
| 87 | 87 | void *rx_fdq[KNAV_DMA_FDQ_PER_CHAN]; |
| 88 | − u32 rx_buffer_sizes[KNAV_DMA_FDQ_PER_CHAN]; | |
| 89 | 88 | struct napi_struct rx_napi; |
| 90 | 89 | struct napi_struct tx_napi; |
| 91 | 90 | |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #define NETCP_SOP_OFFSET (NET_IP_ALIGN + NET_SKB_PAD) |
| 35 | 35 | #define NETCP_NAPI_WEIGHT 64 |
| 36 | 36 | #define NETCP_TX_TIMEOUT (5 * HZ) |
| 37 | +#define NETCP_PACKET_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN) | |
| 37 | 38 | #define NETCP_MIN_PACKET_SIZE ETH_ZLEN |
| 38 | 39 | #define NETCP_MAX_MCAST_ADDR 16 |
| 39 | 40 | |
| @@ -815,30 +816,28 @@ static void netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq) · 775 unmodified lines | ||
| 815 | 816 | if (likely(fdq == 0)) { |
| 816 | 817 | unsigned int primary_buf_len; |
| 817 | 818 | /* Allocate a primary receive queue entry */ |
| 818 | − buf_len = netcp->rx_buffer_sizes[0] + NETCP_SOP_OFFSET; | |
| 819 | + buf_len = NETCP_PACKET_SIZE + NETCP_SOP_OFFSET; | |
| 819 | 820 | primary_buf_len = SKB_DATA_ALIGN(buf_len) + |
| 820 | 821 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); |
| 821 | 822 | |
| 822 | − if (primary_buf_len <= PAGE_SIZE) { | |
| 823 | − bufptr = netdev_alloc_frag(primary_buf_len); | |
| 824 | − pad[1] = primary_buf_len; | |
| 825 | − } else { | |
| 826 | − bufptr = kmalloc(primary_buf_len, GFP_ATOMIC | | |
| 827 | − GFP_DMA32 | __GFP_COLD); | |
| 828 | − pad[1] = 0; | |
| 829 | − } | |
| 823 | + bufptr = netdev_alloc_frag(primary_buf_len); | |
| 824 | + pad[1] = primary_buf_len; | |
| 830 | 825 | |
| 831 | 826 | if (unlikely(!bufptr)) { |
| 832 | − dev_warn_ratelimited(netcp->ndev_dev, "Primary RX buffer alloc failed\n"); | |
| 827 | + dev_warn_ratelimited(netcp->ndev_dev, | |
| 828 | + "Primary RX buffer alloc failed\n"); | |
| 833 | 829 | goto fail; |
| 834 | 830 | } |
| 835 | 831 | dma = dma_map_single(netcp->dev, bufptr, buf_len, |
| 836 | 832 | DMA_TO_DEVICE); |
| 833 | + if (unlikely(dma_mapping_error(netcp->dev, dma))) | |
| 834 | + goto fail; | |
| 835 | + | |
| 837 | 836 | pad[0] = (u32)bufptr; |
| 838 | 837 | |
| 839 | 838 | } else { |
| 840 | 839 | /* Allocate a secondary receive queue entry */ |
| 841 | − page = alloc_page(GFP_ATOMIC | GFP_DMA32 | __GFP_COLD); | |
| 840 | + page = alloc_page(GFP_ATOMIC | GFP_DMA | __GFP_COLD); | |
| 842 | 841 | if (unlikely(!page)) { |
| 843 | 842 | dev_warn_ratelimited(netcp->ndev_dev, "Secondary page alloc failed\n"); |
| 844 | 843 | goto fail; |
| @@ -1021,7 +1020,7 @@ netcp_tx_map_skb(struct sk_buff *skb, struct netcp_intf *netcp) · 176 unmodified lines | ||
| 1021 | 1020 | |
| 1022 | 1021 | /* Map the linear buffer */ |
| 1023 | 1022 | dma_addr = dma_map_single(dev, skb->data, pkt_len, DMA_TO_DEVICE); |
| 1024 | − if (unlikely(!dma_addr)) { | |
| 1023 | + if (unlikely(dma_mapping_error(dev, dma_addr))) { | |
| 1025 | 1024 | dev_err(netcp->ndev_dev, "Failed to map skb buffer\n"); |
| 1026 | 1025 | return NULL; |
| 1027 | 1026 | } |
| @@ -1557,8 +1556,8 @@ static int netcp_setup_navigator_resources(struct net_device *ndev) · 529 unmodified lines | ||
| 1557 | 1556 | knav_queue_disable_notify(netcp->rx_queue); |
| 1558 | 1557 | |
| 1559 | 1558 | /* open Rx FDQs */ |
| 1560 | − for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && | |
| 1561 | − netcp->rx_queue_depths[i] && netcp->rx_buffer_sizes[i]; ++i) { | |
| 1559 | + for (i = 0; i < KNAV_DMA_FDQ_PER_CHAN && netcp->rx_queue_depths[i]; | |
| 1560 | + ++i) { | |
| 1562 | 1561 | snprintf(name, sizeof(name), "rx-fdq-%s-%d", ndev->name, i); |
| 1563 | 1562 | netcp->rx_fdq[i] = knav_queue_open(name, KNAV_QUEUE_GP, 0); |
| 1564 | 1563 | if (IS_ERR_OR_NULL(netcp->rx_fdq[i])) { |
| @@ -1952,14 +1951,6 @@ static int netcp_create_interface(struct netcp_device *netcp_device, · 387 unmodified lines | ||
| 1952 | 1951 | netcp->rx_queue_depths[0] = 128; |
| 1953 | 1952 | } |
| 1954 | 1953 | |
| 1955 | − ret = of_property_read_u32_array(node_interface, "rx-buffer-size", | |
| 1956 | − netcp->rx_buffer_sizes, | |
| 1957 | − KNAV_DMA_FDQ_PER_CHAN); | |
| 1958 | − if (ret) { | |
| 1959 | − dev_err(dev, "missing \"rx-buffer-size\" parameter\n"); | |
| 1960 | − netcp->rx_buffer_sizes[0] = 1536; | |
| 1961 | − } | |
| 1962 | − | |
| 1963 | 1954 | ret = of_property_read_u32_array(node_interface, "rx-pool", temp, 2); |
| 1964 | 1955 | if (ret < 0) { |
| 1965 | 1956 | dev_err(dev, "missing \"rx-pool\" parameter\n"); |
| @@ -728,11 +728,12 @@ static int mkiss_open(struct tty_struct *tty) · 727 unmodified lines | ||
| 728 | 728 | dev->type = ARPHRD_AX25; |
| 729 | 729 | |
| 730 | 730 | /* Perform the low-level AX25 initialization. */ |
| 731 | − if ((err = ax_open(ax->dev))) { | |
| 731 | + err = ax_open(ax->dev); | |
| 732 | + if (err) | |
| 732 | 733 | goto out_free_netdev; |
| 733 | − } | |
| 734 | 734 | |
| 735 | − if (register_netdev(dev)) | |
| 735 | + err = register_netdev(dev); | |
| 736 | + if (err) | |
| 736 | 737 | goto out_free_buffers; |
| 737 | 738 | |
| 738 | 739 | /* after register_netdev() - because else printk smashes the kernel */ |
| @@ -102,6 +102,12 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, · 101 unmodified lines | ||
| 102 | 102 | |
| 103 | 103 | netdev_dbg(ndev, "%s: %d byte payload received\n", __func__, len); |
| 104 | 104 | |
| 105 | + if (len < 0) { | |
| 106 | + ndev->stats.rx_errors++; | |
| 107 | + ndev->stats.rx_length_errors++; | |
| 108 | + goto enqueue_again; | |
| 109 | + } | |
| 110 | + | |
| 105 | 111 | skb_put(skb, len); |
| 106 | 112 | skb->protocol = eth_type_trans(skb, ndev); |
| 107 | 113 | skb->ip_summed = CHECKSUM_NONE; |
| @@ -121,6 +127,7 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data, · 13 unmodified lines | ||
| 121 | 127 | return; |
| 122 | 128 | } |
| 123 | 129 | |
| 130 | +enqueue_again: | |
| 124 | 131 | rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN); |
| 125 | 132 | if (rc) { |
| 126 | 133 | dev_kfree_skb(skb); |
| @@ -184,7 +191,7 @@ static int ntb_netdev_open(struct net_device *ndev) · 57 unmodified lines | ||
| 184 | 191 | |
| 185 | 192 | rc = ntb_transport_rx_enqueue(dev->qp, skb, skb->data, |
| 186 | 193 | ndev->mtu + ETH_HLEN); |
| 187 | − if (rc == -EINVAL) { | |
| 194 | + if (rc) { | |
| 188 | 195 | dev_kfree_skb(skb); |
| 189 | 196 | goto err; |
| 190 | 197 | } |
| @@ -1756,9 +1756,9 @@ static int virtnet_probe(struct virtio_device *vdev) · 1755 unmodified lines | ||
| 1756 | 1756 | /* Do we support "hardware" checksums? */ |
| 1757 | 1757 | if (virtio_has_feature(vdev, VIRTIO_NET_F_CSUM)) { |
| 1758 | 1758 | /* This opens up the world of extra features. */ |
| 1759 | − dev->hw_features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; | |
| 1759 | + dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_SG; | |
| 1760 | 1760 | if (csum) |
| 1761 | − dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; | |
| 1761 | + dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; | |
| 1762 | 1762 | |
| 1763 | 1763 | if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) { |
| 1764 | 1764 | dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO |
| @@ -589,7 +589,8 @@ static int cosa_probe(int base, int irq, int dma) · 588 unmodified lines | ||
| 589 | 589 | chan->netdev->base_addr = chan->cosa->datareg; |
| 590 | 590 | chan->netdev->irq = chan->cosa->irq; |
| 591 | 591 | chan->netdev->dma = chan->cosa->dma; |
| 592 | − if (register_hdlc_device(chan->netdev)) { | |
| 592 | + err = register_hdlc_device(chan->netdev); | |
| 593 | + if (err) { | |
| 593 | 594 | netdev_warn(chan->netdev, |
| 594 | 595 | "register_hdlc_device() failed\n"); |
| 595 | 596 | free_netdev(chan->netdev); |
| @@ -3728,7 +3728,7 @@ const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev) · 3727 unmodified lines | ||
| 3728 | 3728 | switch (phy->rev) { |
| 3729 | 3729 | case 6: |
| 3730 | 3730 | case 5: |
| 3731 | − if (sprom->fem.ghz5.extpa_gain == 3) | |
| 3731 | + if (sprom->fem.ghz2.extpa_gain == 3) | |
| 3732 | 3732 | return b43_ntab_tx_gain_epa_rev3_hi_pwr_2g; |
| 3733 | 3733 | /* fall through */ |
| 3734 | 3734 | case 4: |
| @@ -1023,7 +1023,7 @@ static void iwl_mvm_scan_umac_dwell(struct iwl_mvm *mvm, · 1022 unmodified lines | ||
| 1023 | 1023 | cmd->scan_priority = |
| 1024 | 1024 | iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6); |
| 1025 | 1025 | |
| 1026 | − if (iwl_mvm_scan_total_iterations(params) == 0) | |
| 1026 | + if (iwl_mvm_scan_total_iterations(params) == 1) | |
| 1027 | 1027 | cmd->ooc_priority = |
| 1028 | 1028 | iwl_mvm_scan_priority(mvm, IWL_SCAN_PRIORITY_EXT_6); |
| 1029 | 1029 | else |
| @@ -478,10 +478,16 @@ static void iwl_pcie_apm_stop(struct iwl_trans *trans, bool op_mode_leave) · 477 unmodified lines | ||
| 478 | 478 | if (trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) |
| 479 | 479 | iwl_set_bits_prph(trans, APMG_PCIDEV_STT_REG, |
| 480 | 480 | APMG_PCIDEV_STT_VAL_WAKE_ME); |
| 481 | − else if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) | |
| 481 | + else if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) { | |
| 482 | + iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, | |
| 483 | + CSR_RESET_LINK_PWR_MGMT_DISABLED); | |
| 482 | 484 | iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
| 483 | 485 | CSR_HW_IF_CONFIG_REG_PREPARE | |
| 484 | 486 | CSR_HW_IF_CONFIG_REG_ENABLE_PME); |
| 487 | + mdelay(1); | |
| 488 | + iwl_clear_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, | |
| 489 | + CSR_RESET_LINK_PWR_MGMT_DISABLED); | |
| 490 | + } | |
| 485 | 491 | mdelay(5); |
| 486 | 492 | } |
| 487 | 493 | |
| @@ -575,6 +581,10 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) · 87 unmodified lines | ||
| 575 | 581 | if (ret >= 0) |
| 576 | 582 | return 0; |
| 577 | 583 | |
| 584 | + iwl_set_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, | |
| 585 | + CSR_RESET_LINK_PWR_MGMT_DISABLED); | |
| 586 | + msleep(1); | |
| 587 | + | |
| 578 | 588 | for (iter = 0; iter < 10; iter++) { |
| 579 | 589 | /* If HW is not ready, prepare the conditions to check again */ |
| 580 | 590 | iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
| @@ -582,8 +592,10 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) · 1 unmodified line | ||
| 582 | 592 | |
| 583 | 593 | do { |
| 584 | 594 | ret = iwl_pcie_set_hw_ready(trans); |
| 585 | − if (ret >= 0) | |
| 586 | − return 0; | |
| 595 | + if (ret >= 0) { | |
| 596 | + ret = 0; | |
| 597 | + goto out; | |
| 598 | + } | |
| 587 | 599 | |
| 588 | 600 | usleep_range(200, 1000); |
| 589 | 601 | t += 200; |
| @@ -593,6 +605,10 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) · 3 unmodified lines | ||
| 593 | 605 | |
| 594 | 606 | IWL_ERR(trans, "Couldn't prepare the card\n"); |
| 595 | 607 | |
| 608 | +out: | |
| 609 | + iwl_clear_bit(trans, CSR_DBG_LINK_PWR_MGMT_REG, | |
| 610 | + CSR_RESET_LINK_PWR_MGMT_DISABLED); | |
| 611 | + | |
| 596 | 612 | return ret; |
| 597 | 613 | } |
| 598 | 614 | |
| @@ -1875,8 +1875,19 @@ int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, · 1874 unmodified lines | ||
| 1875 | 1875 | |
| 1876 | 1876 | /* start timer if queue currently empty */ |
| 1877 | 1877 | if (q->read_ptr == q->write_ptr) { |
| 1878 | − if (txq->wd_timeout) | |
| 1879 | − mod_timer(&txq->stuck_timer, jiffies + txq->wd_timeout); | |
| 1878 | + if (txq->wd_timeout) { | |
| 1879 | + /* | |
| 1880 | + * If the TXQ is active, then set the timer, if not, | |
| 1881 | + * set the timer in remainder so that the timer will | |
| 1882 | + * be armed with the right value when the station will | |
| 1883 | + * wake up. | |
| 1884 | + */ | |
| 1885 | + if (!txq->frozen) | |
| 1886 | + mod_timer(&txq->stuck_timer, | |
| 1887 | + jiffies + txq->wd_timeout); | |
| 1888 | + else | |
| 1889 | + txq->frozen_expiry_remainder = txq->wd_timeout; | |
| 1890 | + } | |
| 1880 | 1891 | IWL_DEBUG_RPM(trans, "Q: %d first tx - take ref\n", q->id); |
| 1881 | 1892 | iwl_trans_pcie_ref(trans); |
| 1882 | 1893 | } |
| @@ -172,6 +172,7 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 171 unmodified lines | ||
| 172 | 172 | (struct rsi_91x_sdiodev *)adapter->rsi_dev; |
| 173 | 173 | u32 len; |
| 174 | 174 | u32 num_blocks; |
| 175 | + const u8 *fw; | |
| 175 | 176 | const struct firmware *fw_entry = NULL; |
| 176 | 177 | u32 block_size = dev->tx_blk_size; |
| 177 | 178 | int status = 0; |
| @@ -200,6 +201,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 22 unmodified lines | ||
| 200 | 201 | return status; |
| 201 | 202 | } |
| 202 | 203 | |
| 204 | + /* Copy firmware into DMA-accessible memory */ | |
| 205 | + fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL); | |
| 206 | + if (!fw) | |
| 207 | + return -ENOMEM; | |
| 203 | 208 | len = fw_entry->size; |
| 204 | 209 | |
| 205 | 210 | if (len % 4) |
| @@ -210,7 +215,8 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 4 unmodified lines | ||
| 210 | 215 | rsi_dbg(INIT_ZONE, "%s: Instruction size:%d\n", __func__, len); |
| 211 | 216 | rsi_dbg(INIT_ZONE, "%s: num blocks: %d\n", __func__, num_blocks); |
| 212 | 217 | |
| 213 | − status = rsi_copy_to_card(common, fw_entry->data, len, num_blocks); | |
| 218 | + status = rsi_copy_to_card(common, fw, len, num_blocks); | |
| 219 | + kfree(fw); | |
| 214 | 220 | release_firmware(fw_entry); |
| 215 | 221 | return status; |
| 216 | 222 | } |
| @@ -146,7 +146,10 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 145 unmodified lines | ||
| 146 | 146 | return status; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | + /* Copy firmware into DMA-accessible memory */ | |
| 149 | 150 | fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL); |
| 151 | + if (!fw) | |
| 152 | + return -ENOMEM; | |
| 150 | 153 | len = fw_entry->size; |
| 151 | 154 | |
| 152 | 155 | if (len % 4) |
| @@ -158,6 +161,7 @@ static int rsi_load_ta_instructions(struct rsi_common *common) · 5 unmodified lines | ||
| 158 | 161 | rsi_dbg(INIT_ZONE, "%s: num blocks: %d\n", __func__, num_blocks); |
| 159 | 162 | |
| 160 | 163 | status = rsi_copy_to_card(common, fw, len, num_blocks); |
| 164 | + kfree(fw); | |
| 161 | 165 | release_firmware(fw_entry); |
| 162 | 166 | return status; |
| 163 | 167 | } |
| @@ -1015,9 +1015,12 @@ static void send_beacon_frame(struct ieee80211_hw *hw, · 1014 unmodified lines | ||
| 1015 | 1015 | { |
| 1016 | 1016 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 1017 | 1017 | struct sk_buff *skb = ieee80211_beacon_get(hw, vif); |
| 1018 | + struct rtl_tcb_desc tcb_desc; | |
| 1018 | 1019 | |
| 1019 | − if (skb) | |
| 1020 | − rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, NULL); | |
| 1020 | + if (skb) { | |
| 1021 | + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); | |
| 1022 | + rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc); | |
| 1023 | + } | |
| 1021 | 1024 | } |
| 1022 | 1025 | |
| 1023 | 1026 | static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, |
| @@ -385,6 +385,7 @@ module_param_named(debug, rtl8723be_mod_params.debug, int, 0444); · 384 unmodified lines | ||
| 385 | 385 | module_param_named(ips, rtl8723be_mod_params.inactiveps, bool, 0444); |
| 386 | 386 | module_param_named(swlps, rtl8723be_mod_params.swctrl_lps, bool, 0444); |
| 387 | 387 | module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444); |
| 388 | +module_param_named(msi, rtl8723be_mod_params.msi_support, bool, 0444); | |
| 388 | 389 | module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog, |
| 389 | 390 | bool, 0444); |
| 390 | 391 | MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n"); |
| @@ -61,6 +61,12 @@ void xenvif_skb_zerocopy_prepare(struct xenvif_queue *queue, · 60 unmodified lines | ||
| 61 | 61 | void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue) |
| 62 | 62 | { |
| 63 | 63 | atomic_dec(&queue->inflight_packets); |
| 64 | + | |
| 65 | + /* Wake the dealloc thread _after_ decrementing inflight_packets so | |
| 66 | + * that if kthread_stop() has already been called, the dealloc thread | |
| 67 | + * does not wait forever with nothing to wake it. | |
| 68 | + */ | |
| 69 | + wake_up(&queue->dealloc_wq); | |
| 64 | 70 | } |
| 65 | 71 | |
| 66 | 72 | int xenvif_schedulable(struct xenvif *vif) |
| @@ -810,23 +810,17 @@ static inline struct sk_buff *xenvif_alloc_skb(unsigned int size) · 809 unmodified lines | ||
| 810 | 810 | static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif_queue *queue, |
| 811 | 811 | struct sk_buff *skb, |
| 812 | 812 | struct xen_netif_tx_request *txp, |
| 813 | − struct gnttab_map_grant_ref *gop) | |
| 813 | + struct gnttab_map_grant_ref *gop, | |
| 814 | + unsigned int frag_overflow, | |
| 815 | + struct sk_buff *nskb) | |
| 814 | 816 | { |
| 815 | 817 | struct skb_shared_info *shinfo = skb_shinfo(skb); |
| 816 | 818 | skb_frag_t *frags = shinfo->frags; |
| 817 | 819 | u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; |
| 818 | 820 | int start; |
| 819 | 821 | pending_ring_idx_t index; |
| 820 | − unsigned int nr_slots, frag_overflow = 0; | |
| 822 | + unsigned int nr_slots; | |
| 821 | 823 | |
| 822 | − /* At this point shinfo->nr_frags is in fact the number of | |
| 823 | − * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. | |
| 824 | − */ | |
| 825 | − if (shinfo->nr_frags > MAX_SKB_FRAGS) { | |
| 826 | − frag_overflow = shinfo->nr_frags - MAX_SKB_FRAGS; | |
| 827 | − BUG_ON(frag_overflow > MAX_SKB_FRAGS); | |
| 828 | − shinfo->nr_frags = MAX_SKB_FRAGS; | |
| 829 | − } | |
| 830 | 824 | nr_slots = shinfo->nr_frags; |
| 831 | 825 | |
| 832 | 826 | /* Skip first skb fragment if it is on same page as header fragment. */ |
| @@ -841,13 +835,6 @@ static struct gnttab_map_grant_ref *xenvif_get_requests(struct xenvif_queue *que · 8 unmodified lines | ||
| 841 | 835 | } |
| 842 | 836 | |
| 843 | 837 | if (frag_overflow) { |
| 844 | − struct sk_buff *nskb = xenvif_alloc_skb(0); | |
| 845 | − if (unlikely(nskb == NULL)) { | |
| 846 | − if (net_ratelimit()) | |
| 847 | − netdev_err(queue->vif->dev, | |
| 848 | − "Can't allocate the frag_list skb.\n"); | |
| 849 | − return NULL; | |
| 850 | − } | |
| 851 | 838 | |
| 852 | 839 | shinfo = skb_shinfo(nskb); |
| 853 | 840 | frags = shinfo->frags; |
| @@ -1175,9 +1162,10 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 321 unmodified lines | ||
| 1175 | 1162 | unsigned *copy_ops, |
| 1176 | 1163 | unsigned *map_ops) |
| 1177 | 1164 | { |
| 1178 | − struct gnttab_map_grant_ref *gop = queue->tx_map_ops, *request_gop; | |
| 1179 | − struct sk_buff *skb; | |
| 1165 | + struct gnttab_map_grant_ref *gop = queue->tx_map_ops; | |
| 1166 | + struct sk_buff *skb, *nskb; | |
| 1180 | 1167 | int ret; |
| 1168 | + unsigned int frag_overflow; | |
| 1181 | 1169 | |
| 1182 | 1170 | while (skb_queue_len(&queue->tx_queue) < budget) { |
| 1183 | 1171 | struct xen_netif_tx_request txreq; |
| @@ -1265,6 +1253,29 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 81 unmodified lines | ||
| 1265 | 1253 | break; |
| 1266 | 1254 | } |
| 1267 | 1255 | |
| 1256 | + skb_shinfo(skb)->nr_frags = ret; | |
| 1257 | + if (data_len < txreq.size) | |
| 1258 | + skb_shinfo(skb)->nr_frags++; | |
| 1259 | + /* At this point shinfo->nr_frags is in fact the number of | |
| 1260 | + * slots, which can be as large as XEN_NETBK_LEGACY_SLOTS_MAX. | |
| 1261 | + */ | |
| 1262 | + frag_overflow = 0; | |
| 1263 | + nskb = NULL; | |
| 1264 | + if (skb_shinfo(skb)->nr_frags > MAX_SKB_FRAGS) { | |
| 1265 | + frag_overflow = skb_shinfo(skb)->nr_frags - MAX_SKB_FRAGS; | |
| 1266 | + BUG_ON(frag_overflow > MAX_SKB_FRAGS); | |
| 1267 | + skb_shinfo(skb)->nr_frags = MAX_SKB_FRAGS; | |
| 1268 | + nskb = xenvif_alloc_skb(0); | |
| 1269 | + if (unlikely(nskb == NULL)) { | |
| 1270 | + kfree_skb(skb); | |
| 1271 | + xenvif_tx_err(queue, &txreq, idx); | |
| 1272 | + if (net_ratelimit()) | |
| 1273 | + netdev_err(queue->vif->dev, | |
| 1274 | + "Can't allocate the frag_list skb.\n"); | |
| 1275 | + break; | |
| 1276 | + } | |
| 1277 | + } | |
| 1278 | + | |
| 1268 | 1279 | if (extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) { |
| 1269 | 1280 | struct xen_netif_extra_info *gso; |
| 1270 | 1281 | gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1]; |
| @@ -1272,6 +1283,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 1 unmodified line | ||
| 1272 | 1283 | if (xenvif_set_skb_gso(queue->vif, skb, gso)) { |
| 1273 | 1284 | /* Failure in xenvif_set_skb_gso is fatal. */ |
| 1274 | 1285 | kfree_skb(skb); |
| 1286 | + kfree_skb(nskb); | |
| 1275 | 1287 | break; |
| 1276 | 1288 | } |
| 1277 | 1289 | } |
| @@ -1294,9 +1306,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 16 unmodified lines | ||
| 1294 | 1306 | |
| 1295 | 1307 | (*copy_ops)++; |
| 1296 | 1308 | |
| 1297 | − skb_shinfo(skb)->nr_frags = ret; | |
| 1298 | 1309 | if (data_len < txreq.size) { |
| 1299 | − skb_shinfo(skb)->nr_frags++; | |
| 1300 | 1310 | frag_set_pending_idx(&skb_shinfo(skb)->frags[0], |
| 1301 | 1311 | pending_idx); |
| 1302 | 1312 | xenvif_tx_create_map_op(queue, pending_idx, &txreq, gop); |
| @@ -1310,13 +1320,8 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue, · 7 unmodified lines | ||
| 1310 | 1320 | |
| 1311 | 1321 | queue->pending_cons++; |
| 1312 | 1322 | |
| 1313 | − request_gop = xenvif_get_requests(queue, skb, txfrags, gop); | |
| 1314 | − if (request_gop == NULL) { | |
| 1315 | − kfree_skb(skb); | |
| 1316 | − xenvif_tx_err(queue, &txreq, idx); | |
| 1317 | − break; | |
| 1318 | − } | |
| 1319 | − gop = request_gop; | |
| 1323 | + gop = xenvif_get_requests(queue, skb, txfrags, gop, | |
| 1324 | + frag_overflow, nskb); | |
| 1320 | 1325 | |
| 1321 | 1326 | __skb_queue_tail(&queue->tx_queue, skb); |
| 1322 | 1327 | |
| @@ -1536,7 +1541,6 @@ void xenvif_zerocopy_callback(struct ubuf_info *ubuf, bool zerocopy_success) · 213 unmodified lines | ||
| 1536 | 1541 | smp_wmb(); |
| 1537 | 1542 | queue->dealloc_prod++; |
| 1538 | 1543 | } while (ubuf); |
| 1539 | − wake_up(&queue->dealloc_wq); | |
| 1540 | 1544 | spin_unlock_irqrestore(&queue->callback_lock, flags); |
| 1541 | 1545 | |
| 1542 | 1546 | if (likely(zerocopy_success)) |
| @@ -114,7 +114,7 @@ int ntb_register_device(struct ntb_dev *ntb) · 113 unmodified lines | ||
| 114 | 114 | ntb->dev.bus = &ntb_bus; |
| 115 | 115 | ntb->dev.parent = &ntb->pdev->dev; |
| 116 | 116 | ntb->dev.release = ntb_dev_release; |
| 117 | − dev_set_name(&ntb->dev, pci_name(ntb->pdev)); | |
| 117 | + dev_set_name(&ntb->dev, "%s", pci_name(ntb->pdev)); | |
| 118 | 118 | |
| 119 | 119 | ntb->ctx = NULL; |
| 120 | 120 | ntb->ctx_ops = NULL; |
| @@ -142,10 +142,11 @@ struct ntb_transport_qp { · 141 unmodified lines | ||
| 142 | 142 | |
| 143 | 143 | void (*rx_handler)(struct ntb_transport_qp *qp, void *qp_data, |
| 144 | 144 | void *data, int len); |
| 145 | + struct list_head rx_post_q; | |
| 145 | 146 | struct list_head rx_pend_q; |
| 146 | 147 | struct list_head rx_free_q; |
| 147 | − spinlock_t ntb_rx_pend_q_lock; | |
| 148 | − spinlock_t ntb_rx_free_q_lock; | |
| 148 | + /* ntb_rx_q_lock: synchronize access to rx_XXXX_q */ | |
| 149 | + spinlock_t ntb_rx_q_lock; | |
| 149 | 150 | void *rx_buff; |
| 150 | 151 | unsigned int rx_index; |
| 151 | 152 | unsigned int rx_max_entry; |
| @@ -211,6 +212,8 @@ struct ntb_transport_ctx { · 59 unmodified lines | ||
| 211 | 212 | bool link_is_up; |
| 212 | 213 | struct delayed_work link_work; |
| 213 | 214 | struct work_struct link_cleanup; |
| 215 | + | |
| 216 | + struct dentry *debugfs_node_dir; | |
| 214 | 217 | }; |
| 215 | 218 | |
| 216 | 219 | enum { |
| @@ -436,13 +439,17 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, · 219 unmodified lines | ||
| 436 | 439 | char *buf; |
| 437 | 440 | ssize_t ret, out_offset, out_count; |
| 438 | 441 | |
| 442 | + qp = filp->private_data; | |
| 443 | + | |
| 444 | + if (!qp || !qp->link_is_up) | |
| 445 | + return 0; | |
| 446 | + | |
| 439 | 447 | out_count = 1000; |
| 440 | 448 | |
| 441 | 449 | buf = kmalloc(out_count, GFP_KERNEL); |
| 442 | 450 | if (!buf) |
| 443 | 451 | return -ENOMEM; |
| 444 | 452 | |
| 445 | − qp = filp->private_data; | |
| 446 | 453 | out_offset = 0; |
| 447 | 454 | out_offset += snprintf(buf + out_offset, out_count - out_offset, |
| 448 | 455 | "NTB QP stats\n"); |
| @@ -534,6 +541,27 @@ out: · 85 unmodified lines | ||
| 534 | 541 | return entry; |
| 535 | 542 | } |
| 536 | 543 | |
| 544 | +static struct ntb_queue_entry *ntb_list_mv(spinlock_t *lock, | |
| 545 | + struct list_head *list, | |
| 546 | + struct list_head *to_list) | |
| 547 | +{ | |
| 548 | + struct ntb_queue_entry *entry; | |
| 549 | + unsigned long flags; | |
| 550 | + | |
| 551 | + spin_lock_irqsave(lock, flags); | |
| 552 | + | |
| 553 | + if (list_empty(list)) { | |
| 554 | + entry = NULL; | |
| 555 | + } else { | |
| 556 | + entry = list_first_entry(list, struct ntb_queue_entry, entry); | |
| 557 | + list_move_tail(&entry->entry, to_list); | |
| 558 | + } | |
| 559 | + | |
| 560 | + spin_unlock_irqrestore(lock, flags); | |
| 561 | + | |
| 562 | + return entry; | |
| 563 | +} | |
| 564 | + | |
| 537 | 565 | static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt, |
| 538 | 566 | unsigned int qp_num) |
| 539 | 567 | { |
| @@ -601,13 +629,16 @@ static void ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw) · 61 unmodified lines | ||
| 601 | 629 | } |
| 602 | 630 | |
| 603 | 631 | static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, |
| 604 | − unsigned int size) | |
| 632 | + resource_size_t size) | |
| 605 | 633 | { |
| 606 | 634 | struct ntb_transport_mw *mw = &nt->mw_vec[num_mw]; |
| 607 | 635 | struct pci_dev *pdev = nt->ndev->pdev; |
| 608 | − unsigned int xlat_size, buff_size; | |
| 636 | + size_t xlat_size, buff_size; | |
| 609 | 637 | int rc; |
| 610 | 638 | |
| 639 | + if (!size) | |
| 640 | + return -EINVAL; | |
| 641 | + | |
| 611 | 642 | xlat_size = round_up(size, mw->xlat_align_size); |
| 612 | 643 | buff_size = round_up(size, mw->xlat_align); |
| 613 | 644 | |
| @@ -627,7 +658,7 @@ static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw, · 13 unmodified lines | ||
| 627 | 658 | if (!mw->virt_addr) { |
| 628 | 659 | mw->xlat_size = 0; |
| 629 | 660 | mw->buff_size = 0; |
| 630 | − dev_err(&pdev->dev, "Unable to alloc MW buff of size %d\n", | |
| 661 | + dev_err(&pdev->dev, "Unable to alloc MW buff of size %zu\n", | |
| 631 | 662 | buff_size); |
| 632 | 663 | return -ENOMEM; |
| 633 | 664 | } |
| @@ -867,6 +898,8 @@ static void ntb_qp_link_work(struct work_struct *work) · 233 unmodified lines | ||
| 867 | 898 | |
| 868 | 899 | if (qp->event_handler) |
| 869 | 900 | qp->event_handler(qp->cb_data, qp->link_is_up); |
| 901 | + | |
| 902 | + tasklet_schedule(&qp->rxc_db_work); | |
| 870 | 903 | } else if (nt->link_is_up) |
| 871 | 904 | schedule_delayed_work(&qp->link_work, |
| 872 | 905 | msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT)); |
| @@ -923,12 +956,12 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, · 50 unmodified lines | ||
| 923 | 956 | qp->tx_max_frame = min(transport_mtu, tx_size / 2); |
| 924 | 957 | qp->tx_max_entry = tx_size / qp->tx_max_frame; |
| 925 | 958 | |
| 926 | − if (nt_debugfs_dir) { | |
| 959 | + if (nt->debugfs_node_dir) { | |
| 927 | 960 | char debugfs_name[4]; |
| 928 | 961 | |
| 929 | 962 | snprintf(debugfs_name, 4, "qp%d", qp_num); |
| 930 | 963 | qp->debugfs_dir = debugfs_create_dir(debugfs_name, |
| 931 | − nt_debugfs_dir); | |
| 964 | + nt->debugfs_node_dir); | |
| 932 | 965 | |
| 933 | 966 | qp->debugfs_stats = debugfs_create_file("stats", S_IRUSR, |
| 934 | 967 | qp->debugfs_dir, qp, |
| @@ -941,10 +974,10 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, · 6 unmodified lines | ||
| 941 | 974 | INIT_DELAYED_WORK(&qp->link_work, ntb_qp_link_work); |
| 942 | 975 | INIT_WORK(&qp->link_cleanup, ntb_qp_link_cleanup_work); |
| 943 | 976 | |
| 944 | − spin_lock_init(&qp->ntb_rx_pend_q_lock); | |
| 945 | − spin_lock_init(&qp->ntb_rx_free_q_lock); | |
| 977 | + spin_lock_init(&qp->ntb_rx_q_lock); | |
| 946 | 978 | spin_lock_init(&qp->ntb_tx_free_q_lock); |
| 947 | 979 | |
| 980 | + INIT_LIST_HEAD(&qp->rx_post_q); | |
| 948 | 981 | INIT_LIST_HEAD(&qp->rx_pend_q); |
| 949 | 982 | INIT_LIST_HEAD(&qp->rx_free_q); |
| 950 | 983 | INIT_LIST_HEAD(&qp->tx_free_q); |
| @@ -1031,6 +1064,12 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) · 80 unmodified lines | ||
| 1031 | 1064 | goto err2; |
| 1032 | 1065 | } |
| 1033 | 1066 | |
| 1067 | + if (nt_debugfs_dir) { | |
| 1068 | + nt->debugfs_node_dir = | |
| 1069 | + debugfs_create_dir(pci_name(ndev->pdev), | |
| 1070 | + nt_debugfs_dir); | |
| 1071 | + } | |
| 1072 | + | |
| 1034 | 1073 | for (i = 0; i < qp_count; i++) { |
| 1035 | 1074 | rc = ntb_transport_init_queue(nt, i); |
| 1036 | 1075 | if (rc) |
| @@ -1107,22 +1146,47 @@ static void ntb_transport_free(struct ntb_client *self, struct ntb_dev *ndev) · 70 unmodified lines | ||
| 1107 | 1146 | kfree(nt); |
| 1108 | 1147 | } |
| 1109 | 1148 | |
| 1110 | −static void ntb_rx_copy_callback(void *data) | |
| 1149 | +static void ntb_complete_rxc(struct ntb_transport_qp *qp) | |
| 1111 | 1150 | { |
| 1112 | − struct ntb_queue_entry *entry = data; | |
| 1113 | − struct ntb_transport_qp *qp = entry->qp; | |
| 1114 | − void *cb_data = entry->cb_data; | |
| 1115 | − unsigned int len = entry->len; | |
| 1116 | − struct ntb_payload_header *hdr = entry->rx_hdr; | |
| 1151 | + struct ntb_queue_entry *entry; | |
| 1152 | + void *cb_data; | |
| 1153 | + unsigned int len; | |
| 1154 | + unsigned long irqflags; | |
| 1155 | + | |
| 1156 | + spin_lock_irqsave(&qp->ntb_rx_q_lock, irqflags); | |
| 1157 | + | |
| 1158 | + while (!list_empty(&qp->rx_post_q)) { | |
| 1159 | + entry = list_first_entry(&qp->rx_post_q, | |
| 1160 | + struct ntb_queue_entry, entry); | |
| 1161 | + if (!(entry->flags & DESC_DONE_FLAG)) | |
| 1162 | + break; | |
| 1163 | + | |
| 1164 | + entry->rx_hdr->flags = 0; | |
| 1165 | + iowrite32(entry->index, &qp->rx_info->entry); | |
| 1117 | 1166 | |
| 1118 | − hdr->flags = 0; | |
| 1167 | + cb_data = entry->cb_data; | |
| 1168 | + len = entry->len; | |
| 1119 | 1169 | |
| 1120 | − iowrite32(entry->index, &qp->rx_info->entry); | |
| 1170 | + list_move_tail(&entry->entry, &qp->rx_free_q); | |
| 1121 | 1171 | |
| 1122 | − ntb_list_add(&qp->ntb_rx_free_q_lock, &entry->entry, &qp->rx_free_q); | |
| 1172 | + spin_unlock_irqrestore(&qp->ntb_rx_q_lock, irqflags); | |
| 1123 | 1173 | |
| 1124 | − if (qp->rx_handler && qp->client_ready) | |
| 1125 | − qp->rx_handler(qp, qp->cb_data, cb_data, len); | |
| 1174 | + if (qp->rx_handler && qp->client_ready) | |
| 1175 | + qp->rx_handler(qp, qp->cb_data, cb_data, len); | |
| 1176 | + | |
| 1177 | + spin_lock_irqsave(&qp->ntb_rx_q_lock, irqflags); | |
| 1178 | + } | |
| 1179 | + | |
| 1180 | + spin_unlock_irqrestore(&qp->ntb_rx_q_lock, irqflags); | |
| 1181 | +} | |
| 1182 | + | |
| 1183 | +static void ntb_rx_copy_callback(void *data) | |
| 1184 | +{ | |
| 1185 | + struct ntb_queue_entry *entry = data; | |
| 1186 | + | |
| 1187 | + entry->flags |= DESC_DONE_FLAG; | |
| 1188 | + | |
| 1189 | + ntb_complete_rxc(entry->qp); | |
| 1126 | 1190 | } |
| 1127 | 1191 | |
| 1128 | 1192 | static void ntb_memcpy_rx(struct ntb_queue_entry *entry, void *offset) |
| @@ -1138,19 +1202,18 @@ static void ntb_memcpy_rx(struct ntb_queue_entry *entry, void *offset) · 9 unmodified lines | ||
| 1138 | 1202 | ntb_rx_copy_callback(entry); |
| 1139 | 1203 | } |
| 1140 | 1204 | |
| 1141 | −static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset, | |
| 1142 | − size_t len) | |
| 1205 | +static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset) | |
| 1143 | 1206 | { |
| 1144 | 1207 | struct dma_async_tx_descriptor *txd; |
| 1145 | 1208 | struct ntb_transport_qp *qp = entry->qp; |
| 1146 | 1209 | struct dma_chan *chan = qp->dma_chan; |
| 1147 | 1210 | struct dma_device *device; |
| 1148 | − size_t pay_off, buff_off; | |
| 1211 | + size_t pay_off, buff_off, len; | |
| 1149 | 1212 | struct dmaengine_unmap_data *unmap; |
| 1150 | 1213 | dma_cookie_t cookie; |
| 1151 | 1214 | void *buf = entry->buf; |
| 1152 | 1215 | |
| 1153 | − entry->len = len; | |
| 1216 | + len = entry->len; | |
| 1154 | 1217 | |
| 1155 | 1218 | if (!chan) |
| 1156 | 1219 | goto err; |
| @@ -1226,7 +1289,6 @@ static int ntb_process_rxc(struct ntb_transport_qp *qp) · 69 unmodified lines | ||
| 1226 | 1289 | struct ntb_payload_header *hdr; |
| 1227 | 1290 | struct ntb_queue_entry *entry; |
| 1228 | 1291 | void *offset; |
| 1229 | − int rc; | |
| 1230 | 1292 | |
| 1231 | 1293 | offset = qp->rx_buff + qp->rx_max_frame * qp->rx_index; |
| 1232 | 1294 | hdr = offset + qp->rx_max_frame - sizeof(struct ntb_payload_header); |
| @@ -1255,65 +1317,43 @@ static int ntb_process_rxc(struct ntb_transport_qp *qp) · 22 unmodified lines | ||
| 1255 | 1317 | return -EIO; |
| 1256 | 1318 | } |
| 1257 | 1319 | |
| 1258 | − entry = ntb_list_rm(&qp->ntb_rx_pend_q_lock, &qp->rx_pend_q); | |
| 1320 | + entry = ntb_list_mv(&qp->ntb_rx_q_lock, &qp->rx_pend_q, &qp->rx_post_q); | |
| 1259 | 1321 | if (!entry) { |
| 1260 | 1322 | dev_dbg(&qp->ndev->pdev->dev, "no receive buffer\n"); |
| 1261 | 1323 | qp->rx_err_no_buf++; |
| 1262 | − | |
| 1263 | − rc = -ENOMEM; | |
| 1264 | − goto err; | |
| 1324 | + return -EAGAIN; | |
| 1265 | 1325 | } |
| 1266 | 1326 | |
| 1327 | + entry->rx_hdr = hdr; | |
| 1328 | + entry->index = qp->rx_index; | |
| 1329 | + | |
| 1267 | 1330 | if (hdr->len > entry->len) { |
| 1268 | 1331 | dev_dbg(&qp->ndev->pdev->dev, |
| 1269 | 1332 | "receive buffer overflow! Wanted %d got %d\n", |
| 1270 | 1333 | hdr->len, entry->len); |
| 1271 | 1334 | qp->rx_err_oflow++; |
| 1272 | 1335 | |
| 1273 | − rc = -EIO; | |
| 1274 | − goto err; | |
| 1275 | − } | |
| 1336 | + entry->len = -EIO; | |
| 1337 | + entry->flags |= DESC_DONE_FLAG; | |
| 1276 | 1338 | |
| 1277 | − dev_dbg(&qp->ndev->pdev->dev, | |
| 1278 | − "RX OK index %u ver %u size %d into buf size %d\n", | |
| 1279 | − qp->rx_index, hdr->ver, hdr->len, entry->len); | |
| 1339 | + ntb_complete_rxc(qp); | |
| 1340 | + } else { | |
| 1341 | + dev_dbg(&qp->ndev->pdev->dev, | |
| 1342 | + "RX OK index %u ver %u size %d into buf size %d\n", | |
| 1343 | + qp->rx_index, hdr->ver, hdr->len, entry->len); | |
| 1280 | 1344 | |
| 1281 | − qp->rx_bytes += hdr->len; | |
| 1282 | − qp->rx_pkts++; | |
| 1345 | + qp->rx_bytes += hdr->len; | |
| 1346 | + qp->rx_pkts++; | |
| 1283 | 1347 | |
| 1284 | − entry->index = qp->rx_index; | |
| 1285 | − entry->rx_hdr = hdr; | |
| 1348 | + entry->len = hdr->len; | |
| 1286 | 1349 | |
| 1287 | − ntb_async_rx(entry, offset, hdr->len); | |
| 1350 | + ntb_async_rx(entry, offset); | |
| 1351 | + } | |
| 1288 | 1352 | |
| 1289 | 1353 | qp->rx_index++; |
| 1290 | 1354 | qp->rx_index %= qp->rx_max_entry; |
| 1291 | 1355 | |
| 1292 | 1356 | return 0; |
| 1293 | − | |
| 1294 | −err: | |
| 1295 | − /* FIXME: if this syncrhonous update of the rx_index gets ahead of | |
| 1296 | − * asyncrhonous ntb_rx_copy_callback of previous entry, there are three | |
| 1297 | − * scenarios: | |
| 1298 | − * | |
| 1299 | − * 1) The peer might miss this update, but observe the update | |
| 1300 | − * from the memcpy completion callback. In this case, the buffer will | |
| 1301 | − * not be freed on the peer to be reused for a different packet. The | |
| 1302 | − * successful rx of a later packet would clear the condition, but the | |
| 1303 | − * condition could persist if several rx fail in a row. | |
| 1304 | − * | |
| 1305 | − * 2) The peer may observe this update before the asyncrhonous copy of | |
| 1306 | − * prior packets is completed. The peer may overwrite the buffers of | |
| 1307 | − * the prior packets before they are copied. | |
| 1308 | − * | |
| 1309 | − * 3) Both: the peer may observe the update, and then observe the index | |
| 1310 | − * decrement by the asynchronous completion callback. Who knows what | |
| 1311 | − * badness that will cause. | |
| 1312 | − */ | |
| 1313 | − hdr->flags = 0; | |
| 1314 | − iowrite32(qp->rx_index, &qp->rx_info->entry); | |
| 1315 | − | |
| 1316 | − return rc; | |
| 1317 | 1357 | } |
| 1318 | 1358 | |
| 1319 | 1359 | static void ntb_transport_rxc_db(unsigned long data) |
| @@ -1333,7 +1373,7 @@ static void ntb_transport_rxc_db(unsigned long data) · 13 unmodified lines | ||
| 1333 | 1373 | break; |
| 1334 | 1374 | } |
| 1335 | 1375 | |
| 1336 | − if (qp->dma_chan) | |
| 1376 | + if (i && qp->dma_chan) | |
| 1337 | 1377 | dma_async_issue_pending(qp->dma_chan); |
| 1338 | 1378 | |
| 1339 | 1379 | if (i == qp->rx_max_entry) { |
| @@ -1609,7 +1649,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev, · 269 unmodified lines | ||
| 1609 | 1649 | goto err1; |
| 1610 | 1650 | |
| 1611 | 1651 | entry->qp = qp; |
| 1612 | − ntb_list_add(&qp->ntb_rx_free_q_lock, &entry->entry, | |
| 1652 | + ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry, | |
| 1613 | 1653 | &qp->rx_free_q); |
| 1614 | 1654 | } |
| 1615 | 1655 | |
| @@ -1634,7 +1674,7 @@ err2: · 18 unmodified lines | ||
| 1634 | 1674 | while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q))) |
| 1635 | 1675 | kfree(entry); |
| 1636 | 1676 | err1: |
| 1637 | − while ((entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q))) | |
| 1677 | + while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q))) | |
| 1638 | 1678 | kfree(entry); |
| 1639 | 1679 | if (qp->dma_chan) |
| 1640 | 1680 | dma_release_channel(qp->dma_chan); |
| @@ -1652,7 +1692,6 @@ EXPORT_SYMBOL_GPL(ntb_transport_create_queue); · 11 unmodified lines | ||
| 1652 | 1692 | */ |
| 1653 | 1693 | void ntb_transport_free_queue(struct ntb_transport_qp *qp) |
| 1654 | 1694 | { |
| 1655 | − struct ntb_transport_ctx *nt = qp->transport; | |
| 1656 | 1695 | struct pci_dev *pdev; |
| 1657 | 1696 | struct ntb_queue_entry *entry; |
| 1658 | 1697 | u64 qp_bit; |
| @@ -1689,18 +1728,23 @@ void ntb_transport_free_queue(struct ntb_transport_qp *qp) · 30 unmodified lines | ||
| 1689 | 1728 | qp->tx_handler = NULL; |
| 1690 | 1729 | qp->event_handler = NULL; |
| 1691 | 1730 | |
| 1692 | − while ((entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q))) | |
| 1731 | + while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q))) | |
| 1693 | 1732 | kfree(entry); |
| 1694 | 1733 | |
| 1695 | − while ((entry = ntb_list_rm(&qp->ntb_rx_pend_q_lock, &qp->rx_pend_q))) { | |
| 1696 | − dev_warn(&pdev->dev, "Freeing item from a non-empty queue\n"); | |
| 1734 | + while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_pend_q))) { | |
| 1735 | + dev_warn(&pdev->dev, "Freeing item from non-empty rx_pend_q\n"); | |
| 1736 | + kfree(entry); | |
| 1737 | + } | |
| 1738 | + | |
| 1739 | + while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_post_q))) { | |
| 1740 | + dev_warn(&pdev->dev, "Freeing item from non-empty rx_post_q\n"); | |
| 1697 | 1741 | kfree(entry); |
| 1698 | 1742 | } |
| 1699 | 1743 | |
| 1700 | 1744 | while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q))) |
| 1701 | 1745 | kfree(entry); |
| 1702 | 1746 | |
| 1703 | − nt->qp_bitmap_free |= qp_bit; | |
| 1747 | + qp->transport->qp_bitmap_free |= qp_bit; | |
| 1704 | 1748 | |
| 1705 | 1749 | dev_info(&pdev->dev, "NTB Transport QP %d freed\n", qp->qp_num); |
| 1706 | 1750 | } |
| @@ -1724,14 +1768,14 @@ void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len) · 17 unmodified lines | ||
| 1724 | 1768 | if (!qp || qp->client_ready) |
| 1725 | 1769 | return NULL; |
| 1726 | 1770 | |
| 1727 | − entry = ntb_list_rm(&qp->ntb_rx_pend_q_lock, &qp->rx_pend_q); | |
| 1771 | + entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_pend_q); | |
| 1728 | 1772 | if (!entry) |
| 1729 | 1773 | return NULL; |
| 1730 | 1774 | |
| 1731 | 1775 | buf = entry->cb_data; |
| 1732 | 1776 | *len = entry->len; |
| 1733 | 1777 | |
| 1734 | − ntb_list_add(&qp->ntb_rx_free_q_lock, &entry->entry, &qp->rx_free_q); | |
| 1778 | + ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry, &qp->rx_free_q); | |
| 1735 | 1779 | |
| 1736 | 1780 | return buf; |
| 1737 | 1781 | } |
| @@ -1757,15 +1801,18 @@ int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, · 19 unmodified lines | ||
| 1757 | 1801 | if (!qp) |
| 1758 | 1802 | return -EINVAL; |
| 1759 | 1803 | |
| 1760 | − entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q); | |
| 1804 | + entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q); | |
| 1761 | 1805 | if (!entry) |
| 1762 | 1806 | return -ENOMEM; |
| 1763 | 1807 | |
| 1764 | 1808 | entry->cb_data = cb; |
| 1765 | 1809 | entry->buf = data; |
| 1766 | 1810 | entry->len = len; |
| 1811 | + entry->flags = 0; | |
| 1812 | + | |
| 1813 | + ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry, &qp->rx_pend_q); | |
| 1767 | 1814 | |
| 1768 | − ntb_list_add(&qp->ntb_rx_pend_q_lock, &entry->entry, &qp->rx_pend_q); | |
| 1815 | + tasklet_schedule(&qp->rxc_db_work); | |
| 1769 | 1816 | |
| 1770 | 1817 | return 0; |
| 1771 | 1818 | } |
| @@ -212,6 +212,7 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled) · 211 unmodified lines | ||
| 212 | 212 | |
| 213 | 213 | sun4i_usb_phy_write(phy, PHY_SQUELCH_DETECT, enabled ? 0 : 2, 2); |
| 214 | 214 | } |
| 215 | +EXPORT_SYMBOL_GPL(sun4i_usb_phy_set_squelch_detect); | |
| 215 | 216 | |
| 216 | 217 | static struct phy_ops sun4i_usb_phy_ops = { |
| 217 | 218 | .init = sun4i_usb_phy_init, |
| @@ -28,6 +28,8 @@ · 27 unmodified lines | ||
| 28 | 28 | #include <linux/delay.h> |
| 29 | 29 | #include <linux/phy/omap_control_phy.h> |
| 30 | 30 | #include <linux/of_platform.h> |
| 31 | +#include <linux/mfd/syscon.h> | |
| 32 | +#include <linux/regmap.h> | |
| 31 | 33 | |
| 32 | 34 | #define PLL_STATUS 0x00000004 |
| 33 | 35 | #define PLL_GO 0x00000008 |
| @@ -52,6 +54,8 @@ · 18 unmodified lines | ||
| 52 | 54 | #define PLL_LOCK 0x2 |
| 53 | 55 | #define PLL_IDLE 0x1 |
| 54 | 56 | |
| 57 | +#define SATA_PLL_SOFT_RESET BIT(18) | |
| 58 | + | |
| 55 | 59 | /* |
| 56 | 60 | * This is an Empirical value that works, need to confirm the actual |
| 57 | 61 | * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status |
| @@ -82,6 +86,9 @@ struct ti_pipe3 { · 24 unmodified lines | ||
| 82 | 86 | struct clk *refclk; |
| 83 | 87 | struct clk *div_clk; |
| 84 | 88 | struct pipe3_dpll_map *dpll_map; |
| 89 | + struct regmap *dpll_reset_syscon; /* ctrl. reg. acces */ | |
| 90 | + unsigned int dpll_reset_reg; /* reg. index within syscon */ | |
| 91 | + bool sata_refclk_enabled; | |
| 85 | 92 | }; |
| 86 | 93 | |
| 87 | 94 | static struct pipe3_dpll_map dpll_map_usb[] = { |
| @@ -249,8 +256,11 @@ static int ti_pipe3_exit(struct phy *x) · 161 unmodified lines | ||
| 249 | 256 | u32 val; |
| 250 | 257 | unsigned long timeout; |
| 251 | 258 | |
| 252 | − /* SATA DPLL can't be powered down due to Errata i783 */ | |
| 253 | − if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata")) | |
| 259 | + /* If dpll_reset_syscon is not present we wont power down SATA DPLL | |
| 260 | + * due to Errata i783 | |
| 261 | + */ | |
| 262 | + if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata") && | |
| 263 | + !phy->dpll_reset_syscon) | |
| 254 | 264 | return 0; |
| 255 | 265 | |
| 256 | 266 | /* PCIe doesn't have internal DPLL */ |
| @@ -276,6 +286,14 @@ static int ti_pipe3_exit(struct phy *x) · 19 unmodified lines | ||
| 276 | 286 | } |
| 277 | 287 | } |
| 278 | 288 | |
| 289 | + /* i783: SATA needs control bit toggle after PLL unlock */ | |
| 290 | + if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata")) { | |
| 291 | + regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg, | |
| 292 | + SATA_PLL_SOFT_RESET, SATA_PLL_SOFT_RESET); | |
| 293 | + regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg, | |
| 294 | + SATA_PLL_SOFT_RESET, 0); | |
| 295 | + } | |
| 296 | + | |
| 279 | 297 | ti_pipe3_disable_clocks(phy); |
| 280 | 298 | |
| 281 | 299 | return 0; |
| @@ -350,6 +368,21 @@ static int ti_pipe3_probe(struct platform_device *pdev) · 68 unmodified lines | ||
| 350 | 368 | } |
| 351 | 369 | } else { |
| 352 | 370 | phy->wkupclk = ERR_PTR(-ENODEV); |
| 371 | + phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node, | |
| 372 | + "syscon-pllreset"); | |
| 373 | + if (IS_ERR(phy->dpll_reset_syscon)) { | |
| 374 | + dev_info(&pdev->dev, | |
| 375 | + "can't get syscon-pllreset, sata dpll won't idle\n"); | |
| 376 | + phy->dpll_reset_syscon = NULL; | |
| 377 | + } else { | |
| 378 | + if (of_property_read_u32_index(node, | |
| 379 | + "syscon-pllreset", 1, | |
| 380 | + &phy->dpll_reset_reg)) { | |
| 381 | + dev_err(&pdev->dev, | |
| 382 | + "couldn't get pllreset reg. offset\n"); | |
| 383 | + return -EINVAL; | |
| 384 | + } | |
| 385 | + } | |
| 353 | 386 | } |
| 354 | 387 | |
| 355 | 388 | if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) { |
| @@ -402,10 +435,16 @@ static int ti_pipe3_probe(struct platform_device *pdev) · 46 unmodified lines | ||
| 402 | 435 | |
| 403 | 436 | platform_set_drvdata(pdev, phy); |
| 404 | 437 | pm_runtime_enable(phy->dev); |
| 405 | − /* Prevent auto-disable of refclk for SATA PHY due to Errata i783 */ | |
| 406 | − if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) | |
| 407 | − if (!IS_ERR(phy->refclk)) | |
| 438 | + | |
| 439 | + /* | |
| 440 | + * Prevent auto-disable of refclk for SATA PHY due to Errata i783 | |
| 441 | + */ | |
| 442 | + if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) { | |
| 443 | + if (!IS_ERR(phy->refclk)) { | |
| 408 | 444 | clk_prepare_enable(phy->refclk); |
| 445 | + phy->sata_refclk_enabled = true; | |
| 446 | + } | |
| 447 | + } | |
| 409 | 448 | |
| 410 | 449 | generic_phy = devm_phy_create(phy->dev, NULL, &ops); |
| 411 | 450 | if (IS_ERR(generic_phy)) |
| @@ -472,8 +511,18 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy) · 60 unmodified lines | ||
| 472 | 511 | { |
| 473 | 512 | if (!IS_ERR(phy->wkupclk)) |
| 474 | 513 | clk_disable_unprepare(phy->wkupclk); |
| 475 | − if (!IS_ERR(phy->refclk)) | |
| 514 | + if (!IS_ERR(phy->refclk)) { | |
| 476 | 515 | clk_disable_unprepare(phy->refclk); |
| 516 | + /* | |
| 517 | + * SATA refclk needs an additional disable as we left it | |
| 518 | + * on in probe to avoid Errata i783 | |
| 519 | + */ | |
| 520 | + if (phy->sata_refclk_enabled) { | |
| 521 | + clk_disable_unprepare(phy->refclk); | |
| 522 | + phy->sata_refclk_enabled = false; | |
| 523 | + } | |
| 524 | + } | |
| 525 | + | |
| 477 | 526 | if (!IS_ERR(phy->div_clk)) |
| 478 | 527 | clk_disable_unprepare(phy->div_clk); |
| 479 | 528 | } |
| @@ -4,7 +4,6 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | menuconfig CHROME_PLATFORMS |
| 6 | 6 | bool "Platform support for Chrome hardware" |
| 7 | − depends on X86 || ARM | |
| 8 | 7 | ---help--- |
| 9 | 8 | Say Y here to get to see options for platform support for |
| 10 | 9 | various Chromebooks and Chromeboxes. This option alone does |
| @@ -599,9 +599,10 @@ static void ipr_trc_hook(struct ipr_cmnd *ipr_cmd, · 598 unmodified lines | ||
| 599 | 599 | { |
| 600 | 600 | struct ipr_trace_entry *trace_entry; |
| 601 | 601 | struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; |
| 602 | + unsigned int trace_index; | |
| 602 | 603 | |
| 603 | − trace_entry = &ioa_cfg->trace[atomic_add_return | |
| 604 | − (1, &ioa_cfg->trace_index)%IPR_NUM_TRACE_ENTRIES]; | |
| 604 | + trace_index = atomic_add_return(1, &ioa_cfg->trace_index) & IPR_TRACE_INDEX_MASK; | |
| 605 | + trace_entry = &ioa_cfg->trace[trace_index]; | |
| 605 | 606 | trace_entry->time = jiffies; |
| 606 | 607 | trace_entry->op_code = ipr_cmd->ioarcb.cmd_pkt.cdb[0]; |
| 607 | 608 | trace_entry->type = type; |
| @@ -1051,10 +1052,15 @@ static void ipr_send_blocking_cmd(struct ipr_cmnd *ipr_cmd, · 443 unmodified lines | ||
| 1051 | 1052 | |
| 1052 | 1053 | static int ipr_get_hrrq_index(struct ipr_ioa_cfg *ioa_cfg) |
| 1053 | 1054 | { |
| 1055 | + unsigned int hrrq; | |
| 1056 | + | |
| 1054 | 1057 | if (ioa_cfg->hrrq_num == 1) |
| 1055 | − return 0; | |
| 1056 | − else | |
| 1057 | − return (atomic_add_return(1, &ioa_cfg->hrrq_index) % (ioa_cfg->hrrq_num - 1)) + 1; | |
| 1058 | + hrrq = 0; | |
| 1059 | + else { | |
| 1060 | + hrrq = atomic_add_return(1, &ioa_cfg->hrrq_index); | |
| 1061 | + hrrq = (hrrq % (ioa_cfg->hrrq_num - 1)) + 1; | |
| 1062 | + } | |
| 1063 | + return hrrq; | |
| 1058 | 1064 | } |
| 1059 | 1065 | |
| 1060 | 1066 | /** |
| @@ -6263,21 +6269,23 @@ static void ipr_scsi_done(struct ipr_cmnd *ipr_cmd) · 5202 unmodified lines | ||
| 6263 | 6269 | struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; |
| 6264 | 6270 | struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd; |
| 6265 | 6271 | u32 ioasc = be32_to_cpu(ipr_cmd->s.ioasa.hdr.ioasc); |
| 6266 | − unsigned long hrrq_flags; | |
| 6272 | + unsigned long lock_flags; | |
| 6267 | 6273 | |
| 6268 | 6274 | scsi_set_resid(scsi_cmd, be32_to_cpu(ipr_cmd->s.ioasa.hdr.residual_data_len)); |
| 6269 | 6275 | |
| 6270 | 6276 | if (likely(IPR_IOASC_SENSE_KEY(ioasc) == 0)) { |
| 6271 | 6277 | scsi_dma_unmap(scsi_cmd); |
| 6272 | 6278 | |
| 6273 | − spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags); | |
| 6279 | + spin_lock_irqsave(ipr_cmd->hrrq->lock, lock_flags); | |
| 6274 | 6280 | list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q); |
| 6275 | 6281 | scsi_cmd->scsi_done(scsi_cmd); |
| 6276 | − spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags); | |
| 6282 | + spin_unlock_irqrestore(ipr_cmd->hrrq->lock, lock_flags); | |
| 6277 | 6283 | } else { |
| 6278 | − spin_lock_irqsave(ipr_cmd->hrrq->lock, hrrq_flags); | |
| 6284 | + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | |
| 6285 | + spin_lock(&ipr_cmd->hrrq->_lock); | |
| 6279 | 6286 | ipr_erp_start(ioa_cfg, ipr_cmd); |
| 6280 | − spin_unlock_irqrestore(ipr_cmd->hrrq->lock, hrrq_flags); | |
| 6287 | + spin_unlock(&ipr_cmd->hrrq->_lock); | |
| 6288 | + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | |
| 6281 | 6289 | } |
| 6282 | 6290 | } |
| 6283 | 6291 | |
| @@ -1486,6 +1486,7 @@ struct ipr_ioa_cfg { · 1485 unmodified lines | ||
| 1486 | 1486 | |
| 1487 | 1487 | #define IPR_NUM_TRACE_INDEX_BITS 8 |
| 1488 | 1488 | #define IPR_NUM_TRACE_ENTRIES (1 << IPR_NUM_TRACE_INDEX_BITS) |
| 1489 | +#define IPR_TRACE_INDEX_MASK (IPR_NUM_TRACE_ENTRIES - 1) | |
| 1489 | 1490 | #define IPR_TRACE_SIZE (sizeof(struct ipr_trace_entry) * IPR_NUM_TRACE_ENTRIES) |
| 1490 | 1491 | char trace_start[8]; |
| 1491 | 1492 | #define IPR_TRACE_START_LABEL "trace" |
| @@ -944,7 +944,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses, · 943 unmodified lines | ||
| 944 | 944 | scmd->sdb.length); |
| 945 | 945 | scmd->sdb.table.sgl = &ses->sense_sgl; |
| 946 | 946 | scmd->sc_data_direction = DMA_FROM_DEVICE; |
| 947 | − scmd->sdb.table.nents = 1; | |
| 947 | + scmd->sdb.table.nents = scmd->sdb.table.orig_nents = 1; | |
| 948 | 948 | scmd->cmnd[0] = REQUEST_SENSE; |
| 949 | 949 | scmd->cmnd[4] = scmd->sdb.length; |
| 950 | 950 | scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); |
| @@ -583,7 +583,7 @@ static struct scatterlist *scsi_sg_alloc(unsigned int nents, gfp_t gfp_mask) · 582 unmodified lines | ||
| 583 | 583 | |
| 584 | 584 | static void scsi_free_sgtable(struct scsi_data_buffer *sdb, bool mq) |
| 585 | 585 | { |
| 586 | − if (mq && sdb->table.nents <= SCSI_MAX_SG_SEGMENTS) | |
| 586 | + if (mq && sdb->table.orig_nents <= SCSI_MAX_SG_SEGMENTS) | |
| 587 | 587 | return; |
| 588 | 588 | __sg_free_table(&sdb->table, SCSI_MAX_SG_SEGMENTS, mq, scsi_sg_free); |
| 589 | 589 | } |
| @@ -597,8 +597,8 @@ static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents, bool mq) · 7 unmodified lines | ||
| 597 | 597 | |
| 598 | 598 | if (mq) { |
| 599 | 599 | if (nents <= SCSI_MAX_SG_SEGMENTS) { |
| 600 | − sdb->table.nents = nents; | |
| 601 | − sg_init_table(sdb->table.sgl, sdb->table.nents); | |
| 600 | + sdb->table.nents = sdb->table.orig_nents = nents; | |
| 601 | + sg_init_table(sdb->table.sgl, nents); | |
| 602 | 602 | return 0; |
| 603 | 603 | } |
| 604 | 604 | first_chunk = sdb->table.sgl; |
| @@ -1266,6 +1266,7 @@ static const struct das1800_board *das1800_probe(struct comedi_device *dev) · 1265 unmodified lines | ||
| 1266 | 1266 | if (index == das1801hc || index == das1802hc) |
| 1267 | 1267 | return board; |
| 1268 | 1268 | index = das1801hc; |
| 1269 | + break; | |
| 1269 | 1270 | default: |
| 1270 | 1271 | dev_err(dev->class_dev, |
| 1271 | 1272 | "Board model: probe returned 0x%x (unknown, please report)\n", |
| @@ -40,7 +40,7 @@ · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | #define DEBUG_SUBSYSTEM D_OTHER |
| 42 | 42 | |
| 43 | −#include <linux/unaligned/access_ok.h> | |
| 43 | +#include <asm/unaligned.h> | |
| 44 | 44 | |
| 45 | 45 | #include "../include/obd_support.h" |
| 46 | 46 | #include "../include/lustre_debug.h" |
| @@ -1483,8 +1483,9 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, · 1482 unmodified lines | ||
| 1483 | 1483 | } |
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | − if (changed & BSS_CHANGED_ASSOC && priv->op_mode != NL80211_IFTYPE_AP) { | |
| 1487 | − if (conf->assoc) { | |
| 1486 | + if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_BEACON_INFO) && | |
| 1487 | + priv->op_mode != NL80211_IFTYPE_AP) { | |
| 1488 | + if (conf->assoc && conf->beacon_rate) { | |
| 1488 | 1489 | CARDbUpdateTSF(priv, conf->beacon_rate->hw_value, |
| 1489 | 1490 | conf->sync_tsf); |
| 1490 | 1491 | |
| @@ -405,7 +405,6 @@ static SIMPLE_DEV_PM_OPS(hisi_thermal_pm_ops, · 404 unmodified lines | ||
| 405 | 405 | static struct platform_driver hisi_thermal_driver = { |
| 406 | 406 | .driver = { |
| 407 | 407 | .name = "hisi_thermal", |
| 408 | − .owner = THIS_MODULE, | |
| 409 | 408 | .pm = &hisi_thermal_pm_ops, |
| 410 | 409 | .of_match_table = of_hisi_thermal_match, |
| 411 | 410 | }, |
| @@ -229,7 +229,8 @@ static int allocate_power(struct thermal_zone_device *tz, · 228 unmodified lines | ||
| 229 | 229 | struct thermal_instance *instance; |
| 230 | 230 | struct power_allocator_params *params = tz->governor_data; |
| 231 | 231 | u32 *req_power, *max_power, *granted_power, *extra_actor_power; |
| 232 | − u32 total_req_power, max_allocatable_power; | |
| 232 | + u32 *weighted_req_power; | |
| 233 | + u32 total_req_power, max_allocatable_power, total_weighted_req_power; | |
| 233 | 234 | u32 total_granted_power, power_range; |
| 234 | 235 | int i, num_actors, total_weight, ret = 0; |
| 235 | 236 | int trip_max_desired_temperature = params->trip_max_desired_temperature; |
| @@ -247,16 +248,17 @@ static int allocate_power(struct thermal_zone_device *tz, · 11 unmodified lines | ||
| 247 | 248 | } |
| 248 | 249 | |
| 249 | 250 | /* |
| 250 | − * We need to allocate three arrays of the same size: | |
| 251 | − * req_power, max_power and granted_power. They are going to | |
| 252 | − * be needed until this function returns. Allocate them all | |
| 253 | − * in one go to simplify the allocation and deallocation | |
| 254 | − * logic. | |
| 251 | + * We need to allocate five arrays of the same size: | |
| 252 | + * req_power, max_power, granted_power, extra_actor_power and | |
| 253 | + * weighted_req_power. They are going to be needed until this | |
| 254 | + * function returns. Allocate them all in one go to simplify | |
| 255 | + * the allocation and deallocation logic. | |
| 255 | 256 | */ |
| 256 | 257 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*max_power)); |
| 257 | 258 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*granted_power)); |
| 258 | 259 | BUILD_BUG_ON(sizeof(*req_power) != sizeof(*extra_actor_power)); |
| 259 | − req_power = devm_kcalloc(&tz->device, num_actors * 4, | |
| 260 | + BUILD_BUG_ON(sizeof(*req_power) != sizeof(*weighted_req_power)); | |
| 261 | + req_power = devm_kcalloc(&tz->device, num_actors * 5, | |
| 260 | 262 | sizeof(*req_power), GFP_KERNEL); |
| 261 | 263 | if (!req_power) { |
| 262 | 264 | ret = -ENOMEM; |
| @@ -266,8 +268,10 @@ static int allocate_power(struct thermal_zone_device *tz, · 3 unmodified lines | ||
| 266 | 268 | max_power = &req_power[num_actors]; |
| 267 | 269 | granted_power = &req_power[2 * num_actors]; |
| 268 | 270 | extra_actor_power = &req_power[3 * num_actors]; |
| 271 | + weighted_req_power = &req_power[4 * num_actors]; | |
| 269 | 272 | |
| 270 | 273 | i = 0; |
| 274 | + total_weighted_req_power = 0; | |
| 271 | 275 | total_req_power = 0; |
| 272 | 276 | max_allocatable_power = 0; |
| 273 | 277 | |
| @@ -289,13 +293,14 @@ static int allocate_power(struct thermal_zone_device *tz, · 15 unmodified lines | ||
| 289 | 293 | else |
| 290 | 294 | weight = instance->weight; |
| 291 | 295 | |
| 292 | − req_power[i] = frac_to_int(weight * req_power[i]); | |
| 296 | + weighted_req_power[i] = frac_to_int(weight * req_power[i]); | |
| 293 | 297 | |
| 294 | 298 | if (power_actor_get_max_power(cdev, tz, &max_power[i])) |
| 295 | 299 | continue; |
| 296 | 300 | |
| 297 | 301 | total_req_power += req_power[i]; |
| 298 | 302 | max_allocatable_power += max_power[i]; |
| 303 | + total_weighted_req_power += weighted_req_power[i]; | |
| 299 | 304 | |
| 300 | 305 | i++; |
| 301 | 306 | } |
| @@ -303,8 +308,9 @@ static int allocate_power(struct thermal_zone_device *tz, · 1 unmodified line | ||
| 303 | 308 | power_range = pid_controller(tz, current_temp, control_temp, |
| 304 | 309 | max_allocatable_power); |
| 305 | 310 | |
| 306 | − divvy_up_power(req_power, max_power, num_actors, total_req_power, | |
| 307 | − power_range, granted_power, extra_actor_power); | |
| 311 | + divvy_up_power(weighted_req_power, max_power, num_actors, | |
| 312 | + total_weighted_req_power, power_range, granted_power, | |
| 313 | + extra_actor_power); | |
| 308 | 314 | |
| 309 | 315 | total_granted_power = 0; |
| 310 | 316 | i = 0; |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | config EXYNOS_THERMAL |
| 2 | 2 | tristate "Exynos thermal management unit driver" |
| 3 | − depends on OF | |
| 3 | + depends on THERMAL_OF | |
| 4 | 4 | help |
| 5 | 5 | If you say yes here you get support for the TMU (Thermal Management |
| 6 | 6 | Unit) driver for SAMSUNG EXYNOS series of SoCs. This driver initialises |
| @@ -1296,7 +1296,6 @@ static struct thermal_zone_of_device_ops exynos_sensor_ops = { · 1295 unmodified lines | ||
| 1296 | 1296 | |
| 1297 | 1297 | static int exynos_tmu_probe(struct platform_device *pdev) |
| 1298 | 1298 | { |
| 1299 | − struct exynos_tmu_platform_data *pdata; | |
| 1300 | 1299 | struct exynos_tmu_data *data; |
| 1301 | 1300 | int ret; |
| 1302 | 1301 | |
| @@ -1318,8 +1317,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) · 15 unmodified lines | ||
| 1318 | 1317 | if (ret) |
| 1319 | 1318 | goto err_sensor; |
| 1320 | 1319 | |
| 1321 | − pdata = data->pdata; | |
| 1322 | − | |
| 1323 | 1320 | INIT_WORK(&data->irq_work, exynos_tmu_work); |
| 1324 | 1321 | |
| 1325 | 1322 | data->clk = devm_clk_get(&pdev->dev, "tmu_apbif"); |
| @@ -1392,6 +1389,8 @@ err_clk_sec: · 66 unmodified lines | ||
| 1392 | 1389 | if (!IS_ERR(data->clk_sec)) |
| 1393 | 1390 | clk_unprepare(data->clk_sec); |
| 1394 | 1391 | err_sensor: |
| 1392 | + if (!IS_ERR_OR_NULL(data->regulator)) | |
| 1393 | + regulator_disable(data->regulator); | |
| 1395 | 1394 | thermal_zone_of_sensor_unregister(&pdev->dev, data->tzd); |
| 1396 | 1395 | |
| 1397 | 1396 | return ret; |
| @@ -1333,6 +1333,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, · 1332 unmodified lines | ||
| 1333 | 1333 | return -ENODEV; |
| 1334 | 1334 | |
| 1335 | 1335 | unbind: |
| 1336 | + device_remove_file(&tz->device, &pos->weight_attr); | |
| 1336 | 1337 | device_remove_file(&tz->device, &pos->attr); |
| 1337 | 1338 | sysfs_remove_link(&tz->device.kobj, pos->name); |
| 1338 | 1339 | release_idr(&tz->idr, &tz->lock, pos->id); |
| @@ -1024,7 +1024,18 @@ static struct platform_driver ci_hdrc_driver = { · 1023 unmodified lines | ||
| 1024 | 1024 | }, |
| 1025 | 1025 | }; |
| 1026 | 1026 | |
| 1027 | −module_platform_driver(ci_hdrc_driver); | |
| 1027 | +static int __init ci_hdrc_platform_register(void) | |
| 1028 | +{ | |
| 1029 | + ci_hdrc_host_driver_init(); | |
| 1030 | + return platform_driver_register(&ci_hdrc_driver); | |
| 1031 | +} | |
| 1032 | +module_init(ci_hdrc_platform_register); | |
| 1033 | + | |
| 1034 | +static void __exit ci_hdrc_platform_unregister(void) | |
| 1035 | +{ | |
| 1036 | + platform_driver_unregister(&ci_hdrc_driver); | |
| 1037 | +} | |
| 1038 | +module_exit(ci_hdrc_platform_unregister); | |
| 1028 | 1039 | |
| 1029 | 1040 | MODULE_ALIAS("platform:ci_hdrc"); |
| 1030 | 1041 | MODULE_LICENSE("GPL v2"); |
| @@ -249,9 +249,12 @@ int ci_hdrc_host_init(struct ci_hdrc *ci) · 248 unmodified lines | ||
| 249 | 249 | rdrv->name = "host"; |
| 250 | 250 | ci->roles[CI_ROLE_HOST] = rdrv; |
| 251 | 251 | |
| 252 | + return 0; | |
| 253 | +} | |
| 254 | + | |
| 255 | +void ci_hdrc_host_driver_init(void) | |
| 256 | +{ | |
| 252 | 257 | ehci_init_driver(&ci_ehci_hc_driver, &ehci_ci_overrides); |
| 253 | 258 | orig_bus_suspend = ci_ehci_hc_driver.bus_suspend; |
| 254 | 259 | ci_ehci_hc_driver.bus_suspend = ci_ehci_bus_suspend; |
| 255 | − | |
| 256 | − return 0; | |
| 257 | 260 | } |
| @@ -5,6 +5,7 @@ · 4 unmodified lines | ||
| 5 | 5 | |
| 6 | 6 | int ci_hdrc_host_init(struct ci_hdrc *ci); |
| 7 | 7 | void ci_hdrc_host_destroy(struct ci_hdrc *ci); |
| 8 | +void ci_hdrc_host_driver_init(void); | |
| 8 | 9 | |
| 9 | 10 | #else |
| 10 | 11 | |
| @@ -18,6 +19,11 @@ static inline void ci_hdrc_host_destroy(struct ci_hdrc *ci) · 7 unmodified lines | ||
| 18 | 19 | |
| 19 | 20 | } |
| 20 | 21 | |
| 22 | +static void ci_hdrc_host_driver_init(void) | |
| 23 | +{ | |
| 24 | + | |
| 25 | +} | |
| 26 | + | |
| 21 | 27 | #endif |
| 22 | 28 | |
| 23 | 29 | #endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */ |
| @@ -699,6 +699,10 @@ static inline int hidg_get_minor(void) · 698 unmodified lines | ||
| 699 | 699 | int ret; |
| 700 | 700 | |
| 701 | 701 | ret = ida_simple_get(&hidg_ida, 0, 0, GFP_KERNEL); |
| 702 | + if (ret >= HIDG_MINORS) { | |
| 703 | + ida_simple_remove(&hidg_ida, ret); | |
| 704 | + ret = -ENODEV; | |
| 705 | + } | |
| 702 | 706 | |
| 703 | 707 | return ret; |
| 704 | 708 | } |
| @@ -1248,7 +1248,15 @@ static struct config_item_type printer_func_type = { · 1247 unmodified lines | ||
| 1248 | 1248 | |
| 1249 | 1249 | static inline int gprinter_get_minor(void) |
| 1250 | 1250 | { |
| 1251 | − return ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL); | |
| 1251 | + int ret; | |
| 1252 | + | |
| 1253 | + ret = ida_simple_get(&printer_ida, 0, 0, GFP_KERNEL); | |
| 1254 | + if (ret >= PRINTER_MINORS) { | |
| 1255 | + ida_simple_remove(&printer_ida, ret); | |
| 1256 | + ret = -ENODEV; | |
| 1257 | + } | |
| 1258 | + | |
| 1259 | + return ret; | |
| 1252 | 1260 | } |
| 1253 | 1261 | |
| 1254 | 1262 | static inline void gprinter_put_minor(int minor) |
| @@ -1162,14 +1162,14 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) · 1161 unmodified lines | ||
| 1162 | 1162 | factor = 1000; |
| 1163 | 1163 | } else { |
| 1164 | 1164 | ep_desc = &hs_epin_desc; |
| 1165 | − factor = 125; | |
| 1165 | + factor = 8000; | |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /* pre-compute some values for iso_complete() */ |
| 1169 | 1169 | uac2->p_framesize = opts->p_ssize * |
| 1170 | 1170 | num_channels(opts->p_chmask); |
| 1171 | 1171 | rate = opts->p_srate * uac2->p_framesize; |
| 1172 | − uac2->p_interval = (1 << (ep_desc->bInterval - 1)) * factor; | |
| 1172 | + uac2->p_interval = factor / (1 << (ep_desc->bInterval - 1)); | |
| 1173 | 1173 | uac2->p_pktsize = min_t(unsigned int, rate / uac2->p_interval, |
| 1174 | 1174 | prm->max_psize); |
| 1175 | 1175 | |
| @@ -779,7 +779,7 @@ static int ep_dequeue(struct bdc_ep *ep, struct bdc_req *req) · 778 unmodified lines | ||
| 779 | 779 | /* The current hw dequeue pointer */ |
| 780 | 780 | tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(0)); |
| 781 | 781 | deq_ptr_64 = tmp_32; |
| 782 | − tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS0(1)); | |
| 782 | + tmp_32 = bdc_readl(bdc->regs, BDC_EPSTS1(0)); | |
| 783 | 783 | deq_ptr_64 |= ((u64)tmp_32 << 32); |
| 784 | 784 | |
| 785 | 785 | /* we have the dma addr of next bd that will be fetched by hardware */ |
| @@ -323,6 +323,7 @@ err4: · 322 unmodified lines | ||
| 323 | 323 | |
| 324 | 324 | err3: |
| 325 | 325 | put_device(&udc->dev); |
| 326 | + device_del(&gadget->dev); | |
| 326 | 327 | |
| 327 | 328 | err2: |
| 328 | 329 | put_device(&gadget->dev); |
| @@ -1792,7 +1792,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) · 1791 unmodified lines | ||
| 1792 | 1792 | int size; |
| 1793 | 1793 | int i, j, num_ports; |
| 1794 | 1794 | |
| 1795 | − del_timer_sync(&xhci->cmd_timer); | |
| 1795 | + if (timer_pending(&xhci->cmd_timer)) | |
| 1796 | + del_timer_sync(&xhci->cmd_timer); | |
| 1796 | 1797 | |
| 1797 | 1798 | /* Free the Event Ring Segment Table and the actual Event Ring */ |
| 1798 | 1799 | size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); |
| @@ -82,7 +82,7 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, · 81 unmodified lines | ||
| 82 | 82 | return 0; |
| 83 | 83 | /* offset in TRBs */ |
| 84 | 84 | segment_offset = trb - seg->trbs; |
| 85 | − if (segment_offset > TRBS_PER_SEGMENT) | |
| 85 | + if (segment_offset >= TRBS_PER_SEGMENT) | |
| 86 | 86 | return 0; |
| 87 | 87 | return seg->dma + (segment_offset * sizeof(*trb)); |
| 88 | 88 | } |
| @@ -1099,6 +1099,8 @@ static const struct usb_device_id option_ids[] = { · 1098 unmodified lines | ||
| 1099 | 1099 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ |
| 1100 | 1100 | { USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x68c0, 0xff), |
| 1101 | 1101 | .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC73xx */ |
| 1102 | + { USB_DEVICE_INTERFACE_CLASS(SIERRA_VENDOR_ID, 0x9041, 0xff), | |
| 1103 | + .driver_info = (kernel_ulong_t)&sierra_mc73xx_blacklist }, /* MC7305/MC7355 */ | |
| 1102 | 1104 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) }, |
| 1103 | 1105 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) }, |
| 1104 | 1106 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003), |
| @@ -145,7 +145,6 @@ static const struct usb_device_id id_table[] = { · 144 unmodified lines | ||
| 145 | 145 | {DEVICE_SWI(0x1199, 0x901c)}, /* Sierra Wireless EM7700 */ |
| 146 | 146 | {DEVICE_SWI(0x1199, 0x901f)}, /* Sierra Wireless EM7355 */ |
| 147 | 147 | {DEVICE_SWI(0x1199, 0x9040)}, /* Sierra Wireless Modem */ |
| 148 | − {DEVICE_SWI(0x1199, 0x9041)}, /* Sierra Wireless MC7305/MC7355 */ | |
| 149 | 148 | {DEVICE_SWI(0x1199, 0x9051)}, /* Netgear AirCard 340U */ |
| 150 | 149 | {DEVICE_SWI(0x1199, 0x9053)}, /* Sierra Wireless Modem */ |
| 151 | 150 | {DEVICE_SWI(0x1199, 0x9054)}, /* Sierra Wireless Modem */ |
| @@ -158,6 +157,7 @@ static const struct usb_device_id id_table[] = { · 6 unmodified lines | ||
| 158 | 157 | {DEVICE_SWI(0x413c, 0x81a4)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */ |
| 159 | 158 | {DEVICE_SWI(0x413c, 0x81a8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */ |
| 160 | 159 | {DEVICE_SWI(0x413c, 0x81a9)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ |
| 160 | + {DEVICE_SWI(0x413c, 0x81b1)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */ | |
| 161 | 161 | |
| 162 | 162 | /* Huawei devices */ |
| 163 | 163 | {DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */ |
| @@ -289,6 +289,7 @@ static const struct usb_device_id id_table[] = { · 288 unmodified lines | ||
| 289 | 289 | { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF), |
| 290 | 290 | .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist |
| 291 | 291 | }, |
| 292 | + { USB_DEVICE(0x1199, 0x68AB) }, /* Sierra Wireless AR8550 */ | |
| 292 | 293 | /* AT&T Direct IP LTE modems */ |
| 293 | 294 | { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF), |
| 294 | 295 | .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist |
| @@ -1306,10 +1306,11 @@ static void fbcon_cursor(struct vc_data *vc, int mode) · 1305 unmodified lines | ||
| 1306 | 1306 | int y; |
| 1307 | 1307 | int c = scr_readw((u16 *) vc->vc_pos); |
| 1308 | 1308 | |
| 1309 | + ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms); | |
| 1310 | + | |
| 1309 | 1311 | if (fbcon_is_inactive(vc, info) || vc->vc_deccm != 1) |
| 1310 | 1312 | return; |
| 1311 | 1313 | |
| 1312 | − ops->cur_blink_jiffies = msecs_to_jiffies(vc->vc_cur_blink_ms); | |
| 1313 | 1314 | if (vc->vc_cursor_type & 0x10) |
| 1314 | 1315 | fbcon_del_cursor_timer(info); |
| 1315 | 1316 | else |
| @@ -298,7 +298,7 @@ config FB_ARMCLCD · 297 unmodified lines | ||
| 298 | 298 | |
| 299 | 299 | # Helper logic selected only by the ARM Versatile platform family. |
| 300 | 300 | config PLAT_VERSATILE_CLCD |
| 301 | − def_bool ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS | |
| 301 | + def_bool ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS || ARCH_INTEGRATOR | |
| 302 | 302 | depends on ARM |
| 303 | 303 | depends on FB_ARMCLCD && FB=y |
| 304 | 304 | |
| @@ -60,6 +60,8 @@ omapdss_of_get_next_port(const struct device_node *parent, · 59 unmodified lines | ||
| 60 | 60 | } |
| 61 | 61 | prev = port; |
| 62 | 62 | } while (of_node_cmp(port->name, "port") != 0); |
| 63 | + | |
| 64 | + of_node_put(ports); | |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | return port; |
| @@ -94,7 +96,7 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port) · 28 unmodified lines | ||
| 94 | 96 | if (!port) |
| 95 | 97 | return NULL; |
| 96 | 98 | |
| 97 | − np = of_get_next_parent(port); | |
| 99 | + np = of_get_parent(port); | |
| 98 | 100 | |
| 99 | 101 | for (i = 0; i < 2 && np; ++i) { |
| 100 | 102 | struct property *prop; |
| @@ -653,7 +653,7 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) · 652 unmodified lines | ||
| 653 | 653 | goto err_free_dma; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | − ret = clk_enable(priv->clk); | |
| 656 | + ret = clk_prepare_enable(priv->clk); | |
| 657 | 657 | if (ret < 0) { |
| 658 | 658 | dev_err(dev, "failed to enable clock\n"); |
| 659 | 659 | goto err_misc_deregister; |
| @@ -685,7 +685,7 @@ err_misc_deregister: · 25 unmodified lines | ||
| 685 | 685 | misc_deregister(&priv->misc_dev); |
| 686 | 686 | |
| 687 | 687 | err_disable_clk: |
| 688 | − clk_disable(priv->clk); | |
| 688 | + clk_disable_unprepare(priv->clk); | |
| 689 | 689 | |
| 690 | 690 | return ret; |
| 691 | 691 | } |
| @@ -44,11 +44,9 @@ int of_get_videomode(struct device_node *np, struct videomode *vm, · 43 unmodified lines | ||
| 44 | 44 | index = disp->native_mode; |
| 45 | 45 | |
| 46 | 46 | ret = videomode_from_timings(disp, vm, index); |
| 47 | − if (ret) | |
| 48 | − return ret; | |
| 49 | 47 | |
| 50 | 48 | display_timings_release(disp); |
| 51 | 49 | |
| 52 | − return 0; | |
| 50 | + return ret; | |
| 53 | 51 | } |
| 54 | 52 | EXPORT_SYMBOL_GPL(of_get_videomode); |
| @@ -313,6 +313,7 @@ err_init_vq: · 312 unmodified lines | ||
| 313 | 313 | static void virtinput_remove(struct virtio_device *vdev) |
| 314 | 314 | { |
| 315 | 315 | struct virtio_input *vi = vdev->priv; |
| 316 | + void *buf; | |
| 316 | 317 | unsigned long flags; |
| 317 | 318 | |
| 318 | 319 | spin_lock_irqsave(&vi->lock, flags); |
| @@ -320,6 +321,9 @@ static void virtinput_remove(struct virtio_device *vdev) · 1 unmodified line | ||
| 320 | 321 | spin_unlock_irqrestore(&vi->lock, flags); |
| 321 | 322 | |
| 322 | 323 | input_unregister_device(vi->idev); |
| 324 | + vdev->config->reset(vdev); | |
| 325 | + while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL) | |
| 326 | + kfree(buf); | |
| 323 | 327 | vdev->config->del_vqs(vdev); |
| 324 | 328 | kfree(vi); |
| 325 | 329 | } |
| @@ -472,7 +472,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) · 471 unmodified lines | ||
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /* |
| 475 | − * We avoid multiple worker processes conflicting via the balloon mutex. | |
| 475 | + * As this is a work item it is guaranteed to run as a single instance only. | |
| 476 | 476 | * We may of course race updates of the target counts (which are protected |
| 477 | 477 | * by the balloon lock), or with changes to the Xen hard limit, but we will |
| 478 | 478 | * recover from these in time. |
| @@ -482,9 +482,10 @@ static void balloon_process(struct work_struct *work) · 3 unmodified lines | ||
| 482 | 482 | enum bp_state state = BP_DONE; |
| 483 | 483 | long credit; |
| 484 | 484 | |
| 485 | − mutex_lock(&balloon_mutex); | |
| 486 | 485 | |
| 487 | 486 | do { |
| 487 | + mutex_lock(&balloon_mutex); | |
| 488 | + | |
| 488 | 489 | credit = current_credit(); |
| 489 | 490 | |
| 490 | 491 | if (credit > 0) { |
| @@ -499,17 +500,15 @@ static void balloon_process(struct work_struct *work) · 8 unmodified lines | ||
| 499 | 500 | |
| 500 | 501 | state = update_schedule(state); |
| 501 | 502 | |
| 502 | −#ifndef CONFIG_PREEMPT | |
| 503 | − if (need_resched()) | |
| 504 | − schedule(); | |
| 505 | −#endif | |
| 503 | + mutex_unlock(&balloon_mutex); | |
| 504 | + | |
| 505 | + cond_resched(); | |
| 506 | + | |
| 506 | 507 | } while (credit && state == BP_DONE); |
| 507 | 508 | |
| 508 | 509 | /* Schedule more work if there is some still to be done. */ |
| 509 | 510 | if (state == BP_EAGAIN) |
| 510 | 511 | schedule_delayed_work(&balloon_worker, balloon_stats.schedule_delay * HZ); |
| 511 | − | |
| 512 | − mutex_unlock(&balloon_mutex); | |
| 513 | 512 | } |
| 514 | 513 | |
| 515 | 514 | /* Resets the Xen limit, sets new target, and kicks off processing. */ |
| @@ -568,12 +568,14 @@ static int gntdev_release(struct inode *inode, struct file *flip) · 567 unmodified lines | ||
| 568 | 568 | |
| 569 | 569 | pr_debug("priv %p\n", priv); |
| 570 | 570 | |
| 571 | + mutex_lock(&priv->lock); | |
| 571 | 572 | while (!list_empty(&priv->maps)) { |
| 572 | 573 | map = list_entry(priv->maps.next, struct grant_map, next); |
| 573 | 574 | list_del(&map->next); |
| 574 | 575 | gntdev_put_map(NULL /* already removed */, map); |
| 575 | 576 | } |
| 576 | 577 | WARN_ON(!list_empty(&priv->freeable_maps)); |
| 578 | + mutex_unlock(&priv->lock); | |
| 577 | 579 | |
| 578 | 580 | if (use_ptemod) |
| 579 | 581 | mmu_notifier_unregister(&priv->mn, priv->mm); |
| @@ -814,8 +814,10 @@ static int xenbus_unmap_ring_vfree_hvm(struct xenbus_device *dev, void *vaddr) · 813 unmodified lines | ||
| 814 | 814 | |
| 815 | 815 | rv = xenbus_unmap_ring(dev, node->handles, node->nr_handles, |
| 816 | 816 | addrs); |
| 817 | − if (!rv) | |
| 817 | + if (!rv) { | |
| 818 | 818 | vunmap(vaddr); |
| 819 | + free_xenballooned_pages(node->nr_handles, node->hvm.pages); | |
| 820 | + } | |
| 819 | 821 | else |
| 820 | 822 | WARN(1, "Leaking %p, size %u page(s)\n", vaddr, |
| 821 | 823 | node->nr_handles); |
| @@ -1651,6 +1651,11 @@ static int qgroup_update_counters(struct btrfs_fs_info *fs_info, · 1650 unmodified lines | ||
| 1651 | 1651 | /* Exclusive -> exclusive, nothing changed */ |
| 1652 | 1652 | } |
| 1653 | 1653 | } |
| 1654 | + | |
| 1655 | + /* For exclusive extent, free its reserved bytes too */ | |
| 1656 | + if (nr_old_roots == 0 && nr_new_roots == 1 && | |
| 1657 | + cur_new_count == nr_new_roots) | |
| 1658 | + qg->reserved -= num_bytes; | |
| 1654 | 1659 | if (dirty) |
| 1655 | 1660 | qgroup_dirty(fs_info, qg); |
| 1656 | 1661 | } |
| @@ -1506,7 +1506,6 @@ static int __mark_caps_flushing(struct inode *inode, · 1505 unmodified lines | ||
| 1506 | 1506 | |
| 1507 | 1507 | swap(cf, ci->i_prealloc_cap_flush); |
| 1508 | 1508 | cf->caps = flushing; |
| 1509 | − cf->kick = false; | |
| 1510 | 1509 | |
| 1511 | 1510 | spin_lock(&mdsc->cap_dirty_lock); |
| 1512 | 1511 | list_del_init(&ci->i_dirty_item); |
| @@ -2123,8 +2122,7 @@ static void kick_flushing_capsnaps(struct ceph_mds_client *mdsc, · 610 unmodified lines | ||
| 2123 | 2122 | |
| 2124 | 2123 | static int __kick_flushing_caps(struct ceph_mds_client *mdsc, |
| 2125 | 2124 | struct ceph_mds_session *session, |
| 2126 | − struct ceph_inode_info *ci, | |
| 2127 | − bool kick_all) | |
| 2125 | + struct ceph_inode_info *ci) | |
| 2128 | 2126 | { |
| 2129 | 2127 | struct inode *inode = &ci->vfs_inode; |
| 2130 | 2128 | struct ceph_cap *cap; |
| @@ -2150,9 +2148,7 @@ static int __kick_flushing_caps(struct ceph_mds_client *mdsc, · 19 unmodified lines | ||
| 2150 | 2148 | |
| 2151 | 2149 | for (n = rb_first(&ci->i_cap_flush_tree); n; n = rb_next(n)) { |
| 2152 | 2150 | cf = rb_entry(n, struct ceph_cap_flush, i_node); |
| 2153 | − if (cf->tid < first_tid) | |
| 2154 | − continue; | |
| 2155 | − if (kick_all || cf->kick) | |
| 2151 | + if (cf->tid >= first_tid) | |
| 2156 | 2152 | break; |
| 2157 | 2153 | } |
| 2158 | 2154 | if (!n) { |
| @@ -2161,7 +2157,6 @@ static int __kick_flushing_caps(struct ceph_mds_client *mdsc, · 2 unmodified lines | ||
| 2161 | 2157 | } |
| 2162 | 2158 | |
| 2163 | 2159 | cf = rb_entry(n, struct ceph_cap_flush, i_node); |
| 2164 | − cf->kick = false; | |
| 2165 | 2160 | |
| 2166 | 2161 | first_tid = cf->tid + 1; |
| 2167 | 2162 | |
| @@ -2181,8 +2176,6 @@ void ceph_early_kick_flushing_caps(struct ceph_mds_client *mdsc, · 13 unmodified lines | ||
| 2181 | 2176 | { |
| 2182 | 2177 | struct ceph_inode_info *ci; |
| 2183 | 2178 | struct ceph_cap *cap; |
| 2184 | − struct ceph_cap_flush *cf; | |
| 2185 | − struct rb_node *n; | |
| 2186 | 2179 | |
| 2187 | 2180 | dout("early_kick_flushing_caps mds%d\n", session->s_mds); |
| 2188 | 2181 | list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { |
| @@ -2205,16 +2198,11 @@ void ceph_early_kick_flushing_caps(struct ceph_mds_client *mdsc, · 16 unmodified lines | ||
| 2205 | 2198 | if ((cap->issued & ci->i_flushing_caps) != |
| 2206 | 2199 | ci->i_flushing_caps) { |
| 2207 | 2200 | spin_unlock(&ci->i_ceph_lock); |
| 2208 | − if (!__kick_flushing_caps(mdsc, session, ci, true)) | |
| 2201 | + if (!__kick_flushing_caps(mdsc, session, ci)) | |
| 2209 | 2202 | continue; |
| 2210 | 2203 | spin_lock(&ci->i_ceph_lock); |
| 2211 | 2204 | } |
| 2212 | 2205 | |
| 2213 | − for (n = rb_first(&ci->i_cap_flush_tree); n; n = rb_next(n)) { | |
| 2214 | − cf = rb_entry(n, struct ceph_cap_flush, i_node); | |
| 2215 | − cf->kick = true; | |
| 2216 | − } | |
| 2217 | − | |
| 2218 | 2206 | spin_unlock(&ci->i_ceph_lock); |
| 2219 | 2207 | } |
| 2220 | 2208 | } |
| @@ -2228,7 +2216,7 @@ void ceph_kick_flushing_caps(struct ceph_mds_client *mdsc, · 7 unmodified lines | ||
| 2228 | 2216 | |
| 2229 | 2217 | dout("kick_flushing_caps mds%d\n", session->s_mds); |
| 2230 | 2218 | list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { |
| 2231 | − int delayed = __kick_flushing_caps(mdsc, session, ci, false); | |
| 2219 | + int delayed = __kick_flushing_caps(mdsc, session, ci); | |
| 2232 | 2220 | if (delayed) { |
| 2233 | 2221 | spin_lock(&ci->i_ceph_lock); |
| 2234 | 2222 | __cap_delay_requeue(mdsc, ci); |
| @@ -2261,7 +2249,7 @@ static void kick_flushing_inode_caps(struct ceph_mds_client *mdsc, · 26 unmodified lines | ||
| 2261 | 2249 | |
| 2262 | 2250 | spin_unlock(&ci->i_ceph_lock); |
| 2263 | 2251 | |
| 2264 | − delayed = __kick_flushing_caps(mdsc, session, ci, true); | |
| 2252 | + delayed = __kick_flushing_caps(mdsc, session, ci); | |
| 2265 | 2253 | if (delayed) { |
| 2266 | 2254 | spin_lock(&ci->i_ceph_lock); |
| 2267 | 2255 | __cap_delay_requeue(mdsc, ci); |
| @@ -287,7 +287,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, · 286 unmodified lines | ||
| 287 | 287 | return 0; |
| 288 | 288 | |
| 289 | 289 | spin_lock(&ctx->flc_lock); |
| 290 | − list_for_each_entry(lock, &ctx->flc_flock, fl_list) { | |
| 290 | + list_for_each_entry(lock, &ctx->flc_posix, fl_list) { | |
| 291 | 291 | ++seen_fcntl; |
| 292 | 292 | if (seen_fcntl > num_fcntl_locks) { |
| 293 | 293 | err = -ENOSPC; |
| @@ -189,7 +189,6 @@ static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap) · 188 unmodified lines | ||
| 189 | 189 | struct ceph_cap_flush { |
| 190 | 190 | u64 tid; |
| 191 | 191 | int caps; |
| 192 | − bool kick; | |
| 193 | 192 | struct rb_node g_node; // global |
| 194 | 193 | union { |
| 195 | 194 | struct rb_node i_node; // inode |
| @@ -3442,22 +3442,15 @@ void __init vfs_caches_init_early(void) · 3441 unmodified lines | ||
| 3442 | 3442 | inode_init_early(); |
| 3443 | 3443 | } |
| 3444 | 3444 | |
| 3445 | −void __init vfs_caches_init(unsigned long mempages) | |
| 3445 | +void __init vfs_caches_init(void) | |
| 3446 | 3446 | { |
| 3447 | − unsigned long reserve; | |
| 3448 | − | |
| 3449 | − /* Base hash sizes on available memory, with a reserve equal to | |
| 3450 | − 150% of current kernel size */ | |
| 3451 | − | |
| 3452 | − reserve = min((mempages - nr_free_pages()) * 3/2, mempages - 1); | |
| 3453 | − mempages -= reserve; | |
| 3454 | − | |
| 3455 | 3447 | names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0, |
| 3456 | 3448 | SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); |
| 3457 | 3449 | |
| 3458 | 3450 | dcache_init(); |
| 3459 | 3451 | inode_init(); |
| 3460 | − files_init(mempages); | |
| 3452 | + files_init(); | |
| 3453 | + files_maxfiles_init(); | |
| 3461 | 3454 | mnt_init(); |
| 3462 | 3455 | bdev_cache_init(); |
| 3463 | 3456 | chrdev_init(); |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <linux/hardirq.h> |
| 26 | 26 | #include <linux/task_work.h> |
| 27 | 27 | #include <linux/ima.h> |
| 28 | +#include <linux/swap.h> | |
| 28 | 29 | |
| 29 | 30 | #include <linux/atomic.h> |
| 30 | 31 | |
| @@ -308,19 +309,24 @@ void put_filp(struct file *file) · 277 unmodified lines | ||
| 308 | 309 | } |
| 309 | 310 | } |
| 310 | 311 | |
| 311 | −void __init files_init(unsigned long mempages) | |
| 312 | +void __init files_init(void) | |
| 312 | 313 | { |
| 313 | − unsigned long n; | |
| 314 | − | |
| 315 | 314 | filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, |
| 316 | 315 | SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); |
| 316 | + percpu_counter_init(&nr_files, 0, GFP_KERNEL); | |
| 317 | +} | |
| 317 | 318 | |
| 318 | − /* | |
| 319 | − * One file with associated inode and dcache is very roughly 1K. | |
| 320 | − * Per default don't use more than 10% of our memory for files. | |
| 321 | − */ | |
| 319 | +/* | |
| 320 | + * One file with associated inode and dcache is very roughly 1K. Per default | |
| 321 | + * do not use more than 10% of our memory for files. | |
| 322 | + */ | |
| 323 | +void __init files_maxfiles_init(void) | |
| 324 | +{ | |
| 325 | + unsigned long n; | |
| 326 | + unsigned long memreserve = (totalram_pages - nr_free_pages()) * 3/2; | |
| 327 | + | |
| 328 | + memreserve = min(memreserve, totalram_pages - 1); | |
| 329 | + n = ((totalram_pages - memreserve) * (PAGE_SIZE / 1024)) / 10; | |
| 322 | 330 | |
| 323 | − n = (mempages * (PAGE_SIZE / 1024)) / 10; | |
| 324 | 331 | files_stat.max_files = max_t(unsigned long, n, NR_FILE); |
| 325 | − percpu_counter_init(&nr_files, 0, GFP_KERNEL); | |
| 326 | 332 | } |
| @@ -1010,6 +1010,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size, · 1009 unmodified lines | ||
| 1010 | 1010 | inode = hugetlbfs_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0); |
| 1011 | 1011 | if (!inode) |
| 1012 | 1012 | goto out_dentry; |
| 1013 | + if (creat_flags == HUGETLB_SHMFS_INODE) | |
| 1014 | + inode->i_flags |= S_PRIVATE; | |
| 1013 | 1015 | |
| 1014 | 1016 | file = ERR_PTR(-ENOMEM); |
| 1015 | 1017 | if (hugetlb_reserve_pages(inode, 0, |
| @@ -879,7 +879,7 @@ static inline int may_follow_link(struct nameidata *nd) · 878 unmodified lines | ||
| 879 | 879 | return 0; |
| 880 | 880 | |
| 881 | 881 | /* Allowed if parent directory not sticky and world-writable. */ |
| 882 | − parent = nd->path.dentry->d_inode; | |
| 882 | + parent = nd->inode; | |
| 883 | 883 | if ((parent->i_mode & (S_ISVTX|S_IWOTH)) != (S_ISVTX|S_IWOTH)) |
| 884 | 884 | return 0; |
| 885 | 885 | |
| @@ -1954,8 +1954,13 @@ OK: · 1068 unmodified lines | ||
| 1954 | 1954 | continue; |
| 1955 | 1955 | } |
| 1956 | 1956 | } |
| 1957 | − if (unlikely(!d_can_lookup(nd->path.dentry))) | |
| 1957 | + if (unlikely(!d_can_lookup(nd->path.dentry))) { | |
| 1958 | + if (nd->flags & LOOKUP_RCU) { | |
| 1959 | + if (unlazy_walk(nd, NULL, 0)) | |
| 1960 | + return -ECHILD; | |
| 1961 | + } | |
| 1958 | 1962 | return -ENOTDIR; |
| 1963 | + } | |
| 1959 | 1964 | } |
| 1960 | 1965 | } |
| 1961 | 1966 | |
| @@ -212,6 +212,7 @@ nfsd4_alloc_layout_stateid(struct nfsd4_compound_state *cstate, · 211 unmodified lines | ||
| 212 | 212 | BUG_ON(!ls->ls_file); |
| 213 | 213 | |
| 214 | 214 | if (nfsd4_layout_setlease(ls)) { |
| 215 | + fput(ls->ls_file); | |
| 215 | 216 | put_nfs4_file(fp); |
| 216 | 217 | kmem_cache_free(nfs4_layout_stateid_cache, ls); |
| 217 | 218 | return NULL; |
| @@ -4396,9 +4396,9 @@ laundromat_main(struct work_struct *laundry) · 4395 unmodified lines | ||
| 4396 | 4396 | queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ); |
| 4397 | 4397 | } |
| 4398 | 4398 | |
| 4399 | −static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_ol_stateid *stp) | |
| 4399 | +static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) | |
| 4400 | 4400 | { |
| 4401 | − if (!fh_match(&fhp->fh_handle, &stp->st_stid.sc_file->fi_fhandle)) | |
| 4401 | + if (!fh_match(&fhp->fh_handle, &stp->sc_file->fi_fhandle)) | |
| 4402 | 4402 | return nfserr_bad_stateid; |
| 4403 | 4403 | return nfs_ok; |
| 4404 | 4404 | } |
| @@ -4601,9 +4601,6 @@ nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags) · 196 unmodified lines | ||
| 4601 | 4601 | { |
| 4602 | 4602 | __be32 status; |
| 4603 | 4603 | |
| 4604 | − status = nfs4_check_fh(fhp, ols); | |
| 4605 | − if (status) | |
| 4606 | − return status; | |
| 4607 | 4604 | status = nfsd4_check_openowner_confirmed(ols); |
| 4608 | 4605 | if (status) |
| 4609 | 4606 | return status; |
| @@ -4690,6 +4687,9 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, · 80 unmodified lines | ||
| 4690 | 4687 | status = nfserr_bad_stateid; |
| 4691 | 4688 | break; |
| 4692 | 4689 | } |
| 4690 | + if (status) | |
| 4691 | + goto out; | |
| 4692 | + status = nfs4_check_fh(fhp, s); | |
| 4693 | 4693 | |
| 4694 | 4694 | done: |
| 4695 | 4695 | if (!status && filpp) |
| @@ -4798,7 +4798,7 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_ · 102 unmodified lines | ||
| 4798 | 4798 | status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate)); |
| 4799 | 4799 | if (status) |
| 4800 | 4800 | return status; |
| 4801 | − return nfs4_check_fh(current_fh, stp); | |
| 4801 | + return nfs4_check_fh(current_fh, &stp->st_stid); | |
| 4802 | 4802 | } |
| 4803 | 4803 | |
| 4804 | 4804 | /* |
| @@ -2143,6 +2143,7 @@ nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp, · 2142 unmodified lines | ||
| 2143 | 2143 | #define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID | \ |
| 2144 | 2144 | FATTR4_WORD0_RDATTR_ERROR) |
| 2145 | 2145 | #define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID |
| 2146 | +#define WORD2_ABSENT_FS_ATTRS 0 | |
| 2146 | 2147 | |
| 2147 | 2148 | #ifdef CONFIG_NFSD_V4_SECURITY_LABEL |
| 2148 | 2149 | static inline __be32 |
| @@ -2171,7 +2172,7 @@ nfsd4_encode_security_label(struct xdr_stream *xdr, struct svc_rqst *rqstp, · 22 unmodified lines | ||
| 2171 | 2172 | { return 0; } |
| 2172 | 2173 | #endif |
| 2173 | 2174 | |
| 2174 | −static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err) | |
| 2175 | +static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *bmval2, u32 *rdattr_err) | |
| 2175 | 2176 | { |
| 2176 | 2177 | /* As per referral draft: */ |
| 2177 | 2178 | if (*bmval0 & ~WORD0_ABSENT_FS_ATTRS || |
| @@ -2184,6 +2185,7 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err) · 6 unmodified lines | ||
| 2184 | 2185 | } |
| 2185 | 2186 | *bmval0 &= WORD0_ABSENT_FS_ATTRS; |
| 2186 | 2187 | *bmval1 &= WORD1_ABSENT_FS_ATTRS; |
| 2188 | + *bmval2 &= WORD2_ABSENT_FS_ATTRS; | |
| 2187 | 2189 | return 0; |
| 2188 | 2190 | } |
| 2189 | 2191 | |
| @@ -2246,8 +2248,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, · 56 unmodified lines | ||
| 2246 | 2248 | BUG_ON(bmval2 & ~nfsd_suppattrs2(minorversion)); |
| 2247 | 2249 | |
| 2248 | 2250 | if (exp->ex_fslocs.migrated) { |
| 2249 | − BUG_ON(bmval[2]); | |
| 2250 | − status = fattr_handle_absent_fs(&bmval0, &bmval1, &rdattr_err); | |
| 2251 | + status = fattr_handle_absent_fs(&bmval0, &bmval1, &bmval2, &rdattr_err); | |
| 2251 | 2252 | if (status) |
| 2252 | 2253 | goto out; |
| 2253 | 2254 | } |
| @@ -2286,8 +2287,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, · 32 unmodified lines | ||
| 2286 | 2287 | } |
| 2287 | 2288 | |
| 2288 | 2289 | #ifdef CONFIG_NFSD_V4_SECURITY_LABEL |
| 2289 | − if ((bmval[2] & FATTR4_WORD2_SECURITY_LABEL) || | |
| 2290 | − bmval[0] & FATTR4_WORD0_SUPPORTED_ATTRS) { | |
| 2290 | + if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) || | |
| 2291 | + bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { | |
| 2291 | 2292 | err = security_inode_getsecctx(d_inode(dentry), |
| 2292 | 2293 | &context, &contextlen); |
| 2293 | 2294 | contextsupport = (err == 0); |
| @@ -412,16 +412,36 @@ void fsnotify_clear_marks_by_group_flags(struct fsnotify_group *group, · 411 unmodified lines | ||
| 412 | 412 | unsigned int flags) |
| 413 | 413 | { |
| 414 | 414 | struct fsnotify_mark *lmark, *mark; |
| 415 | + LIST_HEAD(to_free); | |
| 415 | 416 | |
| 417 | + /* | |
| 418 | + * We have to be really careful here. Anytime we drop mark_mutex, e.g. | |
| 419 | + * fsnotify_clear_marks_by_inode() can come and free marks. Even in our | |
| 420 | + * to_free list so we have to use mark_mutex even when accessing that | |
| 421 | + * list. And freeing mark requires us to drop mark_mutex. So we can | |
| 422 | + * reliably free only the first mark in the list. That's why we first | |
| 423 | + * move marks to free to to_free list in one go and then free marks in | |
| 424 | + * to_free list one by one. | |
| 425 | + */ | |
| 416 | 426 | mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING); |
| 417 | 427 | list_for_each_entry_safe(mark, lmark, &group->marks_list, g_list) { |
| 418 | − if (mark->flags & flags) { | |
| 419 | − fsnotify_get_mark(mark); | |
| 420 | − fsnotify_destroy_mark_locked(mark, group); | |
| 421 | − fsnotify_put_mark(mark); | |
| 422 | − } | |
| 428 | + if (mark->flags & flags) | |
| 429 | + list_move(&mark->g_list, &to_free); | |
| 423 | 430 | } |
| 424 | 431 | mutex_unlock(&group->mark_mutex); |
| 432 | + | |
| 433 | + while (1) { | |
| 434 | + mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING); | |
| 435 | + if (list_empty(&to_free)) { | |
| 436 | + mutex_unlock(&group->mark_mutex); | |
| 437 | + break; | |
| 438 | + } | |
| 439 | + mark = list_first_entry(&to_free, struct fsnotify_mark, g_list); | |
| 440 | + fsnotify_get_mark(mark); | |
| 441 | + fsnotify_destroy_mark_locked(mark, group); | |
| 442 | + mutex_unlock(&group->mark_mutex); | |
| 443 | + fsnotify_put_mark(mark); | |
| 444 | + } | |
| 425 | 445 | } |
| 426 | 446 | |
| 427 | 447 | /* |
| @@ -685,7 +685,7 @@ static int ocfs2_direct_IO_zero_extend(struct ocfs2_super *osb, · 684 unmodified lines | ||
| 685 | 685 | |
| 686 | 686 | if (p_cpos && !(ext_flags & OCFS2_EXT_UNWRITTEN)) { |
| 687 | 687 | u64 s = i_size_read(inode); |
| 688 | − sector_t sector = (p_cpos << (osb->s_clustersize_bits - 9)) + | |
| 688 | + sector_t sector = ((u64)p_cpos << (osb->s_clustersize_bits - 9)) + | |
| 689 | 689 | (do_div(s, osb->s_clustersize) >> 9); |
| 690 | 690 | |
| 691 | 691 | ret = blkdev_issue_zeroout(osb->sb->s_bdev, sector, |
| @@ -910,7 +910,7 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb, · 218 unmodified lines | ||
| 910 | 910 | BUG_ON(!p_cpos || (ext_flags & OCFS2_EXT_UNWRITTEN)); |
| 911 | 911 | |
| 912 | 912 | ret = blkdev_issue_zeroout(osb->sb->s_bdev, |
| 913 | − p_cpos << (osb->s_clustersize_bits - 9), | |
| 913 | + (u64)p_cpos << (osb->s_clustersize_bits - 9), | |
| 914 | 914 | zero_len_head >> 9, GFP_NOFS, false); |
| 915 | 915 | if (ret < 0) |
| 916 | 916 | mlog_errno(ret); |
| @@ -4025,9 +4025,13 @@ static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb) · 4024 unmodified lines | ||
| 4025 | 4025 | osb->dc_work_sequence = osb->dc_wake_sequence; |
| 4026 | 4026 | |
| 4027 | 4027 | processed = osb->blocked_lock_count; |
| 4028 | − while (processed) { | |
| 4029 | − BUG_ON(list_empty(&osb->blocked_lock_list)); | |
| 4030 | − | |
| 4028 | + /* | |
| 4029 | + * blocked lock processing in this loop might call iput which can | |
| 4030 | + * remove items off osb->blocked_lock_list. Downconvert up to | |
| 4031 | + * 'processed' number of locks, but stop short if we had some | |
| 4032 | + * removed in ocfs2_mark_lockres_freeing when downconverting. | |
| 4033 | + */ | |
| 4034 | + while (processed && !list_empty(&osb->blocked_lock_list)) { | |
| 4031 | 4035 | lockres = list_entry(osb->blocked_lock_list.next, |
| 4032 | 4036 | struct ocfs2_lock_res, l_blocked_list); |
| 4033 | 4037 | list_del_init(&lockres->l_blocked_list); |
| @@ -121,8 +121,9 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, · 120 unmodified lines | ||
| 121 | 121 | * Other callers might not initialize the si_lsb field, |
| 122 | 122 | * so check explicitly for the right codes here. |
| 123 | 123 | */ |
| 124 | − if (kinfo->si_code == BUS_MCEERR_AR || | |
| 125 | − kinfo->si_code == BUS_MCEERR_AO) | |
| 124 | + if (kinfo->si_signo == SIGBUS && | |
| 125 | + (kinfo->si_code == BUS_MCEERR_AR || | |
| 126 | + kinfo->si_code == BUS_MCEERR_AO)) | |
| 126 | 127 | err |= __put_user((short) kinfo->si_addr_lsb, |
| 127 | 128 | &uinfo->ssi_addr_lsb); |
| 128 | 129 | #endif |
| @@ -691,7 +691,7 @@ struct drm_vblank_crtc { · 690 unmodified lines | ||
| 691 | 691 | struct timer_list disable_timer; /* delayed disable timer */ |
| 692 | 692 | |
| 693 | 693 | /* vblank counter, protected by dev->vblank_time_lock for writes */ |
| 694 | − unsigned long count; | |
| 694 | + u32 count; | |
| 695 | 695 | /* vblank timestamps, protected by dev->vblank_time_lock for writes */ |
| 696 | 696 | struct timeval time[DRM_VBLANKTIME_RBSIZE]; |
| 697 | 697 | |
| @@ -168,6 +168,7 @@ struct drm_encoder_helper_funcs { · 167 unmodified lines | ||
| 168 | 168 | * @get_modes: get mode list for this connector |
| 169 | 169 | * @mode_valid: is this mode valid on the given connector? (optional) |
| 170 | 170 | * @best_encoder: return the preferred encoder for this connector |
| 171 | + * @atomic_best_encoder: atomic version of @best_encoder | |
| 171 | 172 | * |
| 172 | 173 | * The helper operations are called by the mid-layer CRTC helper. |
| 173 | 174 | */ |
| @@ -176,6 +177,8 @@ struct drm_connector_helper_funcs { · 2 unmodified lines | ||
| 176 | 177 | enum drm_mode_status (*mode_valid)(struct drm_connector *connector, |
| 177 | 178 | struct drm_display_mode *mode); |
| 178 | 179 | struct drm_encoder *(*best_encoder)(struct drm_connector *connector); |
| 180 | + struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector, | |
| 181 | + struct drm_connector_state *connector_state); | |
| 179 | 182 | }; |
| 180 | 183 | |
| 181 | 184 | extern void drm_helper_disable_unused_functions(struct drm_device *dev); |
| @@ -172,6 +172,7 @@ · 171 unmodified lines | ||
| 172 | 172 | {0x1002, 0x6610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \ |
| 173 | 173 | {0x1002, 0x6611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \ |
| 174 | 174 | {0x1002, 0x6613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_NEW_MEMMAP}, \ |
| 175 | + {0x1002, 0x6617, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ | |
| 175 | 176 | {0x1002, 0x6620, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
| 176 | 177 | {0x1002, 0x6621, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
| 177 | 178 | {0x1002, 0x6623, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_OLAND|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ |
| @@ -55,7 +55,8 @@ struct vm_fault; · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | extern void __init inode_init(void); |
| 57 | 57 | extern void __init inode_init_early(void); |
| 58 | −extern void __init files_init(unsigned long); | |
| 58 | +extern void __init files_init(void); | |
| 59 | +extern void __init files_maxfiles_init(void); | |
| 59 | 60 | |
| 60 | 61 | extern struct files_stat_struct files_stat; |
| 61 | 62 | extern unsigned long get_max_files(void); |
| @@ -2245,7 +2246,7 @@ extern int ioctl_preallocate(struct file *filp, void __user *argp); · 2183 unmodified lines | ||
| 2245 | 2246 | |
| 2246 | 2247 | /* fs/dcache.c */ |
| 2247 | 2248 | extern void __init vfs_caches_init_early(void); |
| 2248 | −extern void __init vfs_caches_init(unsigned long); | |
| 2249 | +extern void __init vfs_caches_init(void); | |
| 2249 | 2250 | |
| 2250 | 2251 | extern struct kmem_cache *names_cachep; |
| 2251 | 2252 | |
| @@ -631,15 +631,19 @@ static inline void ClearPageSlabPfmemalloc(struct page *page) · 630 unmodified lines | ||
| 631 | 631 | 1 << PG_private | 1 << PG_private_2 | \ |
| 632 | 632 | 1 << PG_writeback | 1 << PG_reserved | \ |
| 633 | 633 | 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \ |
| 634 | − 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON | \ | |
| 634 | + 1 << PG_unevictable | __PG_MLOCKED | \ | |
| 635 | 635 | __PG_COMPOUND_LOCK) |
| 636 | 636 | |
| 637 | 637 | /* |
| 638 | 638 | * Flags checked when a page is prepped for return by the page allocator. |
| 639 | − * Pages being prepped should not have any flags set. It they are set, | |
| 639 | + * Pages being prepped should not have these flags set. It they are set, | |
| 640 | 640 | * there has been a kernel bug or struct page corruption. |
| 641 | + * | |
| 642 | + * __PG_HWPOISON is exceptional because it needs to be kept beyond page's | |
| 643 | + * alloc-free cycle to prevent from reusing the page. | |
| 641 | 644 | */ |
| 642 | −#define PAGE_FLAGS_CHECK_AT_PREP ((1 << NR_PAGEFLAGS) - 1) | |
| 645 | +#define PAGE_FLAGS_CHECK_AT_PREP \ | |
| 646 | + (((1 << NR_PAGEFLAGS) - 1) & ~__PG_HWPOISON) | |
| 643 | 647 | |
| 644 | 648 | #define PAGE_FLAGS_PRIVATE \ |
| 645 | 649 | (1 << PG_private | 1 << PG_private_2) |
| @@ -2913,11 +2913,11 @@ static inline bool skb_defer_rx_timestamp(struct sk_buff *skb) · 2912 unmodified lines | ||
| 2913 | 2913 | * |
| 2914 | 2914 | * PHY drivers may accept clones of transmitted packets for |
| 2915 | 2915 | * timestamping via their phy_driver.txtstamp method. These drivers |
| 2916 | − * must call this function to return the skb back to the stack, with | |
| 2917 | − * or without a timestamp. | |
| 2916 | + * must call this function to return the skb back to the stack with a | |
| 2917 | + * timestamp. | |
| 2918 | 2918 | * |
| 2919 | 2919 | * @skb: clone of the the original outgoing packet |
| 2920 | − * @hwtstamps: hardware time stamps, may be NULL if not available | |
| 2920 | + * @hwtstamps: hardware time stamps | |
| 2921 | 2921 | * |
| 2922 | 2922 | */ |
| 2923 | 2923 | void skb_complete_tx_timestamp(struct sk_buff *skb, |
| @@ -319,6 +319,7 @@ · 318 unmodified lines | ||
| 319 | 319 | #define PCI_MSIX_PBA 8 /* Pending Bit Array offset */ |
| 320 | 320 | #define PCI_MSIX_PBA_BIR 0x00000007 /* BAR index */ |
| 321 | 321 | #define PCI_MSIX_PBA_OFFSET 0xfffffff8 /* Offset into specified BAR */ |
| 322 | +#define PCI_MSIX_FLAGS_BIRMASK PCI_MSIX_PBA_BIR /* deprecated */ | |
| 322 | 323 | #define PCI_CAP_MSIX_SIZEOF 12 /* size of MSIX registers */ |
| 323 | 324 | |
| 324 | 325 | /* MSI-X Table entry format */ |
| @@ -77,7 +77,7 @@ · 76 unmodified lines | ||
| 77 | 77 | #define SND_SOC_TPLG_NUM_TEXTS 16 |
| 78 | 78 | |
| 79 | 79 | /* ABI version */ |
| 80 | −#define SND_SOC_TPLG_ABI_VERSION 0x2 | |
| 80 | +#define SND_SOC_TPLG_ABI_VERSION 0x3 | |
| 81 | 81 | |
| 82 | 82 | /* Max size of TLV data */ |
| 83 | 83 | #define SND_SOC_TPLG_TLV_SIZE 32 |
| @@ -97,7 +97,8 @@ · 13 unmodified lines | ||
| 97 | 97 | #define SND_SOC_TPLG_TYPE_PCM 7 |
| 98 | 98 | #define SND_SOC_TPLG_TYPE_MANIFEST 8 |
| 99 | 99 | #define SND_SOC_TPLG_TYPE_CODEC_LINK 9 |
| 100 | −#define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_CODEC_LINK | |
| 100 | +#define SND_SOC_TPLG_TYPE_PDATA 10 | |
| 101 | +#define SND_SOC_TPLG_TYPE_MAX SND_SOC_TPLG_TYPE_PDATA | |
| 101 | 102 | |
| 102 | 103 | /* vendor block IDs - please add new vendor types to end */ |
| 103 | 104 | #define SND_SOC_TPLG_TYPE_VENDOR_FW 1000 |
| @@ -137,11 +138,19 @@ struct snd_soc_tplg_private { · 33 unmodified lines | ||
| 137 | 138 | /* |
| 138 | 139 | * Kcontrol TLV data. |
| 139 | 140 | */ |
| 141 | +struct snd_soc_tplg_tlv_dbscale { | |
| 142 | + __le32 min; | |
| 143 | + __le32 step; | |
| 144 | + __le32 mute; | |
| 145 | +} __attribute__((packed)); | |
| 146 | + | |
| 140 | 147 | struct snd_soc_tplg_ctl_tlv { |
| 141 | − __le32 size; /* in bytes aligned to 4 */ | |
| 142 | − __le32 numid; /* control element numeric identification */ | |
| 143 | − __le32 count; /* number of elem in data array */ | |
| 144 | − __le32 data[SND_SOC_TPLG_TLV_SIZE]; | |
| 148 | + __le32 size; /* in bytes of this structure */ | |
| 149 | + __le32 type; /* SNDRV_CTL_TLVT_*, type of TLV */ | |
| 150 | + union { | |
| 151 | + __le32 data[SND_SOC_TPLG_TLV_SIZE]; | |
| 152 | + struct snd_soc_tplg_tlv_dbscale scale; | |
| 153 | + }; | |
| 145 | 154 | } __attribute__((packed)); |
| 146 | 155 | |
| 147 | 156 | /* |
| @@ -155,9 +164,11 @@ struct snd_soc_tplg_channel { · 7 unmodified lines | ||
| 155 | 164 | } __attribute__((packed)); |
| 156 | 165 | |
| 157 | 166 | /* |
| 158 | − * Kcontrol Operations IDs | |
| 167 | + * Genericl Operations IDs, for binding Kcontrol or Bytes ext ops | |
| 168 | + * Kcontrol ops need get/put/info. | |
| 169 | + * Bytes ext ops need get/put. | |
| 159 | 170 | */ |
| 160 | −struct snd_soc_tplg_kcontrol_ops_id { | |
| 171 | +struct snd_soc_tplg_io_ops { | |
| 161 | 172 | __le32 get; |
| 162 | 173 | __le32 put; |
| 163 | 174 | __le32 info; |
| @@ -171,8 +182,8 @@ struct snd_soc_tplg_ctl_hdr { · 7 unmodified lines | ||
| 171 | 182 | __le32 type; |
| 172 | 183 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; |
| 173 | 184 | __le32 access; |
| 174 | − struct snd_soc_tplg_kcontrol_ops_id ops; | |
| 175 | − __le32 tlv_size; /* non zero means control has TLV data */ | |
| 185 | + struct snd_soc_tplg_io_ops ops; | |
| 186 | + struct snd_soc_tplg_ctl_tlv tlv; | |
| 176 | 187 | } __attribute__((packed)); |
| 177 | 188 | |
| 178 | 189 | /* |
| @@ -238,6 +249,7 @@ struct snd_soc_tplg_manifest { · 59 unmodified lines | ||
| 238 | 249 | __le32 graph_elems; /* number of graph elements */ |
| 239 | 250 | __le32 dai_elems; /* number of DAI elements */ |
| 240 | 251 | __le32 dai_link_elems; /* number of DAI link elements */ |
| 252 | + struct snd_soc_tplg_private priv; | |
| 241 | 253 | } __attribute__((packed)); |
| 242 | 254 | |
| 243 | 255 | /* |
| @@ -259,7 +271,6 @@ struct snd_soc_tplg_mixer_control { · 15 unmodified lines | ||
| 259 | 271 | __le32 invert; |
| 260 | 272 | __le32 num_channels; |
| 261 | 273 | struct snd_soc_tplg_channel channel[SND_SOC_TPLG_MAX_CHAN]; |
| 262 | − struct snd_soc_tplg_ctl_tlv tlv; | |
| 263 | 274 | struct snd_soc_tplg_private priv; |
| 264 | 275 | } __attribute__((packed)); |
| 265 | 276 | |
| @@ -303,6 +314,7 @@ struct snd_soc_tplg_bytes_control { · 37 unmodified lines | ||
| 303 | 314 | __le32 mask; |
| 304 | 315 | __le32 base; |
| 305 | 316 | __le32 num_regs; |
| 317 | + struct snd_soc_tplg_io_ops ext_ops; | |
| 306 | 318 | struct snd_soc_tplg_private priv; |
| 307 | 319 | } __attribute__((packed)); |
| 308 | 320 | |
| @@ -347,6 +359,7 @@ struct snd_soc_tplg_dapm_widget { · 38 unmodified lines | ||
| 347 | 359 | __le32 reg; /* negative reg = no direct dapm */ |
| 348 | 360 | __le32 shift; /* bits to shift */ |
| 349 | 361 | __le32 mask; /* non-shifted mask */ |
| 362 | + __le32 subseq; /* sort within widget type */ | |
| 350 | 363 | __u32 invert; /* invert the power bit */ |
| 351 | 364 | __u32 ignore_suspend; /* kept enabled over suspend */ |
| 352 | 365 | __u16 event_flags; |
| @@ -656,7 +656,7 @@ asmlinkage __visible void __init start_kernel(void) · 655 unmodified lines | ||
| 656 | 656 | key_init(); |
| 657 | 657 | security_init(); |
| 658 | 658 | dbg_late_init(); |
| 659 | − vfs_caches_init(totalram_pages); | |
| 659 | + vfs_caches_init(); | |
| 660 | 660 | signals_init(); |
| 661 | 661 | /* rootfs populating might need page-writeback */ |
| 662 | 662 | page_writeback_init(); |
| @@ -142,7 +142,6 @@ static int msg_insert(struct msg_msg *msg, struct mqueue_inode_info *info) · 141 unmodified lines | ||
| 142 | 142 | if (!leaf) |
| 143 | 143 | return -ENOMEM; |
| 144 | 144 | INIT_LIST_HEAD(&leaf->msg_list); |
| 145 | − info->qsize += sizeof(*leaf); | |
| 146 | 145 | } |
| 147 | 146 | leaf->priority = msg->m_type; |
| 148 | 147 | rb_link_node(&leaf->rb_node, parent, p); |
| @@ -187,7 +186,6 @@ try_again: · 38 unmodified lines | ||
| 187 | 186 | "lazy leaf delete!\n"); |
| 188 | 187 | rb_erase(&leaf->rb_node, &info->msg_tree); |
| 189 | 188 | if (info->node_cache) { |
| 190 | − info->qsize -= sizeof(*leaf); | |
| 191 | 189 | kfree(leaf); |
| 192 | 190 | } else { |
| 193 | 191 | info->node_cache = leaf; |
| @@ -200,7 +198,6 @@ try_again: · 6 unmodified lines | ||
| 200 | 198 | if (list_empty(&leaf->msg_list)) { |
| 201 | 199 | rb_erase(&leaf->rb_node, &info->msg_tree); |
| 202 | 200 | if (info->node_cache) { |
| 203 | − info->qsize -= sizeof(*leaf); | |
| 204 | 201 | kfree(leaf); |
| 205 | 202 | } else { |
| 206 | 203 | info->node_cache = leaf; |
| @@ -1034,7 +1031,6 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr, · 827 unmodified lines | ||
| 1034 | 1031 | /* Save our speculative allocation into the cache */ |
| 1035 | 1032 | INIT_LIST_HEAD(&new_leaf->msg_list); |
| 1036 | 1033 | info->node_cache = new_leaf; |
| 1037 | − info->qsize += sizeof(*new_leaf); | |
| 1038 | 1034 | new_leaf = NULL; |
| 1039 | 1035 | } else { |
| 1040 | 1036 | kfree(new_leaf); |
| @@ -1142,7 +1138,6 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, · 101 unmodified lines | ||
| 1142 | 1138 | /* Save our speculative allocation into the cache */ |
| 1143 | 1139 | INIT_LIST_HEAD(&new_leaf->msg_list); |
| 1144 | 1140 | info->node_cache = new_leaf; |
| 1145 | − info->qsize += sizeof(*new_leaf); | |
| 1146 | 1141 | } else { |
| 1147 | 1142 | kfree(new_leaf); |
| 1148 | 1143 | } |
| @@ -545,7 +545,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) · 544 unmodified lines | ||
| 545 | 545 | if ((shmflg & SHM_NORESERVE) && |
| 546 | 546 | sysctl_overcommit_memory != OVERCOMMIT_NEVER) |
| 547 | 547 | acctflag = VM_NORESERVE; |
| 548 | − file = shmem_file_setup(name, size, acctflag); | |
| 548 | + file = shmem_kernel_file_setup(name, size, acctflag); | |
| 549 | 549 | } |
| 550 | 550 | error = PTR_ERR(file); |
| 551 | 551 | if (IS_ERR(file)) |
| @@ -97,6 +97,7 @@ bool kthread_should_park(void) · 96 unmodified lines | ||
| 97 | 97 | { |
| 98 | 98 | return test_bit(KTHREAD_SHOULD_PARK, &to_kthread(current)->flags); |
| 99 | 99 | } |
| 100 | +EXPORT_SYMBOL_GPL(kthread_should_park); | |
| 100 | 101 | |
| 101 | 102 | /** |
| 102 | 103 | * kthread_freezable_should_stop - should this freezable kthread return now? |
| @@ -171,6 +172,7 @@ void kthread_parkme(void) · 68 unmodified lines | ||
| 171 | 172 | { |
| 172 | 173 | __kthread_parkme(to_kthread(current)); |
| 173 | 174 | } |
| 175 | +EXPORT_SYMBOL_GPL(kthread_parkme); | |
| 174 | 176 | |
| 175 | 177 | static int kthread(void *_create) |
| 176 | 178 | { |
| @@ -411,6 +413,7 @@ void kthread_unpark(struct task_struct *k) · 234 unmodified lines | ||
| 411 | 413 | if (kthread) |
| 412 | 414 | __kthread_unpark(k, kthread); |
| 413 | 415 | } |
| 416 | +EXPORT_SYMBOL_GPL(kthread_unpark); | |
| 414 | 417 | |
| 415 | 418 | /** |
| 416 | 419 | * kthread_park - park a thread created by kthread_create(). |
| @@ -441,6 +444,7 @@ int kthread_park(struct task_struct *k) · 24 unmodified lines | ||
| 441 | 444 | } |
| 442 | 445 | return ret; |
| 443 | 446 | } |
| 447 | +EXPORT_SYMBOL_GPL(kthread_park); | |
| 444 | 448 | |
| 445 | 449 | /** |
| 446 | 450 | * kthread_stop - stop a thread created by kthread_create(). |
| @@ -602,13 +602,16 @@ const struct kernel_symbol *find_symbol(const char *name, · 601 unmodified lines | ||
| 602 | 602 | } |
| 603 | 603 | EXPORT_SYMBOL_GPL(find_symbol); |
| 604 | 604 | |
| 605 | −/* Search for module by name: must hold module_mutex. */ | |
| 605 | +/* | |
| 606 | + * Search for module by name: must hold module_mutex (or preempt disabled | |
| 607 | + * for read-only access). | |
| 608 | + */ | |
| 606 | 609 | static struct module *find_module_all(const char *name, size_t len, |
| 607 | 610 | bool even_unformed) |
| 608 | 611 | { |
| 609 | 612 | struct module *mod; |
| 610 | 613 | |
| 611 | − module_assert_mutex(); | |
| 614 | + module_assert_mutex_or_preempt(); | |
| 612 | 615 | |
| 613 | 616 | list_for_each_entry(mod, &modules, list) { |
| 614 | 617 | if (!even_unformed && mod->state == MODULE_STATE_UNFORMED) |
| @@ -621,6 +624,7 @@ static struct module *find_module_all(const char *name, size_t len, · 6 unmodified lines | ||
| 621 | 624 | |
| 622 | 625 | struct module *find_module(const char *name) |
| 623 | 626 | { |
| 627 | + module_assert_mutex(); | |
| 624 | 628 | return find_module_all(name, strlen(name), false); |
| 625 | 629 | } |
| 626 | 630 | EXPORT_SYMBOL_GPL(find_module); |
| @@ -2748,12 +2748,15 @@ int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from) · 2747 unmodified lines | ||
| 2748 | 2748 | * Other callers might not initialize the si_lsb field, |
| 2749 | 2749 | * so check explicitly for the right codes here. |
| 2750 | 2750 | */ |
| 2751 | − if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO) | |
| 2751 | + if (from->si_signo == SIGBUS && | |
| 2752 | + (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)) | |
| 2752 | 2753 | err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); |
| 2753 | 2754 | #endif |
| 2754 | 2755 | #ifdef SEGV_BNDERR |
| 2755 | − err |= __put_user(from->si_lower, &to->si_lower); | |
| 2756 | − err |= __put_user(from->si_upper, &to->si_upper); | |
| 2756 | + if (from->si_signo == SIGSEGV && from->si_code == SEGV_BNDERR) { | |
| 2757 | + err |= __put_user(from->si_lower, &to->si_lower); | |
| 2758 | + err |= __put_user(from->si_upper, &to->si_upper); | |
| 2759 | + } | |
| 2757 | 2760 | #endif |
| 2758 | 2761 | break; |
| 2759 | 2762 | case __SI_CHLD: |
| @@ -3017,7 +3020,7 @@ COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo, · 257 unmodified lines | ||
| 3017 | 3020 | int, sig, |
| 3018 | 3021 | struct compat_siginfo __user *, uinfo) |
| 3019 | 3022 | { |
| 3020 | − siginfo_t info; | |
| 3023 | + siginfo_t info = {}; | |
| 3021 | 3024 | int ret = copy_siginfo_from_user32(&info, uinfo); |
| 3022 | 3025 | if (unlikely(ret)) |
| 3023 | 3026 | return ret; |
| @@ -3061,7 +3064,7 @@ COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo, · 37 unmodified lines | ||
| 3061 | 3064 | int, sig, |
| 3062 | 3065 | struct compat_siginfo __user *, uinfo) |
| 3063 | 3066 | { |
| 3064 | − siginfo_t info; | |
| 3067 | + siginfo_t info = {}; | |
| 3065 | 3068 | |
| 3066 | 3069 | if (copy_siginfo_from_user32(&info, uinfo)) |
| 3067 | 3070 | return -EFAULT; |
| @@ -119,7 +119,7 @@ unsigned long iommu_tbl_range_alloc(struct device *dev, · 118 unmodified lines | ||
| 119 | 119 | unsigned long align_mask = 0; |
| 120 | 120 | |
| 121 | 121 | if (align_order > 0) |
| 122 | − align_mask = 0xffffffffffffffffl >> (64 - align_order); | |
| 122 | + align_mask = ~0ul >> (BITS_PER_LONG - align_order); | |
| 123 | 123 | |
| 124 | 124 | /* Sanity check */ |
| 125 | 125 | if (unlikely(npages == 0)) { |
| @@ -1676,12 +1676,7 @@ static void __split_huge_page_refcount(struct page *page, · 1675 unmodified lines | ||
| 1676 | 1676 | /* after clearing PageTail the gup refcount can be released */ |
| 1677 | 1677 | smp_mb__after_atomic(); |
| 1678 | 1678 | |
| 1679 | − /* | |
| 1680 | − * retain hwpoison flag of the poisoned tail page: | |
| 1681 | − * fix for the unsuitable process killed on Guest Machine(KVM) | |
| 1682 | − * by the memory-failure. | |
| 1683 | − */ | |
| 1684 | − page_tail->flags &= ~PAGE_FLAGS_CHECK_AT_PREP | __PG_HWPOISON; | |
| 1679 | + page_tail->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; | |
| 1685 | 1680 | page_tail->flags |= (page->flags & |
| 1686 | 1681 | ((1L << PG_referenced) | |
| 1687 | 1682 | (1L << PG_swapbacked) | |
| @@ -909,6 +909,18 @@ int get_hwpoison_page(struct page *page) · 908 unmodified lines | ||
| 909 | 909 | * directly for tail pages. |
| 910 | 910 | */ |
| 911 | 911 | if (PageTransHuge(head)) { |
| 912 | + /* | |
| 913 | + * Non anonymous thp exists only in allocation/free time. We | |
| 914 | + * can't handle such a case correctly, so let's give it up. | |
| 915 | + * This should be better than triggering BUG_ON when kernel | |
| 916 | + * tries to touch the "partially handled" page. | |
| 917 | + */ | |
| 918 | + if (!PageAnon(head)) { | |
| 919 | + pr_err("MCE: %#lx: non anonymous thp\n", | |
| 920 | + page_to_pfn(page)); | |
| 921 | + return 0; | |
| 922 | + } | |
| 923 | + | |
| 912 | 924 | if (get_page_unless_zero(head)) { |
| 913 | 925 | if (PageTail(page)) |
| 914 | 926 | get_page(page); |
| @@ -1134,15 +1146,6 @@ int memory_failure(unsigned long pfn, int trapno, int flags) · 219 unmodified lines | ||
| 1134 | 1146 | } |
| 1135 | 1147 | |
| 1136 | 1148 | if (!PageHuge(p) && PageTransHuge(hpage)) { |
| 1137 | − if (!PageAnon(hpage)) { | |
| 1138 | − pr_err("MCE: %#lx: non anonymous thp\n", pfn); | |
| 1139 | − if (TestClearPageHWPoison(p)) | |
| 1140 | − atomic_long_sub(nr_pages, &num_poisoned_pages); | |
| 1141 | − put_page(p); | |
| 1142 | − if (p != hpage) | |
| 1143 | − put_page(hpage); | |
| 1144 | − return -EBUSY; | |
| 1145 | − } | |
| 1146 | 1149 | if (unlikely(split_huge_page(hpage))) { |
| 1147 | 1150 | pr_err("MCE: %#lx: thp split failed\n", pfn); |
| 1148 | 1151 | if (TestClearPageHWPoison(p)) |
| @@ -1209,9 +1212,9 @@ int memory_failure(unsigned long pfn, int trapno, int flags) · 60 unmodified lines | ||
| 1209 | 1212 | if (!PageHWPoison(p)) { |
| 1210 | 1213 | printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn); |
| 1211 | 1214 | atomic_long_sub(nr_pages, &num_poisoned_pages); |
| 1215 | + unlock_page(hpage); | |
| 1212 | 1216 | put_page(hpage); |
| 1213 | − res = 0; | |
| 1214 | − goto out; | |
| 1217 | + return 0; | |
| 1215 | 1218 | } |
| 1216 | 1219 | if (hwpoison_filter(p)) { |
| 1217 | 1220 | if (TestClearPageHWPoison(p)) |
| @@ -1656,6 +1659,8 @@ static int __soft_offline_page(struct page *page, int flags) · 438 unmodified lines | ||
| 1656 | 1659 | inc_zone_page_state(page, NR_ISOLATED_ANON + |
| 1657 | 1660 | page_is_file_cache(page)); |
| 1658 | 1661 | list_add(&page->lru, &pagelist); |
| 1662 | + if (!TestSetPageHWPoison(page)) | |
| 1663 | + atomic_long_inc(&num_poisoned_pages); | |
| 1659 | 1664 | ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, |
| 1660 | 1665 | MIGRATE_SYNC, MR_MEMORY_FAILURE); |
| 1661 | 1666 | if (ret) { |
| @@ -1670,9 +1675,8 @@ static int __soft_offline_page(struct page *page, int flags) · 8 unmodified lines | ||
| 1670 | 1675 | pfn, ret, page->flags); |
| 1671 | 1676 | if (ret > 0) |
| 1672 | 1677 | ret = -EIO; |
| 1673 | − } else { | |
| 1674 | − SetPageHWPoison(page); | |
| 1675 | − atomic_long_inc(&num_poisoned_pages); | |
| 1678 | + if (TestClearPageHWPoison(page)) | |
| 1679 | + atomic_long_dec(&num_poisoned_pages); | |
| 1676 | 1680 | } |
| 1677 | 1681 | } else { |
| 1678 | 1682 | pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n", |
| @@ -446,7 +446,7 @@ static int __meminit __add_zone(struct zone *zone, unsigned long phys_start_pfn) · 445 unmodified lines | ||
| 446 | 446 | int nr_pages = PAGES_PER_SECTION; |
| 447 | 447 | int nid = pgdat->node_id; |
| 448 | 448 | int zone_type; |
| 449 | − unsigned long flags; | |
| 449 | + unsigned long flags, pfn; | |
| 450 | 450 | int ret; |
| 451 | 451 | |
| 452 | 452 | zone_type = zone - pgdat->node_zones; |
| @@ -461,6 +461,14 @@ static int __meminit __add_zone(struct zone *zone, unsigned long phys_start_pfn) · 8 unmodified lines | ||
| 461 | 461 | pgdat_resize_unlock(zone->zone_pgdat, &flags); |
| 462 | 462 | memmap_init_zone(nr_pages, nid, zone_type, |
| 463 | 463 | phys_start_pfn, MEMMAP_HOTPLUG); |
| 464 | + | |
| 465 | + /* online_page_range is called later and expects pages reserved */ | |
| 466 | + for (pfn = phys_start_pfn; pfn < phys_start_pfn + nr_pages; pfn++) { | |
| 467 | + if (!pfn_valid(pfn)) | |
| 468 | + continue; | |
| 469 | + | |
| 470 | + SetPageReserved(pfn_to_page(pfn)); | |
| 471 | + } | |
| 464 | 472 | return 0; |
| 465 | 473 | } |
| 466 | 474 | |
| @@ -880,7 +880,8 @@ static int __unmap_and_move(struct page *page, struct page *newpage, · 879 unmodified lines | ||
| 880 | 880 | /* Establish migration ptes or remove ptes */ |
| 881 | 881 | if (page_mapped(page)) { |
| 882 | 882 | try_to_unmap(page, |
| 883 | − TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS); | |
| 883 | + TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS| | |
| 884 | + TTU_IGNORE_HWPOISON); | |
| 884 | 885 | page_was_mapped = 1; |
| 885 | 886 | } |
| 886 | 887 | |
| @@ -950,7 +951,10 @@ out: · 63 unmodified lines | ||
| 950 | 951 | list_del(&page->lru); |
| 951 | 952 | dec_zone_page_state(page, NR_ISOLATED_ANON + |
| 952 | 953 | page_is_file_cache(page)); |
| 953 | − if (reason != MR_MEMORY_FAILURE) | |
| 954 | + /* Soft-offlined page shouldn't go through lru cache list */ | |
| 955 | + if (reason == MR_MEMORY_FAILURE) | |
| 956 | + put_page(page); | |
| 957 | + else | |
| 954 | 958 | putback_lru_page(page); |
| 955 | 959 | } |
| 956 | 960 | |
| @@ -2063,10 +2063,10 @@ static struct notifier_block ratelimit_nb = { · 2062 unmodified lines | ||
| 2063 | 2063 | */ |
| 2064 | 2064 | void __init page_writeback_init(void) |
| 2065 | 2065 | { |
| 2066 | + BUG_ON(wb_domain_init(&global_wb_domain, GFP_KERNEL)); | |
| 2067 | + | |
| 2066 | 2068 | writeback_set_ratelimit(); |
| 2067 | 2069 | register_cpu_notifier(&ratelimit_nb); |
| 2068 | − | |
| 2069 | − BUG_ON(wb_domain_init(&global_wb_domain, GFP_KERNEL)); | |
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | /** |
| @@ -18,7 +18,6 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <linux/mm.h> |
| 19 | 19 | #include <linux/swap.h> |
| 20 | 20 | #include <linux/interrupt.h> |
| 21 | −#include <linux/rwsem.h> | |
| 22 | 21 | #include <linux/pagemap.h> |
| 23 | 22 | #include <linux/jiffies.h> |
| 24 | 23 | #include <linux/bootmem.h> |
| @@ -981,21 +980,21 @@ static void __init __free_pages_boot_core(struct page *page, · 956 unmodified lines | ||
| 981 | 980 | |
| 982 | 981 | #if defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) || \ |
| 983 | 982 | defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) |
| 984 | −/* Only safe to use early in boot when initialisation is single-threaded */ | |
| 983 | + | |
| 985 | 984 | static struct mminit_pfnnid_cache early_pfnnid_cache __meminitdata; |
| 986 | 985 | |
| 987 | 986 | int __meminit early_pfn_to_nid(unsigned long pfn) |
| 988 | 987 | { |
| 988 | + static DEFINE_SPINLOCK(early_pfn_lock); | |
| 989 | 989 | int nid; |
| 990 | 990 | |
| 991 | − /* The system will behave unpredictably otherwise */ | |
| 992 | − BUG_ON(system_state != SYSTEM_BOOTING); | |
| 993 | − | |
| 991 | + spin_lock(&early_pfn_lock); | |
| 994 | 992 | nid = __early_pfn_to_nid(pfn, &early_pfnnid_cache); |
| 995 | − if (nid >= 0) | |
| 996 | − return nid; | |
| 997 | − /* just returns 0 */ | |
| 998 | − return 0; | |
| 993 | + if (nid < 0) | |
| 994 | + nid = 0; | |
| 995 | + spin_unlock(&early_pfn_lock); | |
| 996 | + | |
| 997 | + return nid; | |
| 999 | 998 | } |
| 1000 | 999 | #endif |
| 1001 | 1000 | |
| @@ -1060,7 +1059,15 @@ static void __init deferred_free_range(struct page *page, · 58 unmodified lines | ||
| 1060 | 1059 | __free_pages_boot_core(page, pfn, 0); |
| 1061 | 1060 | } |
| 1062 | 1061 | |
| 1063 | −static __initdata DECLARE_RWSEM(pgdat_init_rwsem); | |
| 1062 | +/* Completion tracking for deferred_init_memmap() threads */ | |
| 1063 | +static atomic_t pgdat_init_n_undone __initdata; | |
| 1064 | +static __initdata DECLARE_COMPLETION(pgdat_init_all_done_comp); | |
| 1065 | + | |
| 1066 | +static inline void __init pgdat_init_report_one_done(void) | |
| 1067 | +{ | |
| 1068 | + if (atomic_dec_and_test(&pgdat_init_n_undone)) | |
| 1069 | + complete(&pgdat_init_all_done_comp); | |
| 1070 | +} | |
| 1064 | 1071 | |
| 1065 | 1072 | /* Initialise remaining memory on a node */ |
| 1066 | 1073 | static int __init deferred_init_memmap(void *data) |
| @@ -1077,7 +1084,7 @@ static int __init deferred_init_memmap(void *data) · 10 unmodified lines | ||
| 1077 | 1084 | const struct cpumask *cpumask = cpumask_of_node(pgdat->node_id); |
| 1078 | 1085 | |
| 1079 | 1086 | if (first_init_pfn == ULONG_MAX) { |
| 1080 | − up_read(&pgdat_init_rwsem); | |
| 1087 | + pgdat_init_report_one_done(); | |
| 1081 | 1088 | return 0; |
| 1082 | 1089 | } |
| 1083 | 1090 | |
| @@ -1177,7 +1184,8 @@ free_range: · 93 unmodified lines | ||
| 1177 | 1184 | |
| 1178 | 1185 | pr_info("node %d initialised, %lu pages in %ums\n", nid, nr_pages, |
| 1179 | 1186 | jiffies_to_msecs(jiffies - start)); |
| 1180 | − up_read(&pgdat_init_rwsem); | |
| 1187 | + | |
| 1188 | + pgdat_init_report_one_done(); | |
| 1181 | 1189 | return 0; |
| 1182 | 1190 | } |
| 1183 | 1191 | |
| @@ -1185,14 +1193,17 @@ void __init page_alloc_init_late(void) · 1 unmodified line | ||
| 1185 | 1193 | { |
| 1186 | 1194 | int nid; |
| 1187 | 1195 | |
| 1196 | + /* There will be num_node_state(N_MEMORY) threads */ | |
| 1197 | + atomic_set(&pgdat_init_n_undone, num_node_state(N_MEMORY)); | |
| 1188 | 1198 | for_each_node_state(nid, N_MEMORY) { |
| 1189 | − down_read(&pgdat_init_rwsem); | |
| 1190 | 1199 | kthread_run(deferred_init_memmap, NODE_DATA(nid), "pgdatinit%d", nid); |
| 1191 | 1200 | } |
| 1192 | 1201 | |
| 1193 | 1202 | /* Block until all are initialised */ |
| 1194 | − down_write(&pgdat_init_rwsem); | |
| 1195 | − up_write(&pgdat_init_rwsem); | |
| 1203 | + wait_for_completion(&pgdat_init_all_done_comp); | |
| 1204 | + | |
| 1205 | + /* Reinit limits that are based on free pages after the kernel is up */ | |
| 1206 | + files_maxfiles_init(); | |
| 1196 | 1207 | } |
| 1197 | 1208 | #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ |
| 1198 | 1209 | |
| @@ -1285,6 +1296,10 @@ static inline int check_new_page(struct page *page) · 86 unmodified lines | ||
| 1285 | 1296 | bad_reason = "non-NULL mapping"; |
| 1286 | 1297 | if (unlikely(atomic_read(&page->_count) != 0)) |
| 1287 | 1298 | bad_reason = "nonzero _count"; |
| 1299 | + if (unlikely(page->flags & __PG_HWPOISON)) { | |
| 1300 | + bad_reason = "HWPoisoned (hardware-corrupted)"; | |
| 1301 | + bad_flags = __PG_HWPOISON; | |
| 1302 | + } | |
| 1288 | 1303 | if (unlikely(page->flags & PAGE_FLAGS_CHECK_AT_PREP)) { |
| 1289 | 1304 | bad_reason = "PAGE_FLAGS_CHECK_AT_PREP flag set"; |
| 1290 | 1305 | bad_flags = PAGE_FLAGS_CHECK_AT_PREP; |
| @@ -3363,8 +3363,8 @@ put_path: · 3362 unmodified lines | ||
| 3363 | 3363 | * shmem_kernel_file_setup - get an unlinked file living in tmpfs which must be |
| 3364 | 3364 | * kernel internal. There will be NO LSM permission checks against the |
| 3365 | 3365 | * underlying inode. So users of this interface must do LSM checks at a |
| 3366 | − * higher layer. The one user is the big_key implementation. LSM checks | |
| 3367 | − * are provided at the key level rather than the inode level. | |
| 3366 | + * higher layer. The users are the big_key and shm implementations. LSM | |
| 3367 | + * checks are provided at the key or shm level rather than the inode. | |
| 3368 | 3368 | * @name: name for dentry (to be seen in /proc/<pid>/maps |
| 3369 | 3369 | * @size: size to be set for the file |
| 3370 | 3370 | * @flags: VM_NORESERVE suppresses pre-accounting of the entire object size |
| @@ -37,8 +37,7 @@ struct kmem_cache *kmem_cache; · 36 unmodified lines | ||
| 37 | 37 | SLAB_TRACE | SLAB_DESTROY_BY_RCU | SLAB_NOLEAKTRACE | \ |
| 38 | 38 | SLAB_FAILSLAB) |
| 39 | 39 | |
| 40 | −#define SLAB_MERGE_SAME (SLAB_DEBUG_FREE | SLAB_RECLAIM_ACCOUNT | \ | |
| 41 | − SLAB_CACHE_DMA | SLAB_NOTRACK) | |
| 40 | +#define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | SLAB_NOTRACK) | |
| 42 | 41 | |
| 43 | 42 | /* |
| 44 | 43 | * Merge control. If this is set then no merging of slab caches will occur. |
| @@ -973,22 +973,18 @@ static unsigned long shrink_page_list(struct list_head *page_list, · 972 unmodified lines | ||
| 973 | 973 | * caller can stall after page list has been processed. |
| 974 | 974 | * |
| 975 | 975 | * 2) Global or new memcg reclaim encounters a page that is |
| 976 | − * not marked for immediate reclaim or the caller does not | |
| 977 | − * have __GFP_IO. In this case mark the page for immediate | |
| 976 | + * not marked for immediate reclaim, or the caller does not | |
| 977 | + * have __GFP_FS (or __GFP_IO if it's simply going to swap, | |
| 978 | + * not to fs). In this case mark the page for immediate | |
| 978 | 979 | * reclaim and continue scanning. |
| 979 | 980 | * |
| 980 | − * __GFP_IO is checked because a loop driver thread might | |
| 981 | + * Require may_enter_fs because we would wait on fs, which | |
| 982 | + * may not have submitted IO yet. And the loop driver might | |
| 981 | 983 | * enter reclaim, and deadlock if it waits on a page for |
| 982 | 984 | * which it is needed to do the write (loop masks off |
| 983 | 985 | * __GFP_IO|__GFP_FS for this reason); but more thought |
| 984 | 986 | * would probably show more reasons. |
| 985 | 987 | * |
| 986 | − * Don't require __GFP_FS, since we're not going into the | |
| 987 | − * FS, just waiting on its writeback completion. Worryingly, | |
| 988 | − * ext4 gfs2 and xfs allocate pages with | |
| 989 | − * grab_cache_page_write_begin(,,AOP_FLAG_NOFS), so testing | |
| 990 | − * may_enter_fs here is liable to OOM on them. | |
| 991 | − * | |
| 992 | 988 | * 3) Legacy memcg encounters a page that is not already marked |
| 993 | 989 | * PageReclaim. memcg does not have any dirty pages |
| 994 | 990 | * throttling so we could easily OOM just because too many |
| @@ -1005,7 +1001,7 @@ static unsigned long shrink_page_list(struct list_head *page_list, · 10 unmodified lines | ||
| 1005 | 1001 | |
| 1006 | 1002 | /* Case 2 above */ |
| 1007 | 1003 | } else if (sane_reclaim(sc) || |
| 1008 | − !PageReclaim(page) || !(sc->gfp_mask & __GFP_IO)) { | |
| 1004 | + !PageReclaim(page) || !may_enter_fs) { | |
| 1009 | 1005 | /* |
| 1010 | 1006 | * This is slightly racy - end_page_writeback() |
| 1011 | 1007 | * might have just cleared PageReclaim, then |
| @@ -1138,6 +1138,9 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, · 1137 unmodified lines | ||
| 1138 | 1138 | * @bat_priv: the bat priv with all the soft interface information |
| 1139 | 1139 | * @skb: packet to check |
| 1140 | 1140 | * @hdr_size: size of the encapsulation header |
| 1141 | + * | |
| 1142 | + * Returns true if the packet was snooped and consumed by DAT. False if the | |
| 1143 | + * packet has to be delivered to the interface | |
| 1141 | 1144 | */ |
| 1142 | 1145 | bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, |
| 1143 | 1146 | struct sk_buff *skb, int hdr_size) |
| @@ -1145,7 +1148,7 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, · 1 unmodified line | ||
| 1145 | 1148 | uint16_t type; |
| 1146 | 1149 | __be32 ip_src, ip_dst; |
| 1147 | 1150 | uint8_t *hw_src, *hw_dst; |
| 1148 | − bool ret = false; | |
| 1151 | + bool dropped = false; | |
| 1149 | 1152 | unsigned short vid; |
| 1150 | 1153 | |
| 1151 | 1154 | if (!atomic_read(&bat_priv->distributed_arp_table)) |
| @@ -1174,12 +1177,17 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv, · 22 unmodified lines | ||
| 1174 | 1177 | /* if this REPLY is directed to a client of mine, let's deliver the |
| 1175 | 1178 | * packet to the interface |
| 1176 | 1179 | */ |
| 1177 | − ret = !batadv_is_my_client(bat_priv, hw_dst, vid); | |
| 1180 | + dropped = !batadv_is_my_client(bat_priv, hw_dst, vid); | |
| 1181 | + | |
| 1182 | + /* if this REPLY is sent on behalf of a client of mine, let's drop the | |
| 1183 | + * packet because the client will reply by itself | |
| 1184 | + */ | |
| 1185 | + dropped |= batadv_is_my_client(bat_priv, hw_src, vid); | |
| 1178 | 1186 | out: |
| 1179 | − if (ret) | |
| 1187 | + if (dropped) | |
| 1180 | 1188 | kfree_skb(skb); |
| 1181 | − /* if ret == false -> packet has to be delivered to the interface */ | |
| 1182 | − return ret; | |
| 1189 | + /* if dropped == false -> deliver to the interface */ | |
| 1190 | + return dropped; | |
| 1183 | 1191 | } |
| 1184 | 1192 | |
| 1185 | 1193 | /** |
| @@ -439,6 +439,8 @@ static void batadv_gw_node_add(struct batadv_priv *bat_priv, · 438 unmodified lines | ||
| 439 | 439 | |
| 440 | 440 | INIT_HLIST_NODE(&gw_node->list); |
| 441 | 441 | gw_node->orig_node = orig_node; |
| 442 | + gw_node->bandwidth_down = ntohl(gateway->bandwidth_down); | |
| 443 | + gw_node->bandwidth_up = ntohl(gateway->bandwidth_up); | |
| 442 | 444 | atomic_set(&gw_node->refcount, 1); |
| 443 | 445 | |
| 444 | 446 | spin_lock_bh(&bat_priv->gw.list_lock); |
| @@ -479,6 +479,9 @@ out: · 478 unmodified lines | ||
| 479 | 479 | */ |
| 480 | 480 | void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *vlan) |
| 481 | 481 | { |
| 482 | + if (!vlan) | |
| 483 | + return; | |
| 484 | + | |
| 482 | 485 | if (atomic_dec_and_test(&vlan->refcount)) { |
| 483 | 486 | spin_lock_bh(&vlan->bat_priv->softif_vlan_list_lock); |
| 484 | 487 | hlist_del_rcu(&vlan->list); |
| @@ -594,6 +594,9 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, · 593 unmodified lines | ||
| 594 | 594 | |
| 595 | 595 | /* increase the refcounter of the related vlan */ |
| 596 | 596 | vlan = batadv_softif_vlan_get(bat_priv, vid); |
| 597 | + if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d", | |
| 598 | + addr, BATADV_PRINT_VID(vid))) | |
| 599 | + goto out; | |
| 597 | 600 | |
| 598 | 601 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
| 599 | 602 | "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n", |
| @@ -1034,6 +1037,7 @@ uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, · 434 unmodified lines | ||
| 1034 | 1037 | struct batadv_tt_local_entry *tt_local_entry; |
| 1035 | 1038 | uint16_t flags, curr_flags = BATADV_NO_FLAGS; |
| 1036 | 1039 | struct batadv_softif_vlan *vlan; |
| 1040 | + void *tt_entry_exists; | |
| 1037 | 1041 | |
| 1038 | 1042 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid); |
| 1039 | 1043 | if (!tt_local_entry) |
| @@ -1061,11 +1065,22 @@ uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, · 21 unmodified lines | ||
| 1061 | 1065 | * immediately purge it |
| 1062 | 1066 | */ |
| 1063 | 1067 | batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL); |
| 1064 | − hlist_del_rcu(&tt_local_entry->common.hash_entry); | |
| 1068 | + | |
| 1069 | + tt_entry_exists = batadv_hash_remove(bat_priv->tt.local_hash, | |
| 1070 | + batadv_compare_tt, | |
| 1071 | + batadv_choose_tt, | |
| 1072 | + &tt_local_entry->common); | |
| 1073 | + if (!tt_entry_exists) | |
| 1074 | + goto out; | |
| 1075 | + | |
| 1076 | + /* extra call to free the local tt entry */ | |
| 1065 | 1077 | batadv_tt_local_entry_free_ref(tt_local_entry); |
| 1066 | 1078 | |
| 1067 | 1079 | /* decrease the reference held for this vlan */ |
| 1068 | 1080 | vlan = batadv_softif_vlan_get(bat_priv, vid); |
| 1081 | + if (!vlan) | |
| 1082 | + goto out; | |
| 1083 | + | |
| 1069 | 1084 | batadv_softif_vlan_free_ref(vlan); |
| 1070 | 1085 | batadv_softif_vlan_free_ref(vlan); |
| 1071 | 1086 | |
| @@ -1166,8 +1181,10 @@ static void batadv_tt_local_table_free(struct batadv_priv *bat_priv) · 94 unmodified lines | ||
| 1166 | 1181 | /* decrease the reference held for this vlan */ |
| 1167 | 1182 | vlan = batadv_softif_vlan_get(bat_priv, |
| 1168 | 1183 | tt_common_entry->vid); |
| 1169 | − batadv_softif_vlan_free_ref(vlan); | |
| 1170 | − batadv_softif_vlan_free_ref(vlan); | |
| 1184 | + if (vlan) { | |
| 1185 | + batadv_softif_vlan_free_ref(vlan); | |
| 1186 | + batadv_softif_vlan_free_ref(vlan); | |
| 1187 | + } | |
| 1171 | 1188 | |
| 1172 | 1189 | batadv_tt_local_entry_free_ref(tt_local); |
| 1173 | 1190 | } |
| @@ -3207,8 +3224,10 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) · 2033 unmodified lines | ||
| 3207 | 3224 | |
| 3208 | 3225 | /* decrease the reference held for this vlan */ |
| 3209 | 3226 | vlan = batadv_softif_vlan_get(bat_priv, tt_common->vid); |
| 3210 | − batadv_softif_vlan_free_ref(vlan); | |
| 3211 | − batadv_softif_vlan_free_ref(vlan); | |
| 3227 | + if (vlan) { | |
| 3228 | + batadv_softif_vlan_free_ref(vlan); | |
| 3229 | + batadv_softif_vlan_free_ref(vlan); | |
| 3230 | + } | |
| 3212 | 3231 | |
| 3213 | 3232 | batadv_tt_local_entry_free_ref(tt_local); |
| 3214 | 3233 | } |
| @@ -7843,7 +7843,7 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent) · 7842 unmodified lines | ||
| 7843 | 7843 | /* Make sure we copy only the significant bytes based on the |
| 7844 | 7844 | * encryption key size, and set the rest of the value to zeroes. |
| 7845 | 7845 | */ |
| 7846 | − memcpy(ev.key.val, key->val, sizeof(key->enc_size)); | |
| 7846 | + memcpy(ev.key.val, key->val, key->enc_size); | |
| 7847 | 7847 | memset(ev.key.val + key->enc_size, 0, |
| 7848 | 7848 | sizeof(ev.key.val) - key->enc_size); |
| 7849 | 7849 | |
| @@ -112,6 +112,8 @@ static inline size_t br_port_info_size(void) · 111 unmodified lines | ||
| 112 | 112 | + nla_total_size(1) /* IFLA_BRPORT_FAST_LEAVE */ |
| 113 | 113 | + nla_total_size(1) /* IFLA_BRPORT_LEARNING */ |
| 114 | 114 | + nla_total_size(1) /* IFLA_BRPORT_UNICAST_FLOOD */ |
| 115 | + + nla_total_size(1) /* IFLA_BRPORT_PROXYARP */ | |
| 116 | + + nla_total_size(1) /* IFLA_BRPORT_PROXYARP_WIFI */ | |
| 115 | 117 | + 0; |
| 116 | 118 | } |
| 117 | 119 | |
| @@ -504,6 +506,8 @@ static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = { · 386 unmodified lines | ||
| 504 | 506 | [IFLA_BRPORT_FAST_LEAVE]= { .type = NLA_U8 }, |
| 505 | 507 | [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 }, |
| 506 | 508 | [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 }, |
| 509 | + [IFLA_BRPORT_PROXYARP] = { .type = NLA_U8 }, | |
| 510 | + [IFLA_BRPORT_PROXYARP_WIFI] = { .type = NLA_U8 }, | |
| 507 | 511 | }; |
| 508 | 512 | |
| 509 | 513 | /* Change the state of the port and notify spanning tree */ |
| @@ -131,12 +131,12 @@ out_noerr: · 130 unmodified lines | ||
| 131 | 131 | goto out; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | −static int skb_set_peeked(struct sk_buff *skb) | |
| 134 | +static struct sk_buff *skb_set_peeked(struct sk_buff *skb) | |
| 135 | 135 | { |
| 136 | 136 | struct sk_buff *nskb; |
| 137 | 137 | |
| 138 | 138 | if (skb->peeked) |
| 139 | − return 0; | |
| 139 | + return skb; | |
| 140 | 140 | |
| 141 | 141 | /* We have to unshare an skb before modifying it. */ |
| 142 | 142 | if (!skb_shared(skb)) |
| @@ -144,7 +144,7 @@ static int skb_set_peeked(struct sk_buff *skb) · 1 unmodified line | ||
| 144 | 144 | |
| 145 | 145 | nskb = skb_clone(skb, GFP_ATOMIC); |
| 146 | 146 | if (!nskb) |
| 147 | − return -ENOMEM; | |
| 147 | + return ERR_PTR(-ENOMEM); | |
| 148 | 148 | |
| 149 | 149 | skb->prev->next = nskb; |
| 150 | 150 | skb->next->prev = nskb; |
| @@ -157,7 +157,7 @@ static int skb_set_peeked(struct sk_buff *skb) · 6 unmodified lines | ||
| 157 | 157 | done: |
| 158 | 158 | skb->peeked = 1; |
| 159 | 159 | |
| 160 | − return 0; | |
| 160 | + return skb; | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
| @@ -229,8 +229,9 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags, · 65 unmodified lines | ||
| 229 | 229 | continue; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | − error = skb_set_peeked(skb); | |
| 233 | − if (error) | |
| 232 | + skb = skb_set_peeked(skb); | |
| 233 | + error = PTR_ERR(skb); | |
| 234 | + if (IS_ERR(skb)) | |
| 234 | 235 | goto unlock_err; |
| 235 | 236 | |
| 236 | 237 | atomic_inc(&skb->users); |
| @@ -3513,8 +3513,6 @@ static int pktgen_thread_worker(void *arg) · 3512 unmodified lines | ||
| 3513 | 3513 | |
| 3514 | 3514 | set_freezable(); |
| 3515 | 3515 | |
| 3516 | − __set_current_state(TASK_RUNNING); | |
| 3517 | − | |
| 3518 | 3516 | while (!kthread_should_stop()) { |
| 3519 | 3517 | pkt_dev = next_to_run(t); |
| 3520 | 3518 | |
| @@ -3559,7 +3557,6 @@ static int pktgen_thread_worker(void *arg) · 38 unmodified lines | ||
| 3559 | 3557 | |
| 3560 | 3558 | try_to_freeze(); |
| 3561 | 3559 | } |
| 3562 | − set_current_state(TASK_INTERRUPTIBLE); | |
| 3563 | 3560 | |
| 3564 | 3561 | pr_debug("%s stopping all device\n", t->tsk->comm); |
| 3565 | 3562 | pktgen_stop(t); |
| @@ -103,10 +103,16 @@ void reqsk_queue_destroy(struct request_sock_queue *queue) · 102 unmodified lines | ||
| 103 | 103 | spin_lock_bh(&queue->syn_wait_lock); |
| 104 | 104 | while ((req = lopt->syn_table[i]) != NULL) { |
| 105 | 105 | lopt->syn_table[i] = req->dl_next; |
| 106 | + /* Because of following del_timer_sync(), | |
| 107 | + * we must release the spinlock here | |
| 108 | + * or risk a dead lock. | |
| 109 | + */ | |
| 110 | + spin_unlock_bh(&queue->syn_wait_lock); | |
| 106 | 111 | atomic_inc(&lopt->qlen_dec); |
| 107 | − if (del_timer(&req->rsk_timer)) | |
| 112 | + if (del_timer_sync(&req->rsk_timer)) | |
| 108 | 113 | reqsk_put(req); |
| 109 | 114 | reqsk_put(req); |
| 115 | + spin_lock_bh(&queue->syn_wait_lock); | |
| 110 | 116 | } |
| 111 | 117 | spin_unlock_bh(&queue->syn_wait_lock); |
| 112 | 118 | } |
| @@ -856,7 +856,8 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p, · 855 unmodified lines | ||
| 856 | 856 | return -ENODEV; |
| 857 | 857 | |
| 858 | 858 | /* Use already configured phy mode */ |
| 859 | − p->phy_interface = p->phy->interface; | |
| 859 | + if (p->phy_interface == PHY_INTERFACE_MODE_NA) | |
| 860 | + p->phy_interface = p->phy->interface; | |
| 860 | 861 | phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, |
| 861 | 862 | p->phy_interface); |
| 862 | 863 | |
| @@ -593,7 +593,7 @@ static bool reqsk_queue_unlink(struct request_sock_queue *queue, · 592 unmodified lines | ||
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | spin_unlock(&queue->syn_wait_lock); |
| 596 | − if (del_timer(&req->rsk_timer)) | |
| 596 | + if (del_timer_sync(&req->rsk_timer)) | |
| 597 | 597 | reqsk_put(req); |
| 598 | 598 | return found; |
| 599 | 599 | } |
| @@ -226,7 +226,8 @@ synproxy_send_client_ack(const struct synproxy_net *snet, · 225 unmodified lines | ||
| 226 | 226 | |
| 227 | 227 | synproxy_build_options(nth, opts); |
| 228 | 228 | |
| 229 | − synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); | |
| 229 | + synproxy_send_tcp(skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, | |
| 230 | + niph, nth, tcp_hdr_size); | |
| 230 | 231 | } |
| 231 | 232 | |
| 232 | 233 | static bool |
| @@ -1348,7 +1348,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) · 1347 unmodified lines | ||
| 1348 | 1348 | req = inet_csk_search_req(sk, th->source, iph->saddr, iph->daddr); |
| 1349 | 1349 | if (req) { |
| 1350 | 1350 | nsk = tcp_check_req(sk, skb, req, false); |
| 1351 | − if (!nsk) | |
| 1351 | + if (!nsk || nsk == sk) | |
| 1352 | 1352 | reqsk_put(req); |
| 1353 | 1353 | return nsk; |
| 1354 | 1354 | } |
| @@ -1995,12 +1995,19 @@ void udp_v4_early_demux(struct sk_buff *skb) · 1994 unmodified lines | ||
| 1995 | 1995 | |
| 1996 | 1996 | skb->sk = sk; |
| 1997 | 1997 | skb->destructor = sock_efree; |
| 1998 | − dst = sk->sk_rx_dst; | |
| 1998 | + dst = READ_ONCE(sk->sk_rx_dst); | |
| 1999 | 1999 | |
| 2000 | 2000 | if (dst) |
| 2001 | 2001 | dst = dst_check(dst, 0); |
| 2002 | − if (dst) | |
| 2003 | − skb_dst_set_noref(skb, dst); | |
| 2002 | + if (dst) { | |
| 2003 | + /* DST_NOCACHE can not be used without taking a reference */ | |
| 2004 | + if (dst->flags & DST_NOCACHE) { | |
| 2005 | + if (likely(atomic_inc_not_zero(&dst->__refcnt))) | |
| 2006 | + skb_dst_set(skb, dst); | |
| 2007 | + } else { | |
| 2008 | + skb_dst_set_noref(skb, dst); | |
| 2009 | + } | |
| 2010 | + } | |
| 2004 | 2011 | } |
| 2005 | 2012 | |
| 2006 | 2013 | int udp_rcv(struct sk_buff *skb) |
| @@ -37,12 +37,13 @@ synproxy_build_ip(struct sk_buff *skb, const struct in6_addr *saddr, · 36 unmodified lines | ||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | static void |
| 40 | −synproxy_send_tcp(const struct sk_buff *skb, struct sk_buff *nskb, | |
| 40 | +synproxy_send_tcp(const struct synproxy_net *snet, | |
| 41 | + const struct sk_buff *skb, struct sk_buff *nskb, | |
| 41 | 42 | struct nf_conntrack *nfct, enum ip_conntrack_info ctinfo, |
| 42 | 43 | struct ipv6hdr *niph, struct tcphdr *nth, |
| 43 | 44 | unsigned int tcp_hdr_size) |
| 44 | 45 | { |
| 45 | − struct net *net = nf_ct_net((struct nf_conn *)nfct); | |
| 46 | + struct net *net = nf_ct_net(snet->tmpl); | |
| 46 | 47 | struct dst_entry *dst; |
| 47 | 48 | struct flowi6 fl6; |
| 48 | 49 | |
| @@ -83,7 +84,8 @@ free_nskb: · 34 unmodified lines | ||
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | static void |
| 86 | −synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th, | |
| 87 | +synproxy_send_client_synack(const struct synproxy_net *snet, | |
| 88 | + const struct sk_buff *skb, const struct tcphdr *th, | |
| 87 | 89 | const struct synproxy_options *opts) |
| 88 | 90 | { |
| 89 | 91 | struct sk_buff *nskb; |
| @@ -119,7 +121,7 @@ synproxy_send_client_synack(const struct sk_buff *skb, const struct tcphdr *th, · 29 unmodified lines | ||
| 119 | 121 | |
| 120 | 122 | synproxy_build_options(nth, opts); |
| 121 | 123 | |
| 122 | − synproxy_send_tcp(skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, | |
| 124 | + synproxy_send_tcp(snet, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, | |
| 123 | 125 | niph, nth, tcp_hdr_size); |
| 124 | 126 | } |
| 125 | 127 | |
| @@ -163,7 +165,7 @@ synproxy_send_server_syn(const struct synproxy_net *snet, · 37 unmodified lines | ||
| 163 | 165 | |
| 164 | 166 | synproxy_build_options(nth, opts); |
| 165 | 167 | |
| 166 | − synproxy_send_tcp(skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW, | |
| 168 | + synproxy_send_tcp(snet, skb, nskb, &snet->tmpl->ct_general, IP_CT_NEW, | |
| 167 | 169 | niph, nth, tcp_hdr_size); |
| 168 | 170 | } |
| 169 | 171 | |
| @@ -203,7 +205,7 @@ synproxy_send_server_ack(const struct synproxy_net *snet, · 33 unmodified lines | ||
| 203 | 205 | |
| 204 | 206 | synproxy_build_options(nth, opts); |
| 205 | 207 | |
| 206 | − synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); | |
| 208 | + synproxy_send_tcp(snet, skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); | |
| 207 | 209 | } |
| 208 | 210 | |
| 209 | 211 | static void |
| @@ -241,7 +243,8 @@ synproxy_send_client_ack(const struct synproxy_net *snet, · 31 unmodified lines | ||
| 241 | 243 | |
| 242 | 244 | synproxy_build_options(nth, opts); |
| 243 | 245 | |
| 244 | − synproxy_send_tcp(skb, nskb, NULL, 0, niph, nth, tcp_hdr_size); | |
| 246 | + synproxy_send_tcp(snet, skb, nskb, skb->nfct, IP_CT_ESTABLISHED_REPLY, | |
| 247 | + niph, nth, tcp_hdr_size); | |
| 245 | 248 | } |
| 246 | 249 | |
| 247 | 250 | static bool |
| @@ -301,7 +304,7 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par) · 53 unmodified lines | ||
| 301 | 304 | XT_SYNPROXY_OPT_SACK_PERM | |
| 302 | 305 | XT_SYNPROXY_OPT_ECN); |
| 303 | 306 | |
| 304 | − synproxy_send_client_synack(skb, th, &opts); | |
| 307 | + synproxy_send_client_synack(snet, skb, th, &opts); | |
| 305 | 308 | return NF_DROP; |
| 306 | 309 | |
| 307 | 310 | } else if (th->ack && !(th->fin || th->rst || th->syn)) { |
| @@ -1844,6 +1844,7 @@ int ip6_route_add(struct fib6_config *cfg) · 1843 unmodified lines | ||
| 1844 | 1844 | int gwa_type; |
| 1845 | 1845 | |
| 1846 | 1846 | gw_addr = &cfg->fc_gateway; |
| 1847 | + gwa_type = ipv6_addr_type(gw_addr); | |
| 1847 | 1848 | |
| 1848 | 1849 | /* if gw_addr is local we will fail to detect this in case |
| 1849 | 1850 | * address is still TENTATIVE (DAD in progress). rt6_lookup() |
| @@ -1851,11 +1852,12 @@ int ip6_route_add(struct fib6_config *cfg) · 1 unmodified line | ||
| 1851 | 1852 | * prefix route was assigned to, which might be non-loopback. |
| 1852 | 1853 | */ |
| 1853 | 1854 | err = -EINVAL; |
| 1854 | − if (ipv6_chk_addr_and_flags(net, gw_addr, NULL, 0, 0)) | |
| 1855 | + if (ipv6_chk_addr_and_flags(net, gw_addr, | |
| 1856 | + gwa_type & IPV6_ADDR_LINKLOCAL ? | |
| 1857 | + dev : NULL, 0, 0)) | |
| 1855 | 1858 | goto out; |
| 1856 | 1859 | |
| 1857 | 1860 | rt->rt6i_gateway = *gw_addr; |
| 1858 | − gwa_type = ipv6_addr_type(gw_addr); | |
| 1859 | 1861 | |
| 1860 | 1862 | if (gwa_type != (IPV6_ADDR_LINKLOCAL|IPV6_ADDR_UNICAST)) { |
| 1861 | 1863 | struct rt6_info *grt; |
| @@ -943,7 +943,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk, struct sk_buff *skb) · 942 unmodified lines | ||
| 943 | 943 | &ipv6_hdr(skb)->daddr, tcp_v6_iif(skb)); |
| 944 | 944 | if (req) { |
| 945 | 945 | nsk = tcp_check_req(sk, skb, req, false); |
| 946 | − if (!nsk) | |
| 946 | + if (!nsk || nsk == sk) | |
| 947 | 947 | reqsk_put(req); |
| 948 | 948 | return nsk; |
| 949 | 949 | } |
| @@ -292,7 +292,7 @@ struct nf_conn *nf_ct_tmpl_alloc(struct net *net, u16 zone, gfp_t flags) · 291 unmodified lines | ||
| 292 | 292 | { |
| 293 | 293 | struct nf_conn *tmpl; |
| 294 | 294 | |
| 295 | − tmpl = kzalloc(sizeof(struct nf_conn), GFP_KERNEL); | |
| 295 | + tmpl = kzalloc(sizeof(*tmpl), flags); | |
| 296 | 296 | if (tmpl == NULL) |
| 297 | 297 | return NULL; |
| 298 | 298 | |
| @@ -303,7 +303,7 @@ struct nf_conn *nf_ct_tmpl_alloc(struct net *net, u16 zone, gfp_t flags) · 4 unmodified lines | ||
| 303 | 303 | if (zone) { |
| 304 | 304 | struct nf_conntrack_zone *nf_ct_zone; |
| 305 | 305 | |
| 306 | − nf_ct_zone = nf_ct_ext_add(tmpl, NF_CT_EXT_ZONE, GFP_ATOMIC); | |
| 306 | + nf_ct_zone = nf_ct_ext_add(tmpl, NF_CT_EXT_ZONE, flags); | |
| 307 | 307 | if (!nf_ct_zone) |
| 308 | 308 | goto out_free; |
| 309 | 309 | nf_ct_zone->id = zone; |
| @@ -1544,10 +1544,8 @@ void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls) · 1234 unmodified lines | ||
| 1544 | 1544 | sz = nr_slots * sizeof(struct hlist_nulls_head); |
| 1545 | 1545 | hash = (void *)__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, |
| 1546 | 1546 | get_order(sz)); |
| 1547 | − if (!hash) { | |
| 1548 | − printk(KERN_WARNING "nf_conntrack: falling back to vmalloc.\n"); | |
| 1547 | + if (!hash) | |
| 1549 | 1548 | hash = vzalloc(sz); |
| 1550 | − } | |
| 1551 | 1549 | |
| 1552 | 1550 | if (hash && nulls) |
| 1553 | 1551 | for (i = 0; i < nr_slots; i++) |
| @@ -353,10 +353,8 @@ static int __net_init synproxy_net_init(struct net *net) · 352 unmodified lines | ||
| 353 | 353 | int err = -ENOMEM; |
| 354 | 354 | |
| 355 | 355 | ct = nf_ct_tmpl_alloc(net, 0, GFP_KERNEL); |
| 356 | − if (IS_ERR(ct)) { | |
| 357 | − err = PTR_ERR(ct); | |
| 356 | + if (!ct) | |
| 358 | 357 | goto err1; |
| 359 | − } | |
| 360 | 358 | |
| 361 | 359 | if (!nfct_seqadj_ext_add(ct)) |
| 362 | 360 | goto err2; |
| @@ -202,9 +202,10 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par, · 201 unmodified lines | ||
| 202 | 202 | goto err1; |
| 203 | 203 | |
| 204 | 204 | ct = nf_ct_tmpl_alloc(par->net, info->zone, GFP_KERNEL); |
| 205 | − ret = PTR_ERR(ct); | |
| 206 | − if (IS_ERR(ct)) | |
| 205 | + if (!ct) { | |
| 206 | + ret = -ENOMEM; | |
| 207 | 207 | goto err2; |
| 208 | + } | |
| 208 | 209 | |
| 209 | 210 | ret = 0; |
| 210 | 211 | if ((info->ct_events || info->exp_events) && |
| @@ -1096,6 +1096,11 @@ static int netlink_insert(struct sock *sk, u32 portid) · 1095 unmodified lines | ||
| 1096 | 1096 | |
| 1097 | 1097 | err = __netlink_insert(table, sk); |
| 1098 | 1098 | if (err) { |
| 1099 | + /* In case the hashtable backend returns with -EBUSY | |
| 1100 | + * from here, it must not escape to the caller. | |
| 1101 | + */ | |
| 1102 | + if (unlikely(err == -EBUSY)) | |
| 1103 | + err = -EOVERFLOW; | |
| 1099 | 1104 | if (err == -EEXIST) |
| 1100 | 1105 | err = -EADDRINUSE; |
| 1101 | 1106 | nlk_sk(sk)->portid = 0; |
| @@ -273,28 +273,36 @@ static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *flow_key, · 272 unmodified lines | ||
| 273 | 273 | return 0; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | −static void set_ip_addr(struct sk_buff *skb, struct iphdr *nh, | |
| 277 | − __be32 *addr, __be32 new_addr) | |
| 276 | +static void update_ip_l4_checksum(struct sk_buff *skb, struct iphdr *nh, | |
| 277 | + __be32 addr, __be32 new_addr) | |
| 278 | 278 | { |
| 279 | 279 | int transport_len = skb->len - skb_transport_offset(skb); |
| 280 | 280 | |
| 281 | + if (nh->frag_off & htons(IP_OFFSET)) | |
| 282 | + return; | |
| 283 | + | |
| 281 | 284 | if (nh->protocol == IPPROTO_TCP) { |
| 282 | 285 | if (likely(transport_len >= sizeof(struct tcphdr))) |
| 283 | 286 | inet_proto_csum_replace4(&tcp_hdr(skb)->check, skb, |
| 284 | − *addr, new_addr, 1); | |
| 287 | + addr, new_addr, 1); | |
| 285 | 288 | } else if (nh->protocol == IPPROTO_UDP) { |
| 286 | 289 | if (likely(transport_len >= sizeof(struct udphdr))) { |
| 287 | 290 | struct udphdr *uh = udp_hdr(skb); |
| 288 | 291 | |
| 289 | 292 | if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) { |
| 290 | 293 | inet_proto_csum_replace4(&uh->check, skb, |
| 291 | − *addr, new_addr, 1); | |
| 294 | + addr, new_addr, 1); | |
| 292 | 295 | if (!uh->check) |
| 293 | 296 | uh->check = CSUM_MANGLED_0; |
| 294 | 297 | } |
| 295 | 298 | } |
| 296 | 299 | } |
| 300 | +} | |
| 297 | 301 | |
| 302 | +static void set_ip_addr(struct sk_buff *skb, struct iphdr *nh, | |
| 303 | + __be32 *addr, __be32 new_addr) | |
| 304 | +{ | |
| 305 | + update_ip_l4_checksum(skb, nh, *addr, new_addr); | |
| 298 | 306 | csum_replace4(&nh->check, *addr, new_addr); |
| 299 | 307 | skb_clear_hash(skb); |
| 300 | 308 | *addr = new_addr; |
| @@ -176,7 +176,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, · 175 unmodified lines | ||
| 176 | 176 | |
| 177 | 177 | /* check for all kinds of wrapping and the like */ |
| 178 | 178 | start = (unsigned long)optval; |
| 179 | − if (len < 0 || len + PAGE_SIZE - 1 < len || start + len < start) { | |
| 179 | + if (len < 0 || len > INT_MAX - PAGE_SIZE + 1 || start + len < start) { | |
| 180 | 180 | ret = -EINVAL; |
| 181 | 181 | goto out; |
| 182 | 182 | } |
| @@ -101,6 +101,8 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, · 100 unmodified lines | ||
| 101 | 101 | return ret; |
| 102 | 102 | ret = ACT_P_CREATED; |
| 103 | 103 | } else { |
| 104 | + if (bind) | |
| 105 | + return 0; | |
| 104 | 106 | if (!ovr) { |
| 105 | 107 | tcf_hash_release(a, bind); |
| 106 | 108 | return -EEXIST; |
| @@ -288,10 +288,26 @@ begin: · 287 unmodified lines | ||
| 288 | 288 | |
| 289 | 289 | static void fq_codel_reset(struct Qdisc *sch) |
| 290 | 290 | { |
| 291 | − struct sk_buff *skb; | |
| 291 | + struct fq_codel_sched_data *q = qdisc_priv(sch); | |
| 292 | + int i; | |
| 292 | 293 | |
| 293 | − while ((skb = fq_codel_dequeue(sch)) != NULL) | |
| 294 | − kfree_skb(skb); | |
| 294 | + INIT_LIST_HEAD(&q->new_flows); | |
| 295 | + INIT_LIST_HEAD(&q->old_flows); | |
| 296 | + for (i = 0; i < q->flows_cnt; i++) { | |
| 297 | + struct fq_codel_flow *flow = q->flows + i; | |
| 298 | + | |
| 299 | + while (flow->head) { | |
| 300 | + struct sk_buff *skb = dequeue_head(flow); | |
| 301 | + | |
| 302 | + qdisc_qstats_backlog_dec(sch, skb); | |
| 303 | + kfree_skb(skb); | |
| 304 | + } | |
| 305 | + | |
| 306 | + INIT_LIST_HEAD(&flow->flowchain); | |
| 307 | + codel_vars_init(&flow->cvars); | |
| 308 | + } | |
| 309 | + memset(q->backlogs, 0, q->flows_cnt * sizeof(u32)); | |
| 310 | + sch->q.qlen = 0; | |
| 295 | 311 | } |
| 296 | 312 | |
| 297 | 313 | static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { |
| @@ -137,7 +137,7 @@ my $ksource = ($ARGV[0] ? $ARGV[0] : '.'); · 136 unmodified lines | ||
| 137 | 137 | my $kconfig = $ARGV[1]; |
| 138 | 138 | my $lsmod_file = $ENV{'LSMOD'}; |
| 139 | 139 | |
| 140 | −my @makefiles = `find $ksource -name Makefile 2>/dev/null`; | |
| 140 | +my @makefiles = `find $ksource -name Makefile -or -name Kbuild 2>/dev/null`; | |
| 141 | 141 | chomp @makefiles; |
| 142 | 142 | |
| 143 | 143 | my %depends; |
| @@ -406,6 +406,7 @@ static __init int yama_init(void) · 405 unmodified lines | ||
| 406 | 406 | */ |
| 407 | 407 | if (!security_module_enable("yama")) |
| 408 | 408 | return 0; |
| 409 | + yama_add_hooks(); | |
| 409 | 410 | #endif |
| 410 | 411 | pr_info("Yama: becoming mindful.\n"); |
| 411 | 412 | |
| @@ -740,8 +740,9 @@ static int handle_in_packet(struct amdtp_stream *s, · 739 unmodified lines | ||
| 740 | 740 | s->data_block_counter != UINT_MAX) |
| 741 | 741 | data_block_counter = s->data_block_counter; |
| 742 | 742 | |
| 743 | − if (((s->flags & CIP_SKIP_DBC_ZERO_CHECK) && data_block_counter == 0) || | |
| 744 | − (s->data_block_counter == UINT_MAX)) { | |
| 743 | + if (((s->flags & CIP_SKIP_DBC_ZERO_CHECK) && | |
| 744 | + data_block_counter == s->tx_first_dbc) || | |
| 745 | + s->data_block_counter == UINT_MAX) { | |
| 745 | 746 | lost = false; |
| 746 | 747 | } else if (!(s->flags & CIP_DBC_IS_END_EVENT)) { |
| 747 | 748 | lost = data_block_counter != s->data_block_counter; |
| @@ -157,6 +157,8 @@ struct amdtp_stream { · 156 unmodified lines | ||
| 157 | 157 | |
| 158 | 158 | /* quirk: fixed interval of dbc between previos/current packets. */ |
| 159 | 159 | unsigned int tx_dbc_interval; |
| 160 | + /* quirk: indicate the value of dbc field in a first packet. */ | |
| 161 | + unsigned int tx_first_dbc; | |
| 160 | 162 | |
| 161 | 163 | bool callbacked; |
| 162 | 164 | wait_queue_head_t callback_wait; |
| @@ -248,10 +248,16 @@ efw_probe(struct fw_unit *unit, · 247 unmodified lines | ||
| 248 | 248 | err = get_hardware_info(efw); |
| 249 | 249 | if (err < 0) |
| 250 | 250 | goto error; |
| 251 | − if (entry->model_id == MODEL_ECHO_AUDIOFIRE_2) | |
| 252 | − efw->is_af2 = true; | |
| 251 | + /* AudioFire8 (since 2009) and AudioFirePre8 */ | |
| 253 | 252 | if (entry->model_id == MODEL_ECHO_AUDIOFIRE_9) |
| 254 | 253 | efw->is_af9 = true; |
| 254 | + /* These models uses the same firmware. */ | |
| 255 | + if (entry->model_id == MODEL_ECHO_AUDIOFIRE_2 || | |
| 256 | + entry->model_id == MODEL_ECHO_AUDIOFIRE_4 || | |
| 257 | + entry->model_id == MODEL_ECHO_AUDIOFIRE_9 || | |
| 258 | + entry->model_id == MODEL_GIBSON_RIP || | |
| 259 | + entry->model_id == MODEL_GIBSON_GOLDTOP) | |
| 260 | + efw->is_fireworks3 = true; | |
| 255 | 261 | |
| 256 | 262 | snd_efw_proc_init(efw); |
| 257 | 263 | |
| @@ -70,8 +70,8 @@ struct snd_efw { · 69 unmodified lines | ||
| 70 | 70 | bool resp_addr_changable; |
| 71 | 71 | |
| 72 | 72 | /* for quirks */ |
| 73 | − bool is_af2; | |
| 74 | 73 | bool is_af9; |
| 74 | + bool is_fireworks3; | |
| 75 | 75 | u32 firmware_version; |
| 76 | 76 | |
| 77 | 77 | unsigned int midi_in_ports; |
| @@ -172,9 +172,15 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw) · 171 unmodified lines | ||
| 172 | 172 | efw->tx_stream.flags |= CIP_DBC_IS_END_EVENT; |
| 173 | 173 | /* Fireworks reset dbc at bus reset. */ |
| 174 | 174 | efw->tx_stream.flags |= CIP_SKIP_DBC_ZERO_CHECK; |
| 175 | − /* AudioFire2 starts packets with non-zero dbc. */ | |
| 176 | − if (efw->is_af2) | |
| 177 | − efw->tx_stream.flags |= CIP_SKIP_INIT_DBC_CHECK; | |
| 175 | + /* | |
| 176 | + * But Recent firmwares starts packets with non-zero dbc. | |
| 177 | + * Driver version 5.7.6 installs firmware version 5.7.3. | |
| 178 | + */ | |
| 179 | + if (efw->is_fireworks3 && | |
| 180 | + (efw->firmware_version == 0x5070000 || | |
| 181 | + efw->firmware_version == 0x5070300 || | |
| 182 | + efw->firmware_version == 0x5080000)) | |
| 183 | + efw->tx_stream.tx_first_dbc = 0x02; | |
| 178 | 184 | /* AudioFire9 always reports wrong dbs. */ |
| 179 | 185 | if (efw->is_af9) |
| 180 | 186 | efw->tx_stream.flags |= CIP_WRONG_DBS; |
| @@ -44,16 +44,10 @@ int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *ebus) · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | offset = snd_hdac_chip_readl(bus, LLCH); |
| 46 | 46 | |
| 47 | − if (offset < 0) | |
| 48 | − return -EIO; | |
| 49 | − | |
| 50 | 47 | /* Lets walk the linked capabilities list */ |
| 51 | 48 | do { |
| 52 | 49 | cur_cap = _snd_hdac_chip_read(l, bus, offset); |
| 53 | 50 | |
| 54 | − if (cur_cap < 0) | |
| 55 | − return -EIO; | |
| 56 | − | |
| 57 | 51 | dev_dbg(bus->dev, "Capability version: 0x%x\n", |
| 58 | 52 | ((cur_cap & AZX_CAP_HDR_VER_MASK) >> AZX_CAP_HDR_VER_OFF)); |
| 59 | 53 | |
| @@ -299,7 +299,7 @@ hdac_ext_host_stream_assign(struct hdac_ext_bus *ebus, · 298 unmodified lines | ||
| 299 | 299 | if (stream->direction != substream->stream) |
| 300 | 300 | continue; |
| 301 | 301 | |
| 302 | − if (stream->opened) { | |
| 302 | + if (!stream->opened) { | |
| 303 | 303 | if (!hstream->decoupled) |
| 304 | 304 | snd_hdac_ext_stream_decouple(ebus, hstream, true); |
| 305 | 305 | res = hstream; |
| @@ -5189,6 +5189,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { · 5188 unmodified lines | ||
| 5189 | 5189 | SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5190 | 5190 | SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5191 | 5191 | SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5192 | + SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC292_FIXUP_DISABLE_AAMIX), | |
| 5192 | 5193 | SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5193 | 5194 | SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), |
| 5194 | 5195 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), |
| @@ -88,7 +88,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl, · 87 unmodified lines | ||
| 88 | 88 | int changed; |
| 89 | 89 | |
| 90 | 90 | mutex_lock(&chip->mutex); |
| 91 | − changed = !value->value.integer.value[0] != chip->dac_mute; | |
| 91 | + changed = (!value->value.integer.value[0]) != chip->dac_mute; | |
| 92 | 92 | if (changed) { |
| 93 | 93 | chip->dac_mute = !value->value.integer.value[0]; |
| 94 | 94 | chip->model.update_dac_mute(chip); |
| @@ -457,14 +457,14 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, · 456 unmodified lines | ||
| 457 | 457 | case SND_SOC_DAIFMT_RIGHT_J: |
| 458 | 458 | if (params_width(params) == 16) { |
| 459 | 459 | snd_soc_update_bits(codec, CS4265_DAC_CTL, |
| 460 | − CS4265_DAC_CTL_DIF, (1 << 5)); | |
| 460 | + CS4265_DAC_CTL_DIF, (2 << 4)); | |
| 461 | 461 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, |
| 462 | − CS4265_SPDIF_CTL2_DIF, (1 << 7)); | |
| 462 | + CS4265_SPDIF_CTL2_DIF, (2 << 6)); | |
| 463 | 463 | } else { |
| 464 | 464 | snd_soc_update_bits(codec, CS4265_DAC_CTL, |
| 465 | − CS4265_DAC_CTL_DIF, (3 << 5)); | |
| 465 | + CS4265_DAC_CTL_DIF, (3 << 4)); | |
| 466 | 466 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, |
| 467 | − CS4265_SPDIF_CTL2_DIF, (1 << 7)); | |
| 467 | + CS4265_SPDIF_CTL2_DIF, (3 << 6)); | |
| 468 | 468 | } |
| 469 | 469 | break; |
| 470 | 470 | case SND_SOC_DAIFMT_LEFT_J: |
| @@ -473,7 +473,7 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, · 2 unmodified lines | ||
| 473 | 473 | snd_soc_update_bits(codec, CS4265_ADC_CTL, |
| 474 | 474 | CS4265_ADC_DIF, 0); |
| 475 | 475 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, |
| 476 | − CS4265_SPDIF_CTL2_DIF, (1 << 6)); | |
| 476 | + CS4265_SPDIF_CTL2_DIF, 0); | |
| 477 | 477 | |
| 478 | 478 | break; |
| 479 | 479 | default: |
| @@ -3341,6 +3341,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, · 3340 unmodified lines | ||
| 3341 | 3341 | break; |
| 3342 | 3342 | |
| 3343 | 3343 | case RT5645_DMIC_DATA_GPIO5: |
| 3344 | + regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, | |
| 3345 | + RT5645_I2S2_DAC_PIN_MASK, RT5645_I2S2_DAC_PIN_GPIO); | |
| 3344 | 3346 | regmap_update_bits(rt5645->regmap, RT5645_DMIC_CTRL1, |
| 3345 | 3347 | RT5645_DMIC_1_DP_MASK, RT5645_DMIC_1_DP_GPIO5); |
| 3346 | 3348 | regmap_update_bits(rt5645->regmap, RT5645_GPIO_CTRL1, |
| @@ -1693,6 +1693,10 @@ · 1692 unmodified lines | ||
| 1693 | 1693 | #define RT5645_GP6_PIN_SFT 6 |
| 1694 | 1694 | #define RT5645_GP6_PIN_GPIO6 (0x0 << 6) |
| 1695 | 1695 | #define RT5645_GP6_PIN_DMIC2_SDA (0x1 << 6) |
| 1696 | +#define RT5645_I2S2_DAC_PIN_MASK (0x1 << 4) | |
| 1697 | +#define RT5645_I2S2_DAC_PIN_SFT 4 | |
| 1698 | +#define RT5645_I2S2_DAC_PIN_I2S (0x0 << 4) | |
| 1699 | +#define RT5645_I2S2_DAC_PIN_GPIO (0x1 << 4) | |
| 1696 | 1700 | #define RT5645_GP8_PIN_MASK (0x1 << 3) |
| 1697 | 1701 | #define RT5645_GP8_PIN_SFT 3 |
| 1698 | 1702 | #define RT5645_GP8_PIN_GPIO8 (0x0 << 3) |
| @@ -701,6 +701,8 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) · 700 unmodified lines | ||
| 701 | 701 | if (byt == NULL) |
| 702 | 702 | return -ENOMEM; |
| 703 | 703 | |
| 704 | + byt->dev = dev; | |
| 705 | + | |
| 704 | 706 | ipc = &byt->ipc; |
| 705 | 707 | ipc->dev = dev; |
| 706 | 708 | ipc->ops.tx_msg = byt_tx_msg; |
| @@ -2119,6 +2119,8 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) · 2118 unmodified lines | ||
| 2119 | 2119 | if (hsw == NULL) |
| 2120 | 2120 | return -ENOMEM; |
| 2121 | 2121 | |
| 2122 | + hsw->dev = dev; | |
| 2123 | + | |
| 2122 | 2124 | ipc = &hsw->ipc; |
| 2123 | 2125 | ipc->dev = dev; |
| 2124 | 2126 | ipc->ops.tx_msg = hsw_tx_msg; |
| @@ -33,6 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | #include <sound/soc.h> |
| 34 | 34 | #include <sound/soc-dapm.h> |
| 35 | 35 | #include <sound/soc-topology.h> |
| 36 | +#include <sound/tlv.h> | |
| 36 | 37 | |
| 37 | 38 | /* |
| 38 | 39 | * We make several passes over the data (since it wont necessarily be ordered) |
| @@ -534,7 +535,7 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, · 495 unmodified lines | ||
| 534 | 535 | k->put = bops[i].put; |
| 535 | 536 | if (k->get == NULL && bops[i].id == hdr->ops.get) |
| 536 | 537 | k->get = bops[i].get; |
| 537 | − if (k->info == NULL && ops[i].id == hdr->ops.info) | |
| 538 | + if (k->info == NULL && bops[i].id == hdr->ops.info) | |
| 538 | 539 | k->info = bops[i].info; |
| 539 | 540 | } |
| 540 | 541 | |
| @@ -579,28 +580,51 @@ static int soc_tplg_init_kcontrol(struct soc_tplg *tplg, · 38 unmodified lines | ||
| 579 | 580 | return 0; |
| 580 | 581 | } |
| 581 | 582 | |
| 583 | + | |
| 584 | +static int soc_tplg_create_tlv_db_scale(struct soc_tplg *tplg, | |
| 585 | + struct snd_kcontrol_new *kc, struct snd_soc_tplg_tlv_dbscale *scale) | |
| 586 | +{ | |
| 587 | + unsigned int item_len = 2 * sizeof(unsigned int); | |
| 588 | + unsigned int *p; | |
| 589 | + | |
| 590 | + p = kzalloc(item_len + 2 * sizeof(unsigned int), GFP_KERNEL); | |
| 591 | + if (!p) | |
| 592 | + return -ENOMEM; | |
| 593 | + | |
| 594 | + p[0] = SNDRV_CTL_TLVT_DB_SCALE; | |
| 595 | + p[1] = item_len; | |
| 596 | + p[2] = scale->min; | |
| 597 | + p[3] = (scale->step & TLV_DB_SCALE_MASK) | |
| 598 | + | (scale->mute ? TLV_DB_SCALE_MUTE : 0); | |
| 599 | + | |
| 600 | + kc->tlv.p = (void *)p; | |
| 601 | + return 0; | |
| 602 | +} | |
| 603 | + | |
| 582 | 604 | static int soc_tplg_create_tlv(struct soc_tplg *tplg, |
| 583 | − struct snd_kcontrol_new *kc, struct snd_soc_tplg_ctl_tlv *tplg_tlv) | |
| 605 | + struct snd_kcontrol_new *kc, struct snd_soc_tplg_ctl_hdr *tc) | |
| 584 | 606 | { |
| 585 | − struct snd_ctl_tlv *tlv; | |
| 586 | − int size; | |
| 607 | + struct snd_soc_tplg_ctl_tlv *tplg_tlv; | |
| 587 | 608 | |
| 588 | − if (tplg_tlv->count == 0) | |
| 609 | + if (!(tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE)) | |
| 589 | 610 | return 0; |
| 590 | 611 | |
| 591 | − size = ((tplg_tlv->count + (sizeof(unsigned int) - 1)) & | |
| 592 | − ~(sizeof(unsigned int) - 1)); | |
| 593 | − tlv = kzalloc(sizeof(*tlv) + size, GFP_KERNEL); | |
| 594 | − if (tlv == NULL) | |
| 595 | − return -ENOMEM; | |
| 596 | − | |
| 597 | − dev_dbg(tplg->dev, " created TLV type %d size %d bytes\n", | |
| 598 | − tplg_tlv->numid, size); | |
| 612 | + if (tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { | |
| 613 | + kc->tlv.c = snd_soc_bytes_tlv_callback; | |
| 614 | + } else { | |
| 615 | + tplg_tlv = &tc->tlv; | |
| 616 | + switch (tplg_tlv->type) { | |
| 617 | + case SNDRV_CTL_TLVT_DB_SCALE: | |
| 618 | + return soc_tplg_create_tlv_db_scale(tplg, kc, | |
| 619 | + &tplg_tlv->scale); | |
| 599 | 620 | |
| 600 | − tlv->numid = tplg_tlv->numid; | |
| 601 | − tlv->length = size; | |
| 602 | − memcpy(&tlv->tlv[0], tplg_tlv->data, size); | |
| 603 | − kc->tlv.p = (void *)tlv; | |
| 621 | + /* TODO: add support for other TLV types */ | |
| 622 | + default: | |
| 623 | + dev_dbg(tplg->dev, "Unsupported TLV type %d\n", | |
| 624 | + tplg_tlv->type); | |
| 625 | + return -EINVAL; | |
| 626 | + } | |
| 627 | + } | |
| 604 | 628 | |
| 605 | 629 | return 0; |
| 606 | 630 | } |
| @@ -772,7 +796,7 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, unsigned int count, · 165 unmodified lines | ||
| 772 | 796 | } |
| 773 | 797 | |
| 774 | 798 | /* create any TLV data */ |
| 775 | − soc_tplg_create_tlv(tplg, &kc, &mc->tlv); | |
| 799 | + soc_tplg_create_tlv(tplg, &kc, &mc->hdr); | |
| 776 | 800 | |
| 777 | 801 | /* register control here */ |
| 778 | 802 | err = soc_tplg_add_kcontrol(tplg, &kc, |
| @@ -1350,6 +1374,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg, · 571 unmodified lines | ||
| 1350 | 1374 | template.reg = w->reg; |
| 1351 | 1375 | template.shift = w->shift; |
| 1352 | 1376 | template.mask = w->mask; |
| 1377 | + template.subseq = w->subseq; | |
| 1353 | 1378 | template.on_val = w->invert ? 0 : 1; |
| 1354 | 1379 | template.off_val = w->invert ? 1 : 0; |
| 1355 | 1380 | template.ignore_suspend = w->ignore_suspend; |