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

Merge branch 'sched/core' into locking/core

Required for the rtmutex/sched_deadline patches which depend on both
branches

+3614 -1830
+6 -5
Documentation/cgroup-v2.txt
··· 1142 1142 1143 1143 pids.max 1144 1144 1145 - A read-write single value file which exists on non-root cgroups. The 1146 - default is "max". 1145 + A read-write single value file which exists on non-root 1146 + cgroups. The default is "max". 1147 1147 1148 - Hard limit of number of processes. 1148 + Hard limit of number of processes. 1149 1149 1150 1150 pids.current 1151 1151 1152 - A read-only single value file which exists on all cgroups. 1152 + A read-only single value file which exists on all cgroups. 1153 1153 1154 - The number of processes currently in the cgroup and its descendants. 1154 + The number of processes currently in the cgroup and its 1155 + descendants. 1155 1156 1156 1157 Organisational operations are not blocked by cgroup policies, so it is 1157 1158 possible to have pids.current > pids.max. This can be done by either
+60 -2
Documentation/devicetree/bindings/powerpc/4xx/emac.txt
··· 71 71 For Axon it can be absent, though my current driver 72 72 doesn't handle phy-address yet so for now, keep 73 73 0x00ffffff in it. 74 + - phy-handle : Used to describe configurations where a external PHY 75 + is used. Please refer to: 76 + Documentation/devicetree/bindings/net/ethernet.txt 74 77 - rx-fifo-size-gige : 1 cell, Rx fifo size in bytes for 1000 Mb/sec 75 78 operations (if absent the value is the same as 76 79 rx-fifo-size). For Axon, either absent or 2048. ··· 84 81 offload, phandle of the TAH device node. 85 82 - tah-channel : 1 cell, optional. If appropriate, channel used on the 86 83 TAH engine. 84 + - fixed-link : Fixed-link subnode describing a link to a non-MDIO 85 + managed entity. See 86 + Documentation/devicetree/bindings/net/fixed-link.txt 87 + for details. 88 + - mdio subnode : When the EMAC has a phy connected to its local 89 + mdio, which us supported by the kernel's network 90 + PHY library in drivers/net/phy, there must be device 91 + tree subnode with the following required properties: 92 + - #address-cells: Must be <1>. 93 + - #size-cells: Must be <0>. 87 94 88 - Example: 95 + For PHY definitions: Please refer to 96 + Documentation/devicetree/bindings/net/phy.txt and 97 + Documentation/devicetree/bindings/net/ethernet.txt 98 + 99 + Examples: 89 100 90 101 EMAC0: ethernet@40000800 { 91 102 device_type = "network"; ··· 120 103 zmii-device = <&ZMII0>; 121 104 zmii-channel = <0>; 122 105 }; 106 + 107 + EMAC1: ethernet@ef600c00 { 108 + device_type = "network"; 109 + compatible = "ibm,emac-apm821xx", "ibm,emac4sync"; 110 + interrupt-parent = <&EMAC1>; 111 + interrupts = <0 1>; 112 + #interrupt-cells = <1>; 113 + #address-cells = <0>; 114 + #size-cells = <0>; 115 + interrupt-map = <0 &UIC2 0x10 IRQ_TYPE_LEVEL_HIGH /* Status */ 116 + 1 &UIC2 0x14 IRQ_TYPE_LEVEL_HIGH /* Wake */>; 117 + reg = <0xef600c00 0x000000c4>; 118 + local-mac-address = [000000000000]; /* Filled in by U-Boot */ 119 + mal-device = <&MAL0>; 120 + mal-tx-channel = <0>; 121 + mal-rx-channel = <0>; 122 + cell-index = <0>; 123 + max-frame-size = <9000>; 124 + rx-fifo-size = <16384>; 125 + tx-fifo-size = <2048>; 126 + fifo-entry-size = <10>; 127 + phy-mode = "rgmii"; 128 + phy-handle = <&phy0>; 129 + phy-map = <0x00000000>; 130 + rgmii-device = <&RGMII0>; 131 + rgmii-channel = <0>; 132 + tah-device = <&TAH0>; 133 + tah-channel = <0>; 134 + has-inverted-stacr-oc; 135 + has-new-stacr-staopc; 136 + 137 + mdio { 138 + #address-cells = <1>; 139 + #size-cells = <0>; 140 + 141 + phy0: ethernet-phy@0 { 142 + compatible = "ethernet-phy-ieee802.3-c22"; 143 + reg = <0>; 144 + }; 145 + }; 146 + }; 147 + 123 148 124 149 ii) McMAL node 125 150 ··· 204 145 - revision : as provided by the RGMII new version register if 205 146 available. 206 147 For Axon: 0x0000012a 207 -
+2 -1
Documentation/networking/ip-sysctl.txt
··· 1006 1006 FALSE (router) 1007 1007 1008 1008 forwarding - BOOLEAN 1009 - Enable IP forwarding on this interface. 1009 + Enable IP forwarding on this interface. This controls whether packets 1010 + received _on_ this interface can be forwarded. 1010 1011 1011 1012 mc_forwarding - BOOLEAN 1012 1013 Do multicast routing. The kernel needs to be compiled with CONFIG_MROUTE
+1
arch/powerpc/boot/zImage.lds.S
··· 68 68 } 69 69 70 70 #ifdef CONFIG_PPC64_BOOT_WRAPPER 71 + . = ALIGN(256); 71 72 .got : 72 73 { 73 74 __toc_start = .;
+1 -1
arch/powerpc/crypto/crc32c-vpmsum_glue.c
··· 52 52 { 53 53 u32 *key = crypto_tfm_ctx(tfm); 54 54 55 - *key = 0; 55 + *key = ~0; 56 56 57 57 return 0; 58 58 }
+4
arch/powerpc/include/asm/bitops.h
··· 51 51 #define PPC_BIT(bit) (1UL << PPC_BITLSHIFT(bit)) 52 52 #define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs)) 53 53 54 + /* Put a PPC bit into a "normal" bit position */ 55 + #define PPC_BITEXTRACT(bits, ppc_bit, dst_bit) \ 56 + ((((bits) >> PPC_BITLSHIFT(ppc_bit)) & 1) << (dst_bit)) 57 + 54 58 #include <asm/barrier.h> 55 59 56 60 /* Macro for generating the ***_bits() functions */
+107 -1
arch/powerpc/include/asm/mce.h
··· 66 66 67 67 #define P8_DSISR_MC_SLB_ERRORS (P7_DSISR_MC_SLB_ERRORS | \ 68 68 P8_DSISR_MC_ERAT_MULTIHIT_SEC) 69 + 70 + /* 71 + * Machine Check bits on power9 72 + */ 73 + #define P9_SRR1_MC_LOADSTORE(srr1) (((srr1) >> PPC_BITLSHIFT(42)) & 1) 74 + 75 + #define P9_SRR1_MC_IFETCH(srr1) ( \ 76 + PPC_BITEXTRACT(srr1, 45, 0) | \ 77 + PPC_BITEXTRACT(srr1, 44, 1) | \ 78 + PPC_BITEXTRACT(srr1, 43, 2) | \ 79 + PPC_BITEXTRACT(srr1, 36, 3) ) 80 + 81 + /* 0 is reserved */ 82 + #define P9_SRR1_MC_IFETCH_UE 1 83 + #define P9_SRR1_MC_IFETCH_SLB_PARITY 2 84 + #define P9_SRR1_MC_IFETCH_SLB_MULTIHIT 3 85 + #define P9_SRR1_MC_IFETCH_ERAT_MULTIHIT 4 86 + #define P9_SRR1_MC_IFETCH_TLB_MULTIHIT 5 87 + #define P9_SRR1_MC_IFETCH_UE_TLB_RELOAD 6 88 + /* 7 is reserved */ 89 + #define P9_SRR1_MC_IFETCH_LINK_TIMEOUT 8 90 + #define P9_SRR1_MC_IFETCH_LINK_TABLEWALK_TIMEOUT 9 91 + /* 10 ? */ 92 + #define P9_SRR1_MC_IFETCH_RA 11 93 + #define P9_SRR1_MC_IFETCH_RA_TABLEWALK 12 94 + #define P9_SRR1_MC_IFETCH_RA_ASYNC_STORE 13 95 + #define P9_SRR1_MC_IFETCH_LINK_ASYNC_STORE_TIMEOUT 14 96 + #define P9_SRR1_MC_IFETCH_RA_TABLEWALK_FOREIGN 15 97 + 98 + /* DSISR bits for machine check (On Power9) */ 99 + #define P9_DSISR_MC_UE (PPC_BIT(48)) 100 + #define P9_DSISR_MC_UE_TABLEWALK (PPC_BIT(49)) 101 + #define P9_DSISR_MC_LINK_LOAD_TIMEOUT (PPC_BIT(50)) 102 + #define P9_DSISR_MC_LINK_TABLEWALK_TIMEOUT (PPC_BIT(51)) 103 + #define P9_DSISR_MC_ERAT_MULTIHIT (PPC_BIT(52)) 104 + #define P9_DSISR_MC_TLB_MULTIHIT_MFTLB (PPC_BIT(53)) 105 + #define P9_DSISR_MC_USER_TLBIE (PPC_BIT(54)) 106 + #define P9_DSISR_MC_SLB_PARITY_MFSLB (PPC_BIT(55)) 107 + #define P9_DSISR_MC_SLB_MULTIHIT_MFSLB (PPC_BIT(56)) 108 + #define P9_DSISR_MC_RA_LOAD (PPC_BIT(57)) 109 + #define P9_DSISR_MC_RA_TABLEWALK (PPC_BIT(58)) 110 + #define P9_DSISR_MC_RA_TABLEWALK_FOREIGN (PPC_BIT(59)) 111 + #define P9_DSISR_MC_RA_FOREIGN (PPC_BIT(60)) 112 + 113 + /* SLB error bits */ 114 + #define P9_DSISR_MC_SLB_ERRORS (P9_DSISR_MC_ERAT_MULTIHIT | \ 115 + P9_DSISR_MC_SLB_PARITY_MFSLB | \ 116 + P9_DSISR_MC_SLB_MULTIHIT_MFSLB) 117 + 69 118 enum MCE_Version { 70 119 MCE_V1 = 1, 71 120 }; ··· 142 93 MCE_ERROR_TYPE_SLB = 2, 143 94 MCE_ERROR_TYPE_ERAT = 3, 144 95 MCE_ERROR_TYPE_TLB = 4, 96 + MCE_ERROR_TYPE_USER = 5, 97 + MCE_ERROR_TYPE_RA = 6, 98 + MCE_ERROR_TYPE_LINK = 7, 145 99 }; 146 100 147 101 enum MCE_UeErrorType { ··· 171 119 MCE_TLB_ERROR_INDETERMINATE = 0, 172 120 MCE_TLB_ERROR_PARITY = 1, 173 121 MCE_TLB_ERROR_MULTIHIT = 2, 122 + }; 123 + 124 + enum MCE_UserErrorType { 125 + MCE_USER_ERROR_INDETERMINATE = 0, 126 + MCE_USER_ERROR_TLBIE = 1, 127 + }; 128 + 129 + enum MCE_RaErrorType { 130 + MCE_RA_ERROR_INDETERMINATE = 0, 131 + MCE_RA_ERROR_IFETCH = 1, 132 + MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH = 2, 133 + MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN = 3, 134 + MCE_RA_ERROR_LOAD = 4, 135 + MCE_RA_ERROR_STORE = 5, 136 + MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE = 6, 137 + MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN = 7, 138 + MCE_RA_ERROR_LOAD_STORE_FOREIGN = 8, 139 + }; 140 + 141 + enum MCE_LinkErrorType { 142 + MCE_LINK_ERROR_INDETERMINATE = 0, 143 + MCE_LINK_ERROR_IFETCH_TIMEOUT = 1, 144 + MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT = 2, 145 + MCE_LINK_ERROR_LOAD_TIMEOUT = 3, 146 + MCE_LINK_ERROR_STORE_TIMEOUT = 4, 147 + MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT = 5, 174 148 }; 175 149 176 150 struct machine_check_event { ··· 244 166 uint64_t effective_address; 245 167 uint8_t reserved_2[16]; 246 168 } tlb_error; 169 + 170 + struct { 171 + enum MCE_UserErrorType user_error_type:8; 172 + uint8_t effective_address_provided; 173 + uint8_t reserved_1[6]; 174 + uint64_t effective_address; 175 + uint8_t reserved_2[16]; 176 + } user_error; 177 + 178 + struct { 179 + enum MCE_RaErrorType ra_error_type:8; 180 + uint8_t effective_address_provided; 181 + uint8_t reserved_1[6]; 182 + uint64_t effective_address; 183 + uint8_t reserved_2[16]; 184 + } ra_error; 185 + 186 + struct { 187 + enum MCE_LinkErrorType link_error_type:8; 188 + uint8_t effective_address_provided; 189 + uint8_t reserved_1[6]; 190 + uint64_t effective_address; 191 + uint8_t reserved_2[16]; 192 + } link_error; 247 193 } u; 248 194 }; 249 195 ··· 278 176 enum MCE_SlbErrorType slb_error_type:8; 279 177 enum MCE_EratErrorType erat_error_type:8; 280 178 enum MCE_TlbErrorType tlb_error_type:8; 179 + enum MCE_UserErrorType user_error_type:8; 180 + enum MCE_RaErrorType ra_error_type:8; 181 + enum MCE_LinkErrorType link_error_type:8; 281 182 } u; 282 - uint8_t reserved[2]; 183 + enum MCE_Severity severity:8; 184 + enum MCE_Initiator initiator:8; 283 185 }; 284 186 285 187 #define MAX_MC_EVT 100
+3
arch/powerpc/kernel/cputable.c
··· 77 77 extern void __flush_tlb_power9(unsigned int action); 78 78 extern long __machine_check_early_realmode_p7(struct pt_regs *regs); 79 79 extern long __machine_check_early_realmode_p8(struct pt_regs *regs); 80 + extern long __machine_check_early_realmode_p9(struct pt_regs *regs); 80 81 #endif /* CONFIG_PPC64 */ 81 82 #if defined(CONFIG_E500) 82 83 extern void __setup_cpu_e5500(unsigned long offset, struct cpu_spec* spec); ··· 541 540 .cpu_setup = __setup_cpu_power9, 542 541 .cpu_restore = __restore_cpu_power9, 543 542 .flush_tlb = __flush_tlb_power9, 543 + .machine_check_early = __machine_check_early_realmode_p9, 544 544 .platform = "power9", 545 545 }, 546 546 { /* Power9 */ ··· 561 559 .cpu_setup = __setup_cpu_power9, 562 560 .cpu_restore = __restore_cpu_power9, 563 561 .flush_tlb = __flush_tlb_power9, 562 + .machine_check_early = __machine_check_early_realmode_p9, 564 563 .platform = "power9", 565 564 }, 566 565 { /* Cell Broadband Engine */
+86 -2
arch/powerpc/kernel/mce.c
··· 58 58 case MCE_ERROR_TYPE_TLB: 59 59 mce->u.tlb_error.tlb_error_type = mce_err->u.tlb_error_type; 60 60 break; 61 + case MCE_ERROR_TYPE_USER: 62 + mce->u.user_error.user_error_type = mce_err->u.user_error_type; 63 + break; 64 + case MCE_ERROR_TYPE_RA: 65 + mce->u.ra_error.ra_error_type = mce_err->u.ra_error_type; 66 + break; 67 + case MCE_ERROR_TYPE_LINK: 68 + mce->u.link_error.link_error_type = mce_err->u.link_error_type; 69 + break; 61 70 case MCE_ERROR_TYPE_UNKNOWN: 62 71 default: 63 72 break; ··· 99 90 mce->gpr3 = regs->gpr[3]; 100 91 mce->in_use = 1; 101 92 102 - mce->initiator = MCE_INITIATOR_CPU; 103 93 /* Mark it recovered if we have handled it and MSR(RI=1). */ 104 94 if (handled && (regs->msr & MSR_RI)) 105 95 mce->disposition = MCE_DISPOSITION_RECOVERED; 106 96 else 107 97 mce->disposition = MCE_DISPOSITION_NOT_RECOVERED; 108 - mce->severity = MCE_SEV_ERROR_SYNC; 98 + 99 + mce->initiator = mce_err->initiator; 100 + mce->severity = mce_err->severity; 109 101 110 102 /* 111 103 * Populate the mce error_type and type-specific error_type. ··· 125 115 } else if (mce->error_type == MCE_ERROR_TYPE_ERAT) { 126 116 mce->u.erat_error.effective_address_provided = true; 127 117 mce->u.erat_error.effective_address = addr; 118 + } else if (mce->error_type == MCE_ERROR_TYPE_USER) { 119 + mce->u.user_error.effective_address_provided = true; 120 + mce->u.user_error.effective_address = addr; 121 + } else if (mce->error_type == MCE_ERROR_TYPE_RA) { 122 + mce->u.ra_error.effective_address_provided = true; 123 + mce->u.ra_error.effective_address = addr; 124 + } else if (mce->error_type == MCE_ERROR_TYPE_LINK) { 125 + mce->u.link_error.effective_address_provided = true; 126 + mce->u.link_error.effective_address = addr; 128 127 } else if (mce->error_type == MCE_ERROR_TYPE_UE) { 129 128 mce->u.ue_error.effective_address_provided = true; 130 129 mce->u.ue_error.effective_address = addr; ··· 258 239 "Parity", 259 240 "Multihit", 260 241 }; 242 + static const char *mc_user_types[] = { 243 + "Indeterminate", 244 + "tlbie(l) invalid", 245 + }; 246 + static const char *mc_ra_types[] = { 247 + "Indeterminate", 248 + "Instruction fetch (bad)", 249 + "Page table walk ifetch (bad)", 250 + "Page table walk ifetch (foreign)", 251 + "Load (bad)", 252 + "Store (bad)", 253 + "Page table walk Load/Store (bad)", 254 + "Page table walk Load/Store (foreign)", 255 + "Load/Store (foreign)", 256 + }; 257 + static const char *mc_link_types[] = { 258 + "Indeterminate", 259 + "Instruction fetch (timeout)", 260 + "Page table walk ifetch (timeout)", 261 + "Load (timeout)", 262 + "Store (timeout)", 263 + "Page table walk Load/Store (timeout)", 264 + }; 261 265 262 266 /* Print things out */ 263 267 if (evt->version != MCE_V1) { ··· 357 315 printk("%s Effective address: %016llx\n", 358 316 level, evt->u.tlb_error.effective_address); 359 317 break; 318 + case MCE_ERROR_TYPE_USER: 319 + subtype = evt->u.user_error.user_error_type < 320 + ARRAY_SIZE(mc_user_types) ? 321 + mc_user_types[evt->u.user_error.user_error_type] 322 + : "Unknown"; 323 + printk("%s Error type: User [%s]\n", level, subtype); 324 + if (evt->u.user_error.effective_address_provided) 325 + printk("%s Effective address: %016llx\n", 326 + level, evt->u.user_error.effective_address); 327 + break; 328 + case MCE_ERROR_TYPE_RA: 329 + subtype = evt->u.ra_error.ra_error_type < 330 + ARRAY_SIZE(mc_ra_types) ? 331 + mc_ra_types[evt->u.ra_error.ra_error_type] 332 + : "Unknown"; 333 + printk("%s Error type: Real address [%s]\n", level, subtype); 334 + if (evt->u.ra_error.effective_address_provided) 335 + printk("%s Effective address: %016llx\n", 336 + level, evt->u.ra_error.effective_address); 337 + break; 338 + case MCE_ERROR_TYPE_LINK: 339 + subtype = evt->u.link_error.link_error_type < 340 + ARRAY_SIZE(mc_link_types) ? 341 + mc_link_types[evt->u.link_error.link_error_type] 342 + : "Unknown"; 343 + printk("%s Error type: Link [%s]\n", level, subtype); 344 + if (evt->u.link_error.effective_address_provided) 345 + printk("%s Effective address: %016llx\n", 346 + level, evt->u.link_error.effective_address); 347 + break; 360 348 default: 361 349 case MCE_ERROR_TYPE_UNKNOWN: 362 350 printk("%s Error type: Unknown\n", level); ··· 412 340 case MCE_ERROR_TYPE_TLB: 413 341 if (evt->u.tlb_error.effective_address_provided) 414 342 return evt->u.tlb_error.effective_address; 343 + break; 344 + case MCE_ERROR_TYPE_USER: 345 + if (evt->u.user_error.effective_address_provided) 346 + return evt->u.user_error.effective_address; 347 + break; 348 + case MCE_ERROR_TYPE_RA: 349 + if (evt->u.ra_error.effective_address_provided) 350 + return evt->u.ra_error.effective_address; 351 + break; 352 + case MCE_ERROR_TYPE_LINK: 353 + if (evt->u.link_error.effective_address_provided) 354 + return evt->u.link_error.effective_address; 415 355 break; 416 356 default: 417 357 case MCE_ERROR_TYPE_UNKNOWN:
+237
arch/powerpc/kernel/mce_power.c
··· 116 116 } 117 117 #endif 118 118 119 + static void flush_erat(void) 120 + { 121 + asm volatile(PPC_INVALIDATE_ERAT : : :"memory"); 122 + } 123 + 124 + #define MCE_FLUSH_SLB 1 125 + #define MCE_FLUSH_TLB 2 126 + #define MCE_FLUSH_ERAT 3 127 + 128 + static int mce_flush(int what) 129 + { 130 + #ifdef CONFIG_PPC_STD_MMU_64 131 + if (what == MCE_FLUSH_SLB) { 132 + flush_and_reload_slb(); 133 + return 1; 134 + } 135 + #endif 136 + if (what == MCE_FLUSH_ERAT) { 137 + flush_erat(); 138 + return 1; 139 + } 140 + if (what == MCE_FLUSH_TLB) { 141 + if (cur_cpu_spec && cur_cpu_spec->flush_tlb) { 142 + cur_cpu_spec->flush_tlb(TLB_INVAL_SCOPE_GLOBAL); 143 + return 1; 144 + } 145 + } 146 + 147 + return 0; 148 + } 149 + 150 + static int mce_handle_flush_derrors(uint64_t dsisr, uint64_t slb, uint64_t tlb, uint64_t erat) 151 + { 152 + if ((dsisr & slb) && mce_flush(MCE_FLUSH_SLB)) 153 + dsisr &= ~slb; 154 + if ((dsisr & erat) && mce_flush(MCE_FLUSH_ERAT)) 155 + dsisr &= ~erat; 156 + if ((dsisr & tlb) && mce_flush(MCE_FLUSH_TLB)) 157 + dsisr &= ~tlb; 158 + /* Any other errors we don't understand? */ 159 + if (dsisr) 160 + return 0; 161 + return 1; 162 + } 163 + 119 164 static long mce_handle_derror(uint64_t dsisr, uint64_t slb_error_bits) 120 165 { 121 166 long handled = 1; ··· 326 281 long handled = 1; 327 282 struct mce_error_info mce_error_info = { 0 }; 328 283 284 + mce_error_info.severity = MCE_SEV_ERROR_SYNC; 285 + mce_error_info.initiator = MCE_INITIATOR_CPU; 286 + 329 287 srr1 = regs->msr; 330 288 nip = regs->nip; 331 289 ··· 400 352 long handled = 1; 401 353 struct mce_error_info mce_error_info = { 0 }; 402 354 355 + mce_error_info.severity = MCE_SEV_ERROR_SYNC; 356 + mce_error_info.initiator = MCE_INITIATOR_CPU; 357 + 403 358 srr1 = regs->msr; 404 359 nip = regs->nip; 405 360 ··· 414 363 handled = mce_handle_ierror_p8(srr1); 415 364 mce_get_ierror_p8(&mce_error_info, srr1); 416 365 addr = regs->nip; 366 + } 367 + 368 + /* Handle UE error. */ 369 + if (mce_error_info.error_type == MCE_ERROR_TYPE_UE) 370 + handled = mce_handle_ue_error(regs); 371 + 372 + save_mce_event(regs, handled, &mce_error_info, nip, addr); 373 + return handled; 374 + } 375 + 376 + static int mce_handle_derror_p9(struct pt_regs *regs) 377 + { 378 + uint64_t dsisr = regs->dsisr; 379 + 380 + return mce_handle_flush_derrors(dsisr, 381 + P9_DSISR_MC_SLB_PARITY_MFSLB | 382 + P9_DSISR_MC_SLB_MULTIHIT_MFSLB, 383 + 384 + P9_DSISR_MC_TLB_MULTIHIT_MFTLB, 385 + 386 + P9_DSISR_MC_ERAT_MULTIHIT); 387 + } 388 + 389 + static int mce_handle_ierror_p9(struct pt_regs *regs) 390 + { 391 + uint64_t srr1 = regs->msr; 392 + 393 + switch (P9_SRR1_MC_IFETCH(srr1)) { 394 + case P9_SRR1_MC_IFETCH_SLB_PARITY: 395 + case P9_SRR1_MC_IFETCH_SLB_MULTIHIT: 396 + return mce_flush(MCE_FLUSH_SLB); 397 + case P9_SRR1_MC_IFETCH_TLB_MULTIHIT: 398 + return mce_flush(MCE_FLUSH_TLB); 399 + case P9_SRR1_MC_IFETCH_ERAT_MULTIHIT: 400 + return mce_flush(MCE_FLUSH_ERAT); 401 + default: 402 + return 0; 403 + } 404 + } 405 + 406 + static void mce_get_derror_p9(struct pt_regs *regs, 407 + struct mce_error_info *mce_err, uint64_t *addr) 408 + { 409 + uint64_t dsisr = regs->dsisr; 410 + 411 + mce_err->severity = MCE_SEV_ERROR_SYNC; 412 + mce_err->initiator = MCE_INITIATOR_CPU; 413 + 414 + if (dsisr & P9_DSISR_MC_USER_TLBIE) 415 + *addr = regs->nip; 416 + else 417 + *addr = regs->dar; 418 + 419 + if (dsisr & P9_DSISR_MC_UE) { 420 + mce_err->error_type = MCE_ERROR_TYPE_UE; 421 + mce_err->u.ue_error_type = MCE_UE_ERROR_LOAD_STORE; 422 + } else if (dsisr & P9_DSISR_MC_UE_TABLEWALK) { 423 + mce_err->error_type = MCE_ERROR_TYPE_UE; 424 + mce_err->u.ue_error_type = MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE; 425 + } else if (dsisr & P9_DSISR_MC_LINK_LOAD_TIMEOUT) { 426 + mce_err->error_type = MCE_ERROR_TYPE_LINK; 427 + mce_err->u.link_error_type = MCE_LINK_ERROR_LOAD_TIMEOUT; 428 + } else if (dsisr & P9_DSISR_MC_LINK_TABLEWALK_TIMEOUT) { 429 + mce_err->error_type = MCE_ERROR_TYPE_LINK; 430 + mce_err->u.link_error_type = MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT; 431 + } else if (dsisr & P9_DSISR_MC_ERAT_MULTIHIT) { 432 + mce_err->error_type = MCE_ERROR_TYPE_ERAT; 433 + mce_err->u.erat_error_type = MCE_ERAT_ERROR_MULTIHIT; 434 + } else if (dsisr & P9_DSISR_MC_TLB_MULTIHIT_MFTLB) { 435 + mce_err->error_type = MCE_ERROR_TYPE_TLB; 436 + mce_err->u.tlb_error_type = MCE_TLB_ERROR_MULTIHIT; 437 + } else if (dsisr & P9_DSISR_MC_USER_TLBIE) { 438 + mce_err->error_type = MCE_ERROR_TYPE_USER; 439 + mce_err->u.user_error_type = MCE_USER_ERROR_TLBIE; 440 + } else if (dsisr & P9_DSISR_MC_SLB_PARITY_MFSLB) { 441 + mce_err->error_type = MCE_ERROR_TYPE_SLB; 442 + mce_err->u.slb_error_type = MCE_SLB_ERROR_PARITY; 443 + } else if (dsisr & P9_DSISR_MC_SLB_MULTIHIT_MFSLB) { 444 + mce_err->error_type = MCE_ERROR_TYPE_SLB; 445 + mce_err->u.slb_error_type = MCE_SLB_ERROR_MULTIHIT; 446 + } else if (dsisr & P9_DSISR_MC_RA_LOAD) { 447 + mce_err->error_type = MCE_ERROR_TYPE_RA; 448 + mce_err->u.ra_error_type = MCE_RA_ERROR_LOAD; 449 + } else if (dsisr & P9_DSISR_MC_RA_TABLEWALK) { 450 + mce_err->error_type = MCE_ERROR_TYPE_RA; 451 + mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE; 452 + } else if (dsisr & P9_DSISR_MC_RA_TABLEWALK_FOREIGN) { 453 + mce_err->error_type = MCE_ERROR_TYPE_RA; 454 + mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN; 455 + } else if (dsisr & P9_DSISR_MC_RA_FOREIGN) { 456 + mce_err->error_type = MCE_ERROR_TYPE_RA; 457 + mce_err->u.ra_error_type = MCE_RA_ERROR_LOAD_STORE_FOREIGN; 458 + } 459 + } 460 + 461 + static void mce_get_ierror_p9(struct pt_regs *regs, 462 + struct mce_error_info *mce_err, uint64_t *addr) 463 + { 464 + uint64_t srr1 = regs->msr; 465 + 466 + switch (P9_SRR1_MC_IFETCH(srr1)) { 467 + case P9_SRR1_MC_IFETCH_RA_ASYNC_STORE: 468 + case P9_SRR1_MC_IFETCH_LINK_ASYNC_STORE_TIMEOUT: 469 + mce_err->severity = MCE_SEV_FATAL; 470 + break; 471 + default: 472 + mce_err->severity = MCE_SEV_ERROR_SYNC; 473 + break; 474 + } 475 + 476 + mce_err->initiator = MCE_INITIATOR_CPU; 477 + 478 + *addr = regs->nip; 479 + 480 + switch (P9_SRR1_MC_IFETCH(srr1)) { 481 + case P9_SRR1_MC_IFETCH_UE: 482 + mce_err->error_type = MCE_ERROR_TYPE_UE; 483 + mce_err->u.ue_error_type = MCE_UE_ERROR_IFETCH; 484 + break; 485 + case P9_SRR1_MC_IFETCH_SLB_PARITY: 486 + mce_err->error_type = MCE_ERROR_TYPE_SLB; 487 + mce_err->u.slb_error_type = MCE_SLB_ERROR_PARITY; 488 + break; 489 + case P9_SRR1_MC_IFETCH_SLB_MULTIHIT: 490 + mce_err->error_type = MCE_ERROR_TYPE_SLB; 491 + mce_err->u.slb_error_type = MCE_SLB_ERROR_MULTIHIT; 492 + break; 493 + case P9_SRR1_MC_IFETCH_ERAT_MULTIHIT: 494 + mce_err->error_type = MCE_ERROR_TYPE_ERAT; 495 + mce_err->u.erat_error_type = MCE_ERAT_ERROR_MULTIHIT; 496 + break; 497 + case P9_SRR1_MC_IFETCH_TLB_MULTIHIT: 498 + mce_err->error_type = MCE_ERROR_TYPE_TLB; 499 + mce_err->u.tlb_error_type = MCE_TLB_ERROR_MULTIHIT; 500 + break; 501 + case P9_SRR1_MC_IFETCH_UE_TLB_RELOAD: 502 + mce_err->error_type = MCE_ERROR_TYPE_UE; 503 + mce_err->u.ue_error_type = MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH; 504 + break; 505 + case P9_SRR1_MC_IFETCH_LINK_TIMEOUT: 506 + mce_err->error_type = MCE_ERROR_TYPE_LINK; 507 + mce_err->u.link_error_type = MCE_LINK_ERROR_IFETCH_TIMEOUT; 508 + break; 509 + case P9_SRR1_MC_IFETCH_LINK_TABLEWALK_TIMEOUT: 510 + mce_err->error_type = MCE_ERROR_TYPE_LINK; 511 + mce_err->u.link_error_type = MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT; 512 + break; 513 + case P9_SRR1_MC_IFETCH_RA: 514 + mce_err->error_type = MCE_ERROR_TYPE_RA; 515 + mce_err->u.ra_error_type = MCE_RA_ERROR_IFETCH; 516 + break; 517 + case P9_SRR1_MC_IFETCH_RA_TABLEWALK: 518 + mce_err->error_type = MCE_ERROR_TYPE_RA; 519 + mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH; 520 + break; 521 + case P9_SRR1_MC_IFETCH_RA_ASYNC_STORE: 522 + mce_err->error_type = MCE_ERROR_TYPE_RA; 523 + mce_err->u.ra_error_type = MCE_RA_ERROR_STORE; 524 + break; 525 + case P9_SRR1_MC_IFETCH_LINK_ASYNC_STORE_TIMEOUT: 526 + mce_err->error_type = MCE_ERROR_TYPE_LINK; 527 + mce_err->u.link_error_type = MCE_LINK_ERROR_STORE_TIMEOUT; 528 + break; 529 + case P9_SRR1_MC_IFETCH_RA_TABLEWALK_FOREIGN: 530 + mce_err->error_type = MCE_ERROR_TYPE_RA; 531 + mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN; 532 + break; 533 + default: 534 + break; 535 + } 536 + } 537 + 538 + long __machine_check_early_realmode_p9(struct pt_regs *regs) 539 + { 540 + uint64_t nip, addr; 541 + long handled; 542 + struct mce_error_info mce_error_info = { 0 }; 543 + 544 + nip = regs->nip; 545 + 546 + if (P9_SRR1_MC_LOADSTORE(regs->msr)) { 547 + handled = mce_handle_derror_p9(regs); 548 + mce_get_derror_p9(regs, &mce_error_info, &addr); 549 + } else { 550 + handled = mce_handle_ierror_p9(regs); 551 + mce_get_ierror_p9(regs, &mce_error_info, &addr); 417 552 } 418 553 419 554 /* Handle UE error. */
+2
arch/powerpc/perf/core-book3s.c
··· 188 188 sdsync = POWER7P_MMCRA_SDAR_VALID; 189 189 else if (ppmu->flags & PPMU_ALT_SIPR) 190 190 sdsync = POWER6_MMCRA_SDSYNC; 191 + else if (ppmu->flags & PPMU_NO_SIAR) 192 + sdsync = MMCRA_SAMPLE_ENABLE; 191 193 else 192 194 sdsync = MMCRA_SDSYNC; 193 195
+36 -7
arch/powerpc/perf/isa207-common.c
··· 65 65 return !(event & ~valid_mask); 66 66 } 67 67 68 - static u64 mmcra_sdar_mode(u64 event) 68 + static inline bool is_event_marked(u64 event) 69 69 { 70 - if (cpu_has_feature(CPU_FTR_ARCH_300) && !cpu_has_feature(CPU_FTR_POWER9_DD1)) 71 - return p9_SDAR_MODE(event) << MMCRA_SDAR_MODE_SHIFT; 70 + if (event & EVENT_IS_MARKED) 71 + return true; 72 72 73 - return MMCRA_SDAR_MODE_TLB; 73 + return false; 74 + } 75 + 76 + static void mmcra_sdar_mode(u64 event, unsigned long *mmcra) 77 + { 78 + /* 79 + * MMCRA[SDAR_MODE] specifices how the SDAR should be updated in 80 + * continous sampling mode. 81 + * 82 + * Incase of Power8: 83 + * MMCRA[SDAR_MODE] will be programmed as "0b01" for continous sampling 84 + * mode and will be un-changed when setting MMCRA[63] (Marked events). 85 + * 86 + * Incase of Power9: 87 + * Marked event: MMCRA[SDAR_MODE] will be set to 0b00 ('No Updates'), 88 + * or if group already have any marked events. 89 + * Non-Marked events (for DD1): 90 + * MMCRA[SDAR_MODE] will be set to 0b01 91 + * For rest 92 + * MMCRA[SDAR_MODE] will be set from event code. 93 + */ 94 + if (cpu_has_feature(CPU_FTR_ARCH_300)) { 95 + if (is_event_marked(event) || (*mmcra & MMCRA_SAMPLE_ENABLE)) 96 + *mmcra &= MMCRA_SDAR_MODE_NO_UPDATES; 97 + else if (!cpu_has_feature(CPU_FTR_POWER9_DD1)) 98 + *mmcra |= p9_SDAR_MODE(event) << MMCRA_SDAR_MODE_SHIFT; 99 + else if (cpu_has_feature(CPU_FTR_POWER9_DD1)) 100 + *mmcra |= MMCRA_SDAR_MODE_TLB; 101 + } else 102 + *mmcra |= MMCRA_SDAR_MODE_TLB; 74 103 } 75 104 76 105 static u64 thresh_cmp_val(u64 value) ··· 209 180 value |= CNST_L1_QUAL_VAL(cache); 210 181 } 211 182 212 - if (event & EVENT_IS_MARKED) { 183 + if (is_event_marked(event)) { 213 184 mask |= CNST_SAMPLE_MASK; 214 185 value |= CNST_SAMPLE_VAL(event >> EVENT_SAMPLE_SHIFT); 215 186 } ··· 305 276 } 306 277 307 278 /* In continuous sampling mode, update SDAR on TLB miss */ 308 - mmcra |= mmcra_sdar_mode(event[i]); 279 + mmcra_sdar_mode(event[i], &mmcra); 309 280 310 281 if (event[i] & EVENT_IS_L1) { 311 282 cache = event[i] >> EVENT_CACHE_SEL_SHIFT; ··· 314 285 mmcr1 |= (cache & 1) << MMCR1_DC_QUAL_SHIFT; 315 286 } 316 287 317 - if (event[i] & EVENT_IS_MARKED) { 288 + if (is_event_marked(event[i])) { 318 289 mmcra |= MMCRA_SAMPLE_ENABLE; 319 290 320 291 val = (event[i] >> EVENT_SAMPLE_SHIFT) & EVENT_SAMPLE_MASK;
+1
arch/powerpc/perf/isa207-common.h
··· 246 246 #define MMCRA_THR_CMP_SHIFT 32 247 247 #define MMCRA_SDAR_MODE_SHIFT 42 248 248 #define MMCRA_SDAR_MODE_TLB (1ull << MMCRA_SDAR_MODE_SHIFT) 249 + #define MMCRA_SDAR_MODE_NO_UPDATES ~(0x3ull << MMCRA_SDAR_MODE_SHIFT) 249 250 #define MMCRA_IFM_SHIFT 30 250 251 251 252 /* MMCR1 Threshold Compare bit constant for power9 */
+6 -15
arch/powerpc/platforms/powernv/opal.c
··· 395 395 struct machine_check_event *evt) 396 396 { 397 397 int recovered = 0; 398 - uint64_t ea = get_mce_fault_addr(evt); 399 398 400 399 if (!(regs->msr & MSR_RI)) { 401 400 /* If MSR_RI isn't set, we cannot recover */ ··· 403 404 } else if (evt->disposition == MCE_DISPOSITION_RECOVERED) { 404 405 /* Platform corrected itself */ 405 406 recovered = 1; 406 - } else if (ea && !is_kernel_addr(ea)) { 407 + } else if (evt->severity == MCE_SEV_FATAL) { 408 + /* Fatal machine check */ 409 + pr_err("Machine check interrupt is fatal\n"); 410 + recovered = 0; 411 + } else if ((evt->severity == MCE_SEV_ERROR_SYNC) && 412 + (user_mode(regs) && !is_global_init(current))) { 407 413 /* 408 - * Faulting address is not in kernel text. We should be fine. 409 - * We need to find which process uses this address. 410 414 * For now, kill the task if we have received exception when 411 415 * in userspace. 412 416 * 413 417 * TODO: Queue up this address for hwpoisioning later. 414 - */ 415 - if (user_mode(regs) && !is_global_init(current)) { 416 - _exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip); 417 - recovered = 1; 418 - } else 419 - recovered = 0; 420 - } else if (user_mode(regs) && !is_global_init(current) && 421 - evt->severity == MCE_SEV_ERROR_SYNC) { 422 - /* 423 - * If we have received a synchronous error when in userspace 424 - * kill the task. 425 418 */ 426 419 _exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip); 427 420 recovered = 1;
+15 -5
arch/powerpc/platforms/powernv/pci-ioda.c
··· 1775 1775 } 1776 1776 1777 1777 static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, 1778 - struct pci_bus *bus) 1778 + struct pci_bus *bus, 1779 + bool add_to_group) 1779 1780 { 1780 1781 struct pci_dev *dev; 1781 1782 1782 1783 list_for_each_entry(dev, &bus->devices, bus_list) { 1783 1784 set_iommu_table_base(&dev->dev, pe->table_group.tables[0]); 1784 1785 set_dma_offset(&dev->dev, pe->tce_bypass_base); 1785 - iommu_add_device(&dev->dev); 1786 + if (add_to_group) 1787 + iommu_add_device(&dev->dev); 1786 1788 1787 1789 if ((pe->flags & PNV_IODA_PE_BUS_ALL) && dev->subordinate) 1788 - pnv_ioda_setup_bus_dma(pe, dev->subordinate); 1790 + pnv_ioda_setup_bus_dma(pe, dev->subordinate, 1791 + add_to_group); 1789 1792 } 1790 1793 } 1791 1794 ··· 2194 2191 set_iommu_table_base(&pe->pdev->dev, tbl); 2195 2192 iommu_add_device(&pe->pdev->dev); 2196 2193 } else if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)) 2197 - pnv_ioda_setup_bus_dma(pe, pe->pbus); 2194 + pnv_ioda_setup_bus_dma(pe, pe->pbus, true); 2198 2195 2199 2196 return; 2200 2197 fail: ··· 2429 2426 2430 2427 pnv_pci_ioda2_set_bypass(pe, false); 2431 2428 pnv_pci_ioda2_unset_window(&pe->table_group, 0); 2429 + if (pe->pbus) 2430 + pnv_ioda_setup_bus_dma(pe, pe->pbus, false); 2432 2431 pnv_ioda2_table_free(tbl); 2433 2432 } 2434 2433 ··· 2440 2435 table_group); 2441 2436 2442 2437 pnv_pci_ioda2_setup_default_config(pe); 2438 + if (pe->pbus) 2439 + pnv_ioda_setup_bus_dma(pe, pe->pbus, false); 2443 2440 } 2444 2441 2445 2442 static struct iommu_table_group_ops pnv_pci_ioda2_ops = { ··· 2631 2624 level_shift = entries_shift + 3; 2632 2625 level_shift = max_t(unsigned, level_shift, PAGE_SHIFT); 2633 2626 2627 + if ((level_shift - 3) * levels + page_shift >= 60) 2628 + return -EINVAL; 2629 + 2634 2630 /* Allocate TCE table */ 2635 2631 addr = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift, 2636 2632 levels, tce_table_size, &offset, &total_allocated); ··· 2738 2728 if (pe->flags & PNV_IODA_PE_DEV) 2739 2729 iommu_add_device(&pe->pdev->dev); 2740 2730 else if (pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)) 2741 - pnv_ioda_setup_bus_dma(pe, pe->pbus); 2731 + pnv_ioda_setup_bus_dma(pe, pe->pbus, true); 2742 2732 } 2743 2733 2744 2734 #ifdef CONFIG_PCI_MSI
+9 -3
block/bio.c
··· 376 376 bio_list_init(&punt); 377 377 bio_list_init(&nopunt); 378 378 379 - while ((bio = bio_list_pop(current->bio_list))) 379 + while ((bio = bio_list_pop(&current->bio_list[0]))) 380 380 bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio); 381 + current->bio_list[0] = nopunt; 381 382 382 - *current->bio_list = nopunt; 383 + bio_list_init(&nopunt); 384 + while ((bio = bio_list_pop(&current->bio_list[1]))) 385 + bio_list_add(bio->bi_pool == bs ? &punt : &nopunt, bio); 386 + current->bio_list[1] = nopunt; 383 387 384 388 spin_lock(&bs->rescue_lock); 385 389 bio_list_merge(&bs->rescue_list, &punt); ··· 470 466 * we retry with the original gfp_flags. 471 467 */ 472 468 473 - if (current->bio_list && !bio_list_empty(current->bio_list)) 469 + if (current->bio_list && 470 + (!bio_list_empty(&current->bio_list[0]) || 471 + !bio_list_empty(&current->bio_list[1]))) 474 472 gfp_mask &= ~__GFP_DIRECT_RECLAIM; 475 473 476 474 p = mempool_alloc(bs->bio_pool, gfp_mask);
+18 -12
block/blk-core.c
··· 1973 1973 */ 1974 1974 blk_qc_t generic_make_request(struct bio *bio) 1975 1975 { 1976 - struct bio_list bio_list_on_stack; 1976 + /* 1977 + * bio_list_on_stack[0] contains bios submitted by the current 1978 + * make_request_fn. 1979 + * bio_list_on_stack[1] contains bios that were submitted before 1980 + * the current make_request_fn, but that haven't been processed 1981 + * yet. 1982 + */ 1983 + struct bio_list bio_list_on_stack[2]; 1977 1984 blk_qc_t ret = BLK_QC_T_NONE; 1978 1985 1979 1986 if (!generic_make_request_checks(bio)) ··· 1997 1990 * should be added at the tail 1998 1991 */ 1999 1992 if (current->bio_list) { 2000 - bio_list_add(current->bio_list, bio); 1993 + bio_list_add(&current->bio_list[0], bio); 2001 1994 goto out; 2002 1995 } 2003 1996 ··· 2016 2009 * bio_list, and call into ->make_request() again. 2017 2010 */ 2018 2011 BUG_ON(bio->bi_next); 2019 - bio_list_init(&bio_list_on_stack); 2020 - current->bio_list = &bio_list_on_stack; 2012 + bio_list_init(&bio_list_on_stack[0]); 2013 + current->bio_list = bio_list_on_stack; 2021 2014 do { 2022 2015 struct request_queue *q = bdev_get_queue(bio->bi_bdev); 2023 2016 2024 2017 if (likely(blk_queue_enter(q, false) == 0)) { 2025 - struct bio_list hold; 2026 2018 struct bio_list lower, same; 2027 2019 2028 2020 /* Create a fresh bio_list for all subordinate requests */ 2029 - hold = bio_list_on_stack; 2030 - bio_list_init(&bio_list_on_stack); 2021 + bio_list_on_stack[1] = bio_list_on_stack[0]; 2022 + bio_list_init(&bio_list_on_stack[0]); 2031 2023 ret = q->make_request_fn(q, bio); 2032 2024 2033 2025 blk_queue_exit(q); ··· 2036 2030 */ 2037 2031 bio_list_init(&lower); 2038 2032 bio_list_init(&same); 2039 - while ((bio = bio_list_pop(&bio_list_on_stack)) != NULL) 2033 + while ((bio = bio_list_pop(&bio_list_on_stack[0])) != NULL) 2040 2034 if (q == bdev_get_queue(bio->bi_bdev)) 2041 2035 bio_list_add(&same, bio); 2042 2036 else 2043 2037 bio_list_add(&lower, bio); 2044 2038 /* now assemble so we handle the lowest level first */ 2045 - bio_list_merge(&bio_list_on_stack, &lower); 2046 - bio_list_merge(&bio_list_on_stack, &same); 2047 - bio_list_merge(&bio_list_on_stack, &hold); 2039 + bio_list_merge(&bio_list_on_stack[0], &lower); 2040 + bio_list_merge(&bio_list_on_stack[0], &same); 2041 + bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]); 2048 2042 } else { 2049 2043 bio_io_error(bio); 2050 2044 } 2051 - bio = bio_list_pop(current->bio_list); 2045 + bio = bio_list_pop(&bio_list_on_stack[0]); 2052 2046 } while (bio); 2053 2047 current->bio_list = NULL; /* deactivate */ 2054 2048
+3
block/blk-mq-tag.c
··· 295 295 for (i = 0; i < set->nr_hw_queues; i++) { 296 296 struct blk_mq_tags *tags = set->tags[i]; 297 297 298 + if (!tags) 299 + continue; 300 + 298 301 for (j = 0; j < tags->nr_tags; j++) { 299 302 if (!tags->static_rqs[j]) 300 303 continue;
+5 -4
block/blk-mq.c
··· 1434 1434 return blk_tag_to_qc_t(rq->internal_tag, hctx->queue_num, true); 1435 1435 } 1436 1436 1437 - static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie) 1437 + static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie, 1438 + bool may_sleep) 1438 1439 { 1439 1440 struct request_queue *q = rq->q; 1440 1441 struct blk_mq_queue_data bd = { ··· 1476 1475 } 1477 1476 1478 1477 insert: 1479 - blk_mq_sched_insert_request(rq, false, true, true, false); 1478 + blk_mq_sched_insert_request(rq, false, true, false, may_sleep); 1480 1479 } 1481 1480 1482 1481 /* ··· 1570 1569 1571 1570 if (!(data.hctx->flags & BLK_MQ_F_BLOCKING)) { 1572 1571 rcu_read_lock(); 1573 - blk_mq_try_issue_directly(old_rq, &cookie); 1572 + blk_mq_try_issue_directly(old_rq, &cookie, false); 1574 1573 rcu_read_unlock(); 1575 1574 } else { 1576 1575 srcu_idx = srcu_read_lock(&data.hctx->queue_rq_srcu); 1577 - blk_mq_try_issue_directly(old_rq, &cookie); 1576 + blk_mq_try_issue_directly(old_rq, &cookie, true); 1578 1577 srcu_read_unlock(&data.hctx->queue_rq_srcu, srcu_idx); 1579 1578 } 1580 1579 goto done;
+5 -4
crypto/af_alg.c
··· 266 266 return err; 267 267 } 268 268 269 - int af_alg_accept(struct sock *sk, struct socket *newsock) 269 + int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern) 270 270 { 271 271 struct alg_sock *ask = alg_sk(sk); 272 272 const struct af_alg_type *type; ··· 281 281 if (!type) 282 282 goto unlock; 283 283 284 - sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, 0); 284 + sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, kern); 285 285 err = -ENOMEM; 286 286 if (!sk2) 287 287 goto unlock; ··· 323 323 } 324 324 EXPORT_SYMBOL_GPL(af_alg_accept); 325 325 326 - static int alg_accept(struct socket *sock, struct socket *newsock, int flags) 326 + static int alg_accept(struct socket *sock, struct socket *newsock, int flags, 327 + bool kern) 327 328 { 328 - return af_alg_accept(sock->sk, newsock); 329 + return af_alg_accept(sock->sk, newsock, kern); 329 330 } 330 331 331 332 static const struct proto_ops alg_proto_ops = {
+5 -4
crypto/algif_hash.c
··· 239 239 return err ?: len; 240 240 } 241 241 242 - static int hash_accept(struct socket *sock, struct socket *newsock, int flags) 242 + static int hash_accept(struct socket *sock, struct socket *newsock, int flags, 243 + bool kern) 243 244 { 244 245 struct sock *sk = sock->sk; 245 246 struct alg_sock *ask = alg_sk(sk); ··· 261 260 if (err) 262 261 return err; 263 262 264 - err = af_alg_accept(ask->parent, newsock); 263 + err = af_alg_accept(ask->parent, newsock, kern); 265 264 if (err) 266 265 return err; 267 266 ··· 379 378 } 380 379 381 380 static int hash_accept_nokey(struct socket *sock, struct socket *newsock, 382 - int flags) 381 + int flags, bool kern) 383 382 { 384 383 int err; 385 384 ··· 387 386 if (err) 388 387 return err; 389 388 390 - return hash_accept(sock, newsock, flags); 389 + return hash_accept(sock, newsock, flags, kern); 391 390 } 392 391 393 392 static struct proto_ops algif_hash_ops_nokey = {
+4 -2
drivers/ata/ahci_qoriq.c
··· 177 177 case AHCI_LS1043A: 178 178 if (!qpriv->ecc_addr) 179 179 return -EINVAL; 180 - writel(ECC_DIS_ARMV8_CH2, qpriv->ecc_addr); 180 + writel(readl(qpriv->ecc_addr) | ECC_DIS_ARMV8_CH2, 181 + qpriv->ecc_addr); 181 182 writel(AHCI_PORT_PHY_1_CFG, reg_base + PORT_PHY1); 182 183 writel(AHCI_PORT_TRANS_CFG, reg_base + PORT_TRANS); 183 184 if (qpriv->is_dmacoherent) ··· 195 194 case AHCI_LS1046A: 196 195 if (!qpriv->ecc_addr) 197 196 return -EINVAL; 198 - writel(ECC_DIS_ARMV8_CH2, qpriv->ecc_addr); 197 + writel(readl(qpriv->ecc_addr) | ECC_DIS_ARMV8_CH2, 198 + qpriv->ecc_addr); 199 199 writel(AHCI_PORT_PHY_1_CFG, reg_base + PORT_PHY1); 200 200 writel(AHCI_PORT_TRANS_CFG, reg_base + PORT_TRANS); 201 201 if (qpriv->is_dmacoherent)
-1
drivers/ata/libata-sff.c
··· 1482 1482 break; 1483 1483 1484 1484 default: 1485 - WARN_ON_ONCE(1); 1486 1485 return AC_ERR_SYSTEM; 1487 1486 } 1488 1487
+3 -6
drivers/ata/libata-transport.c
··· 224 224 225 225 static void ata_tport_release(struct device *dev) 226 226 { 227 - put_device(dev->parent); 228 227 } 229 228 230 229 /** ··· 283 284 device_initialize(dev); 284 285 dev->type = &ata_port_type; 285 286 286 - dev->parent = get_device(parent); 287 + dev->parent = parent; 287 288 dev->release = ata_tport_release; 288 289 dev_set_name(dev, "ata%d", ap->print_id); 289 290 transport_setup_device(dev); ··· 347 348 348 349 static void ata_tlink_release(struct device *dev) 349 350 { 350 - put_device(dev->parent); 351 351 } 352 352 353 353 /** ··· 408 410 int error; 409 411 410 412 device_initialize(dev); 411 - dev->parent = get_device(&ap->tdev); 413 + dev->parent = &ap->tdev; 412 414 dev->release = ata_tlink_release; 413 415 if (ata_is_host_link(link)) 414 416 dev_set_name(dev, "link%d", ap->print_id); ··· 587 589 588 590 static void ata_tdev_release(struct device *dev) 589 591 { 590 - put_device(dev->parent); 591 592 } 592 593 593 594 /** ··· 659 662 int error; 660 663 661 664 device_initialize(dev); 662 - dev->parent = get_device(&link->tdev); 665 + dev->parent = &link->tdev; 663 666 dev->release = ata_tdev_release; 664 667 if (ata_is_host_link(link)) 665 668 dev_set_name(dev, "dev%d.%d", ap->print_id,ata_dev->devno);
+14 -2
drivers/char/hw_random/omap-rng.c
··· 397 397 irq, err); 398 398 return err; 399 399 } 400 - omap_rng_write(priv, RNG_INTMASK_REG, RNG_SHUTDOWN_OFLO_MASK); 401 400 402 - priv->clk = of_clk_get(pdev->dev.of_node, 0); 401 + priv->clk = devm_clk_get(&pdev->dev, NULL); 403 402 if (IS_ERR(priv->clk) && PTR_ERR(priv->clk) == -EPROBE_DEFER) 404 403 return -EPROBE_DEFER; 405 404 if (!IS_ERR(priv->clk)) { ··· 407 408 dev_err(&pdev->dev, "unable to enable the clk, " 408 409 "err = %d\n", err); 409 410 } 411 + 412 + /* 413 + * On OMAP4, enabling the shutdown_oflo interrupt is 414 + * done in the interrupt mask register. There is no 415 + * such register on EIP76, and it's enabled by the 416 + * same bit in the control register 417 + */ 418 + if (priv->pdata->regs[RNG_INTMASK_REG]) 419 + omap_rng_write(priv, RNG_INTMASK_REG, 420 + RNG_SHUTDOWN_OFLO_MASK); 421 + else 422 + omap_rng_write(priv, RNG_CONTROL_REG, 423 + RNG_SHUTDOWN_OFLO_MASK); 410 424 } 411 425 return 0; 412 426 }
+85 -47
drivers/crypto/s5p-sss.c
··· 270 270 scatterwalk_done(&walk, out, 0); 271 271 } 272 272 273 - static void s5p_aes_complete(struct s5p_aes_dev *dev, int err) 273 + static void s5p_sg_done(struct s5p_aes_dev *dev) 274 274 { 275 275 if (dev->sg_dst_cpy) { 276 276 dev_dbg(dev->dev, ··· 281 281 } 282 282 s5p_free_sg_cpy(dev, &dev->sg_src_cpy); 283 283 s5p_free_sg_cpy(dev, &dev->sg_dst_cpy); 284 + } 284 285 285 - /* holding a lock outside */ 286 + /* Calls the completion. Cannot be called with dev->lock hold. */ 287 + static void s5p_aes_complete(struct s5p_aes_dev *dev, int err) 288 + { 286 289 dev->req->base.complete(&dev->req->base, err); 287 290 dev->busy = false; 288 291 } ··· 371 368 } 372 369 373 370 /* 374 - * Returns true if new transmitting (output) data is ready and its 375 - * address+length have to be written to device (by calling 376 - * s5p_set_dma_outdata()). False otherwise. 371 + * Returns -ERRNO on error (mapping of new data failed). 372 + * On success returns: 373 + * - 0 if there is no more data, 374 + * - 1 if new transmitting (output) data is ready and its address+length 375 + * have to be written to device (by calling s5p_set_dma_outdata()). 377 376 */ 378 - static bool s5p_aes_tx(struct s5p_aes_dev *dev) 377 + static int s5p_aes_tx(struct s5p_aes_dev *dev) 379 378 { 380 - int err = 0; 381 - bool ret = false; 379 + int ret = 0; 382 380 383 381 s5p_unset_outdata(dev); 384 382 385 383 if (!sg_is_last(dev->sg_dst)) { 386 - err = s5p_set_outdata(dev, sg_next(dev->sg_dst)); 387 - if (err) 388 - s5p_aes_complete(dev, err); 389 - else 390 - ret = true; 391 - } else { 392 - s5p_aes_complete(dev, err); 393 - 394 - dev->busy = true; 395 - tasklet_schedule(&dev->tasklet); 384 + ret = s5p_set_outdata(dev, sg_next(dev->sg_dst)); 385 + if (!ret) 386 + ret = 1; 396 387 } 397 388 398 389 return ret; 399 390 } 400 391 401 392 /* 402 - * Returns true if new receiving (input) data is ready and its 403 - * address+length have to be written to device (by calling 404 - * s5p_set_dma_indata()). False otherwise. 393 + * Returns -ERRNO on error (mapping of new data failed). 394 + * On success returns: 395 + * - 0 if there is no more data, 396 + * - 1 if new receiving (input) data is ready and its address+length 397 + * have to be written to device (by calling s5p_set_dma_indata()). 405 398 */ 406 - static bool s5p_aes_rx(struct s5p_aes_dev *dev) 399 + static int s5p_aes_rx(struct s5p_aes_dev *dev/*, bool *set_dma*/) 407 400 { 408 - int err; 409 - bool ret = false; 401 + int ret = 0; 410 402 411 403 s5p_unset_indata(dev); 412 404 413 405 if (!sg_is_last(dev->sg_src)) { 414 - err = s5p_set_indata(dev, sg_next(dev->sg_src)); 415 - if (err) 416 - s5p_aes_complete(dev, err); 417 - else 418 - ret = true; 406 + ret = s5p_set_indata(dev, sg_next(dev->sg_src)); 407 + if (!ret) 408 + ret = 1; 419 409 } 420 410 421 411 return ret; ··· 418 422 { 419 423 struct platform_device *pdev = dev_id; 420 424 struct s5p_aes_dev *dev = platform_get_drvdata(pdev); 421 - bool set_dma_tx = false; 422 - bool set_dma_rx = false; 425 + int err_dma_tx = 0; 426 + int err_dma_rx = 0; 427 + bool tx_end = false; 423 428 unsigned long flags; 424 429 uint32_t status; 430 + int err; 425 431 426 432 spin_lock_irqsave(&dev->lock, flags); 427 433 434 + /* 435 + * Handle rx or tx interrupt. If there is still data (scatterlist did not 436 + * reach end), then map next scatterlist entry. 437 + * In case of such mapping error, s5p_aes_complete() should be called. 438 + * 439 + * If there is no more data in tx scatter list, call s5p_aes_complete() 440 + * and schedule new tasklet. 441 + */ 428 442 status = SSS_READ(dev, FCINTSTAT); 429 443 if (status & SSS_FCINTSTAT_BRDMAINT) 430 - set_dma_rx = s5p_aes_rx(dev); 431 - if (status & SSS_FCINTSTAT_BTDMAINT) 432 - set_dma_tx = s5p_aes_tx(dev); 444 + err_dma_rx = s5p_aes_rx(dev); 445 + 446 + if (status & SSS_FCINTSTAT_BTDMAINT) { 447 + if (sg_is_last(dev->sg_dst)) 448 + tx_end = true; 449 + err_dma_tx = s5p_aes_tx(dev); 450 + } 433 451 434 452 SSS_WRITE(dev, FCINTPEND, status); 435 453 436 - /* 437 - * Writing length of DMA block (either receiving or transmitting) 438 - * will start the operation immediately, so this should be done 439 - * at the end (even after clearing pending interrupts to not miss the 440 - * interrupt). 441 - */ 442 - if (set_dma_tx) 443 - s5p_set_dma_outdata(dev, dev->sg_dst); 444 - if (set_dma_rx) 445 - s5p_set_dma_indata(dev, dev->sg_src); 454 + if (err_dma_rx < 0) { 455 + err = err_dma_rx; 456 + goto error; 457 + } 458 + if (err_dma_tx < 0) { 459 + err = err_dma_tx; 460 + goto error; 461 + } 446 462 463 + if (tx_end) { 464 + s5p_sg_done(dev); 465 + 466 + spin_unlock_irqrestore(&dev->lock, flags); 467 + 468 + s5p_aes_complete(dev, 0); 469 + dev->busy = true; 470 + tasklet_schedule(&dev->tasklet); 471 + } else { 472 + /* 473 + * Writing length of DMA block (either receiving or 474 + * transmitting) will start the operation immediately, so this 475 + * should be done at the end (even after clearing pending 476 + * interrupts to not miss the interrupt). 477 + */ 478 + if (err_dma_tx == 1) 479 + s5p_set_dma_outdata(dev, dev->sg_dst); 480 + if (err_dma_rx == 1) 481 + s5p_set_dma_indata(dev, dev->sg_src); 482 + 483 + spin_unlock_irqrestore(&dev->lock, flags); 484 + } 485 + 486 + return IRQ_HANDLED; 487 + 488 + error: 489 + s5p_sg_done(dev); 447 490 spin_unlock_irqrestore(&dev->lock, flags); 491 + s5p_aes_complete(dev, err); 448 492 449 493 return IRQ_HANDLED; 450 494 } ··· 633 597 s5p_unset_indata(dev); 634 598 635 599 indata_error: 636 - s5p_aes_complete(dev, err); 600 + s5p_sg_done(dev); 637 601 spin_unlock_irqrestore(&dev->lock, flags); 602 + s5p_aes_complete(dev, err); 638 603 } 639 604 640 605 static void s5p_tasklet_cb(unsigned long data) ··· 842 805 dev_warn(dev, "feed control interrupt is not available.\n"); 843 806 goto err_irq; 844 807 } 845 - err = devm_request_irq(dev, pdata->irq_fc, s5p_aes_interrupt, 846 - IRQF_SHARED, pdev->name, pdev); 808 + err = devm_request_threaded_irq(dev, pdata->irq_fc, NULL, 809 + s5p_aes_interrupt, IRQF_ONESHOT, 810 + pdev->name, pdev); 847 811 if (err < 0) { 848 812 dev_warn(dev, "feed control interrupt is not available.\n"); 849 813 goto err_irq;
+3
drivers/isdn/gigaset/bas-gigaset.c
··· 2317 2317 return -ENODEV; 2318 2318 } 2319 2319 2320 + if (hostif->desc.bNumEndpoints < 1) 2321 + return -ENODEV; 2322 + 2320 2323 dev_info(&udev->dev, 2321 2324 "%s: Device matched (Vendor: 0x%x, Product: 0x%x)\n", 2322 2325 __func__, le16_to_cpu(udev->descriptor.idVendor),
+1
drivers/macintosh/macio_asic.c
··· 392 392 * To get all the fields, copy all archdata 393 393 */ 394 394 dev->ofdev.dev.archdata = chip->lbus.pdev->dev.archdata; 395 + dev->ofdev.dev.dma_ops = chip->lbus.pdev->dev.dma_ops; 395 396 #endif /* CONFIG_PCI */ 396 397 397 398 #ifdef DEBUG
+15 -12
drivers/md/dm.c
··· 989 989 struct dm_offload *o = container_of(cb, struct dm_offload, cb); 990 990 struct bio_list list; 991 991 struct bio *bio; 992 + int i; 992 993 993 994 INIT_LIST_HEAD(&o->cb.list); 994 995 995 996 if (unlikely(!current->bio_list)) 996 997 return; 997 998 998 - list = *current->bio_list; 999 - bio_list_init(current->bio_list); 999 + for (i = 0; i < 2; i++) { 1000 + list = current->bio_list[i]; 1001 + bio_list_init(&current->bio_list[i]); 1000 1002 1001 - while ((bio = bio_list_pop(&list))) { 1002 - struct bio_set *bs = bio->bi_pool; 1003 - if (unlikely(!bs) || bs == fs_bio_set) { 1004 - bio_list_add(current->bio_list, bio); 1005 - continue; 1003 + while ((bio = bio_list_pop(&list))) { 1004 + struct bio_set *bs = bio->bi_pool; 1005 + if (unlikely(!bs) || bs == fs_bio_set) { 1006 + bio_list_add(&current->bio_list[i], bio); 1007 + continue; 1008 + } 1009 + 1010 + spin_lock(&bs->rescue_lock); 1011 + bio_list_add(&bs->rescue_list, bio); 1012 + queue_work(bs->rescue_workqueue, &bs->rescue_work); 1013 + spin_unlock(&bs->rescue_lock); 1006 1014 } 1007 - 1008 - spin_lock(&bs->rescue_lock); 1009 - bio_list_add(&bs->rescue_list, bio); 1010 - queue_work(bs->rescue_workqueue, &bs->rescue_work); 1011 - spin_unlock(&bs->rescue_lock); 1012 1015 } 1013 1016 } 1014 1017
+2 -1
drivers/md/raid10.c
··· 974 974 !conf->barrier || 975 975 (atomic_read(&conf->nr_pending) && 976 976 current->bio_list && 977 - !bio_list_empty(current->bio_list)), 977 + (!bio_list_empty(&current->bio_list[0]) || 978 + !bio_list_empty(&current->bio_list[1]))), 978 979 conf->resync_lock); 979 980 conf->nr_waiting--; 980 981 if (!conf->nr_waiting)
+2 -8
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
··· 2272 2272 processed = xgbe_rx_poll(channel, budget); 2273 2273 2274 2274 /* If we processed everything, we are done */ 2275 - if (processed < budget) { 2276 - /* Turn off polling */ 2277 - napi_complete_done(napi, processed); 2278 - 2275 + if ((processed < budget) && napi_complete_done(napi, processed)) { 2279 2276 /* Enable Tx and Rx interrupts */ 2280 2277 if (pdata->channel_irq_mode) 2281 2278 xgbe_enable_rx_tx_int(pdata, channel); ··· 2314 2317 } while ((processed < budget) && (processed != last_processed)); 2315 2318 2316 2319 /* If we processed everything, we are done */ 2317 - if (processed < budget) { 2318 - /* Turn off polling */ 2319 - napi_complete_done(napi, processed); 2320 - 2320 + if ((processed < budget) && napi_complete_done(napi, processed)) { 2321 2321 /* Enable Tx and Rx interrupts */ 2322 2322 xgbe_enable_rx_tx_ints(pdata); 2323 2323 }
+1 -1
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
··· 213 213 if (!((1U << i) & self->msix_entry_mask)) 214 214 continue; 215 215 216 - free_irq(pci_irq_vector(pdev, i), self->aq_vec[i]); 217 216 if (pdev->msix_enabled) 218 217 irq_set_affinity_hint(pci_irq_vector(pdev, i), NULL); 218 + free_irq(pci_irq_vector(pdev, i), self->aq_vec[i]); 219 219 self->msix_entry_mask &= ~(1U << i); 220 220 } 221 221 }
+30 -6
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 13292 13292 dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 13293 13293 NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_HIGHDMA; 13294 13294 13295 - /* VF with OLD Hypervisor or old PF do not support filtering */ 13296 13295 if (IS_PF(bp)) { 13297 13296 if (chip_is_e1x) 13298 13297 bp->accept_any_vlan = true; 13299 13298 else 13300 13299 dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; 13301 - #ifdef CONFIG_BNX2X_SRIOV 13302 - } else if (bp->acquire_resp.pfdev_info.pf_cap & PFVF_CAP_VLAN_FILTER) { 13303 - dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; 13304 - #endif 13305 13300 } 13301 + /* For VF we'll know whether to enable VLAN filtering after 13302 + * getting a response to CHANNEL_TLV_ACQUIRE from PF. 13303 + */ 13306 13304 13307 13305 dev->features |= dev->hw_features | NETIF_F_HW_VLAN_CTAG_RX; 13308 13306 dev->features |= NETIF_F_HIGHDMA; ··· 13736 13738 if (!netif_running(bp->dev)) { 13737 13739 DP(BNX2X_MSG_PTP, 13738 13740 "PTP adjfreq called while the interface is down\n"); 13739 - return -EFAULT; 13741 + return -ENETDOWN; 13740 13742 } 13741 13743 13742 13744 if (ppb < 0) { ··· 13795 13797 { 13796 13798 struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info); 13797 13799 13800 + if (!netif_running(bp->dev)) { 13801 + DP(BNX2X_MSG_PTP, 13802 + "PTP adjtime called while the interface is down\n"); 13803 + return -ENETDOWN; 13804 + } 13805 + 13798 13806 DP(BNX2X_MSG_PTP, "PTP adjtime called, delta = %llx\n", delta); 13799 13807 13800 13808 timecounter_adjtime(&bp->timecounter, delta); ··· 13812 13808 { 13813 13809 struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info); 13814 13810 u64 ns; 13811 + 13812 + if (!netif_running(bp->dev)) { 13813 + DP(BNX2X_MSG_PTP, 13814 + "PTP gettime called while the interface is down\n"); 13815 + return -ENETDOWN; 13816 + } 13815 13817 13816 13818 ns = timecounter_read(&bp->timecounter); 13817 13819 ··· 13833 13823 { 13834 13824 struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info); 13835 13825 u64 ns; 13826 + 13827 + if (!netif_running(bp->dev)) { 13828 + DP(BNX2X_MSG_PTP, 13829 + "PTP settime called while the interface is down\n"); 13830 + return -ENETDOWN; 13831 + } 13836 13832 13837 13833 ns = timespec64_to_ns(ts); 13838 13834 ··· 14007 13991 rc = bnx2x_vfpf_acquire(bp, tx_count, rx_count); 14008 13992 if (rc) 14009 13993 goto init_one_freemem; 13994 + 13995 + #ifdef CONFIG_BNX2X_SRIOV 13996 + /* VF with OLD Hypervisor or old PF do not support filtering */ 13997 + if (bp->acquire_resp.pfdev_info.pf_cap & PFVF_CAP_VLAN_FILTER) { 13998 + dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; 13999 + dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 14000 + } 14001 + #endif 14010 14002 } 14011 14003 14012 14004 /* Enable SRIOV if capability found in configuration space */
+16 -8
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
··· 434 434 435 435 /* Add/Remove the filter */ 436 436 rc = bnx2x_config_vlan_mac(bp, &ramrod); 437 - if (rc && rc != -EEXIST) { 437 + if (rc == -EEXIST) 438 + return 0; 439 + if (rc) { 438 440 BNX2X_ERR("Failed to %s %s\n", 439 441 filter->add ? "add" : "delete", 440 442 (filter->type == BNX2X_VF_FILTER_VLAN_MAC) ? ··· 445 443 "MAC" : "VLAN"); 446 444 return rc; 447 445 } 446 + 447 + filter->applied = true; 448 448 449 449 return 0; 450 450 } ··· 473 469 /* Rollback if needed */ 474 470 if (i != filters->count) { 475 471 BNX2X_ERR("Managed only %d/%d filters - rolling back\n", 476 - i, filters->count + 1); 472 + i, filters->count); 477 473 while (--i >= 0) { 474 + if (!filters->filters[i].applied) 475 + continue; 478 476 filters->filters[i].add = !filters->filters[i].add; 479 477 bnx2x_vf_mac_vlan_config(bp, vf, qid, 480 478 &filters->filters[i], ··· 1905 1899 continue; 1906 1900 } 1907 1901 1908 - DP(BNX2X_MSG_IOV, "add addresses for vf %d\n", vf->abs_vfid); 1902 + DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS), 1903 + "add addresses for vf %d\n", vf->abs_vfid); 1909 1904 for_each_vfq(vf, j) { 1910 1905 struct bnx2x_vf_queue *rxq = vfq_get(vf, j); 1911 1906 ··· 1927 1920 cpu_to_le32(U64_HI(q_stats_addr)); 1928 1921 cur_query_entry->address.lo = 1929 1922 cpu_to_le32(U64_LO(q_stats_addr)); 1930 - DP(BNX2X_MSG_IOV, 1931 - "added address %x %x for vf %d queue %d client %d\n", 1932 - cur_query_entry->address.hi, 1933 - cur_query_entry->address.lo, cur_query_entry->funcID, 1934 - j, cur_query_entry->index); 1923 + DP_AND((BNX2X_MSG_IOV | BNX2X_MSG_STATS), 1924 + "added address %x %x for vf %d queue %d client %d\n", 1925 + cur_query_entry->address.hi, 1926 + cur_query_entry->address.lo, 1927 + cur_query_entry->funcID, 1928 + j, cur_query_entry->index); 1935 1929 cur_query_entry++; 1936 1930 cur_data_offset += sizeof(struct per_queue_stats); 1937 1931 stats_count++;
+1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
··· 114 114 (BNX2X_VF_FILTER_MAC | BNX2X_VF_FILTER_VLAN) /*shortcut*/ 115 115 116 116 bool add; 117 + bool applied; 117 118 u8 *mac; 118 119 u16 vid; 119 120 };
+28 -12
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
··· 868 868 struct bnx2x *bp = netdev_priv(dev); 869 869 struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters; 870 870 struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp; 871 - int rc, i = 0; 871 + int rc = 0, i = 0; 872 872 struct netdev_hw_addr *ha; 873 873 874 874 if (bp->state != BNX2X_STATE_OPEN) { ··· 883 883 /* Get Rx mode requested */ 884 884 DP(NETIF_MSG_IFUP, "dev->flags = %x\n", dev->flags); 885 885 886 + /* We support PFVF_MAX_MULTICAST_PER_VF mcast addresses tops */ 887 + if (netdev_mc_count(dev) > PFVF_MAX_MULTICAST_PER_VF) { 888 + DP(NETIF_MSG_IFUP, 889 + "VF supports not more than %d multicast MAC addresses\n", 890 + PFVF_MAX_MULTICAST_PER_VF); 891 + rc = -EINVAL; 892 + goto out; 893 + } 894 + 886 895 netdev_for_each_mc_addr(ha, dev) { 887 896 DP(NETIF_MSG_IFUP, "Adding mcast MAC: %pM\n", 888 897 bnx2x_mc_addr(ha)); 889 898 memcpy(req->multicast[i], bnx2x_mc_addr(ha), ETH_ALEN); 890 899 i++; 891 - } 892 - 893 - /* We support four PFVF_MAX_MULTICAST_PER_VF mcast 894 - * addresses tops 895 - */ 896 - if (i >= PFVF_MAX_MULTICAST_PER_VF) { 897 - DP(NETIF_MSG_IFUP, 898 - "VF supports not more than %d multicast MAC addresses\n", 899 - PFVF_MAX_MULTICAST_PER_VF); 900 - return -EINVAL; 901 900 } 902 901 903 902 req->n_multicast = i; ··· 923 924 out: 924 925 bnx2x_vfpf_finalize(bp, &req->first_tlv); 925 926 926 - return 0; 927 + return rc; 927 928 } 928 929 929 930 /* request pf to add a vlan for the vf */ ··· 1770 1771 1771 1772 if (fl) { 1772 1773 /* set mac list */ 1774 + rc = bnx2x_vf_mac_vlan_config_list(bp, vf, fl, 1775 + msg->vf_qid, 1776 + false); 1777 + if (rc) 1778 + goto op_err; 1779 + } 1780 + 1781 + /* build vlan list */ 1782 + fl = NULL; 1783 + 1784 + rc = bnx2x_vf_mbx_macvlan_list(bp, vf, msg, &fl, 1785 + VFPF_VLAN_FILTER); 1786 + if (rc) 1787 + goto op_err; 1788 + 1789 + if (fl) { 1790 + /* set vlan list */ 1773 1791 rc = bnx2x_vf_mac_vlan_config_list(bp, vf, fl, 1774 1792 msg->vf_qid, 1775 1793 false);
+18 -7
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 4465 4465 vf->vlan = le16_to_cpu(resp->vlan) & VLAN_VID_MASK; 4466 4466 } 4467 4467 #endif 4468 + if (BNXT_PF(bp) && (le16_to_cpu(resp->flags) & 4469 + FUNC_QCFG_RESP_FLAGS_FW_DCBX_AGENT_ENABLED)) 4470 + bp->flags |= BNXT_FLAG_FW_LLDP_AGENT; 4471 + 4468 4472 switch (resp->port_partition_type) { 4469 4473 case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_0: 4470 4474 case FUNC_QCFG_RESP_PORT_PARTITION_TYPE_NPAR1_5: ··· 5511 5507 bp->lpi_tmr_hi = le32_to_cpu(resp->valid_tx_lpi_timer_high) & 5512 5508 PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_MASK; 5513 5509 } 5514 - link_info->support_auto_speeds = 5515 - le16_to_cpu(resp->supported_speeds_auto_mode); 5510 + if (resp->supported_speeds_auto_mode) 5511 + link_info->support_auto_speeds = 5512 + le16_to_cpu(resp->supported_speeds_auto_mode); 5516 5513 5517 5514 hwrm_phy_qcaps_exit: 5518 5515 mutex_unlock(&bp->hwrm_cmd_lock); ··· 6500 6495 if (!silent) 6501 6496 bnxt_dbg_dump_states(bp); 6502 6497 if (netif_running(bp->dev)) { 6498 + int rc; 6499 + 6500 + if (!silent) 6501 + bnxt_ulp_stop(bp); 6503 6502 bnxt_close_nic(bp, false, false); 6504 - bnxt_open_nic(bp, false, false); 6503 + rc = bnxt_open_nic(bp, false, false); 6504 + if (!silent && !rc) 6505 + bnxt_ulp_start(bp); 6505 6506 } 6506 6507 } 6507 6508 ··· 7455 7444 if (rc) 7456 7445 goto init_err_pci_clean; 7457 7446 7447 + rc = bnxt_hwrm_func_reset(bp); 7448 + if (rc) 7449 + goto init_err_pci_clean; 7450 + 7458 7451 bnxt_hwrm_fw_set_time(bp); 7459 7452 7460 7453 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG | ··· 7566 7551 bp->flags |= BNXT_FLAG_STRIP_VLAN; 7567 7552 7568 7553 rc = bnxt_probe_phy(bp); 7569 - if (rc) 7570 - goto init_err_pci_clean; 7571 - 7572 - rc = bnxt_hwrm_func_reset(bp); 7573 7554 if (rc) 7574 7555 goto init_err_pci_clean; 7575 7556
+1
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 993 993 BNXT_FLAG_ROCEV2_CAP) 994 994 #define BNXT_FLAG_NO_AGG_RINGS 0x20000 995 995 #define BNXT_FLAG_RX_PAGE_MODE 0x40000 996 + #define BNXT_FLAG_FW_LLDP_AGENT 0x80000 996 997 #define BNXT_FLAG_CHIP_NITRO_A0 0x1000000 997 998 998 999 #define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
+1 -1
drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c
··· 474 474 return; 475 475 476 476 bp->dcbx_cap = DCB_CAP_DCBX_VER_IEEE; 477 - if (BNXT_PF(bp)) 477 + if (BNXT_PF(bp) && !(bp->flags & BNXT_FLAG_FW_LLDP_AGENT)) 478 478 bp->dcbx_cap |= DCB_CAP_DCBX_HOST; 479 479 else 480 480 bp->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED;
+147 -59
drivers/net/ethernet/broadcom/genet/bcmgenet.c
··· 1 1 /* 2 2 * Broadcom GENET (Gigabit Ethernet) controller driver 3 3 * 4 - * Copyright (c) 2014 Broadcom Corporation 4 + * Copyright (c) 2014-2017 Broadcom 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify 7 7 * it under the terms of the GNU General Public License version 2 as ··· 450 450 genet_dma_ring_regs[r]); 451 451 } 452 452 453 + static int bcmgenet_begin(struct net_device *dev) 454 + { 455 + struct bcmgenet_priv *priv = netdev_priv(dev); 456 + 457 + /* Turn on the clock */ 458 + return clk_prepare_enable(priv->clk); 459 + } 460 + 461 + static void bcmgenet_complete(struct net_device *dev) 462 + { 463 + struct bcmgenet_priv *priv = netdev_priv(dev); 464 + 465 + /* Turn off the clock */ 466 + clk_disable_unprepare(priv->clk); 467 + } 468 + 453 469 static int bcmgenet_get_link_ksettings(struct net_device *dev, 454 470 struct ethtool_link_ksettings *cmd) 455 471 { ··· 794 778 STAT_GENET_RUNT("rx_runt_bytes", mib.rx_runt_bytes), 795 779 /* Misc UniMAC counters */ 796 780 STAT_GENET_MISC("rbuf_ovflow_cnt", mib.rbuf_ovflow_cnt, 797 - UMAC_RBUF_OVFL_CNT), 798 - STAT_GENET_MISC("rbuf_err_cnt", mib.rbuf_err_cnt, UMAC_RBUF_ERR_CNT), 781 + UMAC_RBUF_OVFL_CNT_V1), 782 + STAT_GENET_MISC("rbuf_err_cnt", mib.rbuf_err_cnt, 783 + UMAC_RBUF_ERR_CNT_V1), 799 784 STAT_GENET_MISC("mdf_err_cnt", mib.mdf_err_cnt, UMAC_MDF_ERR_CNT), 800 785 STAT_GENET_SOFT_MIB("alloc_rx_buff_failed", mib.alloc_rx_buff_failed), 801 786 STAT_GENET_SOFT_MIB("rx_dma_failed", mib.rx_dma_failed), ··· 838 821 } 839 822 } 840 823 824 + static u32 bcmgenet_update_stat_misc(struct bcmgenet_priv *priv, u16 offset) 825 + { 826 + u16 new_offset; 827 + u32 val; 828 + 829 + switch (offset) { 830 + case UMAC_RBUF_OVFL_CNT_V1: 831 + if (GENET_IS_V2(priv)) 832 + new_offset = RBUF_OVFL_CNT_V2; 833 + else 834 + new_offset = RBUF_OVFL_CNT_V3PLUS; 835 + 836 + val = bcmgenet_rbuf_readl(priv, new_offset); 837 + /* clear if overflowed */ 838 + if (val == ~0) 839 + bcmgenet_rbuf_writel(priv, 0, new_offset); 840 + break; 841 + case UMAC_RBUF_ERR_CNT_V1: 842 + if (GENET_IS_V2(priv)) 843 + new_offset = RBUF_ERR_CNT_V2; 844 + else 845 + new_offset = RBUF_ERR_CNT_V3PLUS; 846 + 847 + val = bcmgenet_rbuf_readl(priv, new_offset); 848 + /* clear if overflowed */ 849 + if (val == ~0) 850 + bcmgenet_rbuf_writel(priv, 0, new_offset); 851 + break; 852 + default: 853 + val = bcmgenet_umac_readl(priv, offset); 854 + /* clear if overflowed */ 855 + if (val == ~0) 856 + bcmgenet_umac_writel(priv, 0, offset); 857 + break; 858 + } 859 + 860 + return val; 861 + } 862 + 841 863 static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv) 842 864 { 843 865 int i, j = 0; ··· 892 836 case BCMGENET_STAT_NETDEV: 893 837 case BCMGENET_STAT_SOFT: 894 838 continue; 895 - case BCMGENET_STAT_MIB_RX: 896 - case BCMGENET_STAT_MIB_TX: 897 839 case BCMGENET_STAT_RUNT: 898 - if (s->type != BCMGENET_STAT_MIB_RX) 899 - offset = BCMGENET_STAT_OFFSET; 840 + offset += BCMGENET_STAT_OFFSET; 841 + /* fall through */ 842 + case BCMGENET_STAT_MIB_TX: 843 + offset += BCMGENET_STAT_OFFSET; 844 + /* fall through */ 845 + case BCMGENET_STAT_MIB_RX: 900 846 val = bcmgenet_umac_readl(priv, 901 847 UMAC_MIB_START + j + offset); 848 + offset = 0; /* Reset Offset */ 902 849 break; 903 850 case BCMGENET_STAT_MISC: 904 - val = bcmgenet_umac_readl(priv, s->reg_offset); 905 - /* clear if overflowed */ 906 - if (val == ~0) 907 - bcmgenet_umac_writel(priv, 0, s->reg_offset); 851 + if (GENET_IS_V1(priv)) { 852 + val = bcmgenet_umac_readl(priv, s->reg_offset); 853 + /* clear if overflowed */ 854 + if (val == ~0) 855 + bcmgenet_umac_writel(priv, 0, 856 + s->reg_offset); 857 + } else { 858 + val = bcmgenet_update_stat_misc(priv, 859 + s->reg_offset); 860 + } 908 861 break; 909 862 } 910 863 ··· 1038 973 1039 974 /* standard ethtool support functions. */ 1040 975 static const struct ethtool_ops bcmgenet_ethtool_ops = { 976 + .begin = bcmgenet_begin, 977 + .complete = bcmgenet_complete, 1041 978 .get_strings = bcmgenet_get_strings, 1042 979 .get_sset_count = bcmgenet_get_sset_count, 1043 980 .get_ethtool_stats = bcmgenet_get_ethtool_stats, ··· 1234 1167 struct bcmgenet_priv *priv = netdev_priv(dev); 1235 1168 struct device *kdev = &priv->pdev->dev; 1236 1169 struct enet_cb *tx_cb_ptr; 1237 - struct netdev_queue *txq; 1238 1170 unsigned int pkts_compl = 0; 1239 1171 unsigned int bytes_compl = 0; 1240 1172 unsigned int c_index; ··· 1285 1219 dev->stats.tx_packets += pkts_compl; 1286 1220 dev->stats.tx_bytes += bytes_compl; 1287 1221 1288 - txq = netdev_get_tx_queue(dev, ring->queue); 1289 - netdev_tx_completed_queue(txq, pkts_compl, bytes_compl); 1290 - 1291 - if (ring->free_bds > (MAX_SKB_FRAGS + 1)) { 1292 - if (netif_tx_queue_stopped(txq)) 1293 - netif_tx_wake_queue(txq); 1294 - } 1222 + netdev_tx_completed_queue(netdev_get_tx_queue(dev, ring->queue), 1223 + pkts_compl, bytes_compl); 1295 1224 1296 1225 return pkts_compl; 1297 1226 } ··· 1309 1248 struct bcmgenet_tx_ring *ring = 1310 1249 container_of(napi, struct bcmgenet_tx_ring, napi); 1311 1250 unsigned int work_done = 0; 1251 + struct netdev_queue *txq; 1252 + unsigned long flags; 1312 1253 1313 - work_done = bcmgenet_tx_reclaim(ring->priv->dev, ring); 1254 + spin_lock_irqsave(&ring->lock, flags); 1255 + work_done = __bcmgenet_tx_reclaim(ring->priv->dev, ring); 1256 + if (ring->free_bds > (MAX_SKB_FRAGS + 1)) { 1257 + txq = netdev_get_tx_queue(ring->priv->dev, ring->queue); 1258 + netif_tx_wake_queue(txq); 1259 + } 1260 + spin_unlock_irqrestore(&ring->lock, flags); 1314 1261 1315 1262 if (work_done == 0) { 1316 1263 napi_complete(napi); ··· 2526 2457 /* Interrupt bottom half */ 2527 2458 static void bcmgenet_irq_task(struct work_struct *work) 2528 2459 { 2460 + unsigned long flags; 2461 + unsigned int status; 2529 2462 struct bcmgenet_priv *priv = container_of( 2530 2463 work, struct bcmgenet_priv, bcmgenet_irq_work); 2531 2464 2532 2465 netif_dbg(priv, intr, priv->dev, "%s\n", __func__); 2533 2466 2534 - if (priv->irq0_stat & UMAC_IRQ_MPD_R) { 2535 - priv->irq0_stat &= ~UMAC_IRQ_MPD_R; 2467 + spin_lock_irqsave(&priv->lock, flags); 2468 + status = priv->irq0_stat; 2469 + priv->irq0_stat = 0; 2470 + spin_unlock_irqrestore(&priv->lock, flags); 2471 + 2472 + if (status & UMAC_IRQ_MPD_R) { 2536 2473 netif_dbg(priv, wol, priv->dev, 2537 2474 "magic packet detected, waking up\n"); 2538 2475 bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC); 2539 2476 } 2540 2477 2541 2478 /* Link UP/DOWN event */ 2542 - if (priv->irq0_stat & UMAC_IRQ_LINK_EVENT) { 2479 + if (status & UMAC_IRQ_LINK_EVENT) 2543 2480 phy_mac_interrupt(priv->phydev, 2544 - !!(priv->irq0_stat & UMAC_IRQ_LINK_UP)); 2545 - priv->irq0_stat &= ~UMAC_IRQ_LINK_EVENT; 2546 - } 2481 + !!(status & UMAC_IRQ_LINK_UP)); 2547 2482 } 2548 2483 2549 2484 /* bcmgenet_isr1: handle Rx and Tx priority queues */ ··· 2556 2483 struct bcmgenet_priv *priv = dev_id; 2557 2484 struct bcmgenet_rx_ring *rx_ring; 2558 2485 struct bcmgenet_tx_ring *tx_ring; 2559 - unsigned int index; 2486 + unsigned int index, status; 2560 2487 2561 - /* Save irq status for bottom-half processing. */ 2562 - priv->irq1_stat = 2563 - bcmgenet_intrl2_1_readl(priv, INTRL2_CPU_STAT) & 2488 + /* Read irq status */ 2489 + status = bcmgenet_intrl2_1_readl(priv, INTRL2_CPU_STAT) & 2564 2490 ~bcmgenet_intrl2_1_readl(priv, INTRL2_CPU_MASK_STATUS); 2565 2491 2566 2492 /* clear interrupts */ 2567 - bcmgenet_intrl2_1_writel(priv, priv->irq1_stat, INTRL2_CPU_CLEAR); 2493 + bcmgenet_intrl2_1_writel(priv, status, INTRL2_CPU_CLEAR); 2568 2494 2569 2495 netif_dbg(priv, intr, priv->dev, 2570 - "%s: IRQ=0x%x\n", __func__, priv->irq1_stat); 2496 + "%s: IRQ=0x%x\n", __func__, status); 2571 2497 2572 2498 /* Check Rx priority queue interrupts */ 2573 2499 for (index = 0; index < priv->hw_params->rx_queues; index++) { 2574 - if (!(priv->irq1_stat & BIT(UMAC_IRQ1_RX_INTR_SHIFT + index))) 2500 + if (!(status & BIT(UMAC_IRQ1_RX_INTR_SHIFT + index))) 2575 2501 continue; 2576 2502 2577 2503 rx_ring = &priv->rx_rings[index]; ··· 2583 2511 2584 2512 /* Check Tx priority queue interrupts */ 2585 2513 for (index = 0; index < priv->hw_params->tx_queues; index++) { 2586 - if (!(priv->irq1_stat & BIT(index))) 2514 + if (!(status & BIT(index))) 2587 2515 continue; 2588 2516 2589 2517 tx_ring = &priv->tx_rings[index]; ··· 2603 2531 struct bcmgenet_priv *priv = dev_id; 2604 2532 struct bcmgenet_rx_ring *rx_ring; 2605 2533 struct bcmgenet_tx_ring *tx_ring; 2534 + unsigned int status; 2535 + unsigned long flags; 2606 2536 2607 - /* Save irq status for bottom-half processing. */ 2608 - priv->irq0_stat = 2609 - bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_STAT) & 2537 + /* Read irq status */ 2538 + status = bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_STAT) & 2610 2539 ~bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_MASK_STATUS); 2611 2540 2612 2541 /* clear interrupts */ 2613 - bcmgenet_intrl2_0_writel(priv, priv->irq0_stat, INTRL2_CPU_CLEAR); 2542 + bcmgenet_intrl2_0_writel(priv, status, INTRL2_CPU_CLEAR); 2614 2543 2615 2544 netif_dbg(priv, intr, priv->dev, 2616 - "IRQ=0x%x\n", priv->irq0_stat); 2545 + "IRQ=0x%x\n", status); 2617 2546 2618 - if (priv->irq0_stat & UMAC_IRQ_RXDMA_DONE) { 2547 + if (status & UMAC_IRQ_RXDMA_DONE) { 2619 2548 rx_ring = &priv->rx_rings[DESC_INDEX]; 2620 2549 2621 2550 if (likely(napi_schedule_prep(&rx_ring->napi))) { ··· 2625 2552 } 2626 2553 } 2627 2554 2628 - if (priv->irq0_stat & UMAC_IRQ_TXDMA_DONE) { 2555 + if (status & UMAC_IRQ_TXDMA_DONE) { 2629 2556 tx_ring = &priv->tx_rings[DESC_INDEX]; 2630 2557 2631 2558 if (likely(napi_schedule_prep(&tx_ring->napi))) { ··· 2634 2561 } 2635 2562 } 2636 2563 2637 - if (priv->irq0_stat & (UMAC_IRQ_PHY_DET_R | 2638 - UMAC_IRQ_PHY_DET_F | 2639 - UMAC_IRQ_LINK_EVENT | 2640 - UMAC_IRQ_HFB_SM | 2641 - UMAC_IRQ_HFB_MM | 2642 - UMAC_IRQ_MPD_R)) { 2643 - /* all other interested interrupts handled in bottom half */ 2644 - schedule_work(&priv->bcmgenet_irq_work); 2564 + if ((priv->hw_params->flags & GENET_HAS_MDIO_INTR) && 2565 + status & (UMAC_IRQ_MDIO_DONE | UMAC_IRQ_MDIO_ERROR)) { 2566 + wake_up(&priv->wq); 2645 2567 } 2646 2568 2647 - if ((priv->hw_params->flags & GENET_HAS_MDIO_INTR) && 2648 - priv->irq0_stat & (UMAC_IRQ_MDIO_DONE | UMAC_IRQ_MDIO_ERROR)) { 2649 - priv->irq0_stat &= ~(UMAC_IRQ_MDIO_DONE | UMAC_IRQ_MDIO_ERROR); 2650 - wake_up(&priv->wq); 2569 + /* all other interested interrupts handled in bottom half */ 2570 + status &= (UMAC_IRQ_LINK_EVENT | 2571 + UMAC_IRQ_MPD_R); 2572 + if (status) { 2573 + /* Save irq status for bottom-half processing. */ 2574 + spin_lock_irqsave(&priv->lock, flags); 2575 + priv->irq0_stat |= status; 2576 + spin_unlock_irqrestore(&priv->lock, flags); 2577 + 2578 + schedule_work(&priv->bcmgenet_irq_work); 2651 2579 } 2652 2580 2653 2581 return IRQ_HANDLED; ··· 2875 2801 err_fini_dma: 2876 2802 bcmgenet_fini_dma(priv); 2877 2803 err_clk_disable: 2804 + if (priv->internal_phy) 2805 + bcmgenet_power_down(priv, GENET_POWER_PASSIVE); 2878 2806 clk_disable_unprepare(priv->clk); 2879 2807 return ret; 2880 2808 } ··· 3253 3177 */ 3254 3178 gphy_rev = reg & 0xffff; 3255 3179 3180 + /* This is reserved so should require special treatment */ 3181 + if (gphy_rev == 0 || gphy_rev == 0x01ff) { 3182 + pr_warn("Invalid GPHY revision detected: 0x%04x\n", gphy_rev); 3183 + return; 3184 + } 3185 + 3256 3186 /* This is the good old scheme, just GPHY major, no minor nor patch */ 3257 3187 if ((gphy_rev & 0xf0) != 0) 3258 3188 priv->gphy_rev = gphy_rev << 8; ··· 3266 3184 /* This is the new scheme, GPHY major rolls over with 0x10 = rev G0 */ 3267 3185 else if ((gphy_rev & 0xff00) != 0) 3268 3186 priv->gphy_rev = gphy_rev; 3269 - 3270 - /* This is reserved so should require special treatment */ 3271 - else if (gphy_rev == 0 || gphy_rev == 0x01ff) { 3272 - pr_warn("Invalid GPHY revision detected: 0x%04x\n", gphy_rev); 3273 - return; 3274 - } 3275 3187 3276 3188 #ifdef CONFIG_PHYS_ADDR_T_64BIT 3277 3189 if (!(params->flags & GENET_HAS_40BITS)) ··· 3309 3233 const void *macaddr; 3310 3234 struct resource *r; 3311 3235 int err = -EIO; 3236 + const char *phy_mode_str; 3312 3237 3313 3238 /* Up to GENET_MAX_MQ_CNT + 1 TX queues and RX queues */ 3314 3239 dev = alloc_etherdev_mqs(sizeof(*priv), GENET_MAX_MQ_CNT + 1, ··· 3352 3275 err = PTR_ERR(priv->base); 3353 3276 goto err; 3354 3277 } 3278 + 3279 + spin_lock_init(&priv->lock); 3355 3280 3356 3281 SET_NETDEV_DEV(dev, &pdev->dev); 3357 3282 dev_set_drvdata(&pdev->dev, dev); ··· 3416 3337 dev_warn(&priv->pdev->dev, "failed to get enet-eee clock\n"); 3417 3338 priv->clk_eee = NULL; 3418 3339 } 3340 + 3341 + /* If this is an internal GPHY, power it on now, before UniMAC is 3342 + * brought out of reset as absolutely no UniMAC activity is allowed 3343 + */ 3344 + if (dn && !of_property_read_string(dn, "phy-mode", &phy_mode_str) && 3345 + !strcasecmp(phy_mode_str, "internal")) 3346 + bcmgenet_power_up(priv, GENET_POWER_PASSIVE); 3419 3347 3420 3348 err = reset_umac(priv); 3421 3349 if (err) ··· 3588 3502 return 0; 3589 3503 3590 3504 out_clk_disable: 3505 + if (priv->internal_phy) 3506 + bcmgenet_power_down(priv, GENET_POWER_PASSIVE); 3591 3507 clk_disable_unprepare(priv->clk); 3592 3508 return ret; 3593 3509 }
+11 -5
drivers/net/ethernet/broadcom/genet/bcmgenet.h
··· 1 1 /* 2 - * Copyright (c) 2014 Broadcom Corporation 2 + * Copyright (c) 2014-2017 Broadcom 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License version 2 as ··· 214 214 #define MDIO_REG_SHIFT 16 215 215 #define MDIO_REG_MASK 0x1F 216 216 217 - #define UMAC_RBUF_OVFL_CNT 0x61C 217 + #define UMAC_RBUF_OVFL_CNT_V1 0x61C 218 + #define RBUF_OVFL_CNT_V2 0x80 219 + #define RBUF_OVFL_CNT_V3PLUS 0x94 218 220 219 221 #define UMAC_MPD_CTRL 0x620 220 222 #define MPD_EN (1 << 0) ··· 226 224 227 225 #define UMAC_MPD_PW_MS 0x624 228 226 #define UMAC_MPD_PW_LS 0x628 229 - #define UMAC_RBUF_ERR_CNT 0x634 227 + #define UMAC_RBUF_ERR_CNT_V1 0x634 228 + #define RBUF_ERR_CNT_V2 0x84 229 + #define RBUF_ERR_CNT_V3PLUS 0x98 230 230 #define UMAC_MDF_ERR_CNT 0x638 231 231 #define UMAC_MDF_CTRL 0x650 232 232 #define UMAC_MDF_ADDR 0x654 ··· 623 619 struct work_struct bcmgenet_irq_work; 624 620 int irq0; 625 621 int irq1; 626 - unsigned int irq0_stat; 627 - unsigned int irq1_stat; 628 622 int wol_irq; 629 623 bool wol_irq_disabled; 624 + 625 + /* shared status */ 626 + spinlock_t lock; 627 + unsigned int irq0_stat; 630 628 631 629 /* HW descriptors/checksum variables */ 632 630 bool desc_64b_en;
+55 -55
drivers/net/ethernet/cavium/liquidio/lio_main.c
··· 152 152 */ 153 153 struct octeon_sg_entry *sg; 154 154 155 - u64 sg_dma_ptr; 155 + dma_addr_t sg_dma_ptr; 156 156 }; 157 157 158 158 struct handshake { ··· 734 734 struct octnic_gather *g; 735 735 int i; 736 736 737 + kfree(lio->glist_lock); 738 + lio->glist_lock = NULL; 739 + 737 740 if (!lio->glist) 738 741 return; 739 742 ··· 744 741 do { 745 742 g = (struct octnic_gather *) 746 743 list_delete_head(&lio->glist[i]); 747 - if (g) { 748 - if (g->sg) { 749 - dma_unmap_single(&lio->oct_dev-> 750 - pci_dev->dev, 751 - g->sg_dma_ptr, 752 - g->sg_size, 753 - DMA_TO_DEVICE); 754 - kfree((void *)((unsigned long)g->sg - 755 - g->adjust)); 756 - } 744 + if (g) 757 745 kfree(g); 758 - } 759 746 } while (g); 747 + 748 + if (lio->glists_virt_base && lio->glists_virt_base[i]) { 749 + lio_dma_free(lio->oct_dev, 750 + lio->glist_entry_size * lio->tx_qsize, 751 + lio->glists_virt_base[i], 752 + lio->glists_dma_base[i]); 753 + } 760 754 } 761 755 762 - kfree((void *)lio->glist); 763 - kfree((void *)lio->glist_lock); 756 + kfree(lio->glists_virt_base); 757 + lio->glists_virt_base = NULL; 758 + 759 + kfree(lio->glists_dma_base); 760 + lio->glists_dma_base = NULL; 761 + 762 + kfree(lio->glist); 763 + lio->glist = NULL; 764 764 } 765 765 766 766 /** ··· 778 772 lio->glist_lock = kcalloc(num_iqs, sizeof(*lio->glist_lock), 779 773 GFP_KERNEL); 780 774 if (!lio->glist_lock) 781 - return 1; 775 + return -ENOMEM; 782 776 783 777 lio->glist = kcalloc(num_iqs, sizeof(*lio->glist), 784 778 GFP_KERNEL); 785 779 if (!lio->glist) { 786 - kfree((void *)lio->glist_lock); 787 - return 1; 780 + kfree(lio->glist_lock); 781 + lio->glist_lock = NULL; 782 + return -ENOMEM; 783 + } 784 + 785 + lio->glist_entry_size = 786 + ROUNDUP8((ROUNDUP4(OCTNIC_MAX_SG) >> 2) * OCT_SG_ENTRY_SIZE); 787 + 788 + /* allocate memory to store virtual and dma base address of 789 + * per glist consistent memory 790 + */ 791 + lio->glists_virt_base = kcalloc(num_iqs, sizeof(*lio->glists_virt_base), 792 + GFP_KERNEL); 793 + lio->glists_dma_base = kcalloc(num_iqs, sizeof(*lio->glists_dma_base), 794 + GFP_KERNEL); 795 + 796 + if (!lio->glists_virt_base || !lio->glists_dma_base) { 797 + delete_glists(lio); 798 + return -ENOMEM; 788 799 } 789 800 790 801 for (i = 0; i < num_iqs; i++) { ··· 811 788 812 789 INIT_LIST_HEAD(&lio->glist[i]); 813 790 791 + lio->glists_virt_base[i] = 792 + lio_dma_alloc(oct, 793 + lio->glist_entry_size * lio->tx_qsize, 794 + &lio->glists_dma_base[i]); 795 + 796 + if (!lio->glists_virt_base[i]) { 797 + delete_glists(lio); 798 + return -ENOMEM; 799 + } 800 + 814 801 for (j = 0; j < lio->tx_qsize; j++) { 815 802 g = kzalloc_node(sizeof(*g), GFP_KERNEL, 816 803 numa_node); ··· 829 796 if (!g) 830 797 break; 831 798 832 - g->sg_size = ((ROUNDUP4(OCTNIC_MAX_SG) >> 2) * 833 - OCT_SG_ENTRY_SIZE); 799 + g->sg = lio->glists_virt_base[i] + 800 + (j * lio->glist_entry_size); 834 801 835 - g->sg = kmalloc_node(g->sg_size + 8, 836 - GFP_KERNEL, numa_node); 837 - if (!g->sg) 838 - g->sg = kmalloc(g->sg_size + 8, GFP_KERNEL); 839 - if (!g->sg) { 840 - kfree(g); 841 - break; 842 - } 843 - 844 - /* The gather component should be aligned on 64-bit 845 - * boundary 846 - */ 847 - if (((unsigned long)g->sg) & 7) { 848 - g->adjust = 8 - (((unsigned long)g->sg) & 7); 849 - g->sg = (struct octeon_sg_entry *) 850 - ((unsigned long)g->sg + g->adjust); 851 - } 852 - g->sg_dma_ptr = dma_map_single(&oct->pci_dev->dev, 853 - g->sg, g->sg_size, 854 - DMA_TO_DEVICE); 855 - if (dma_mapping_error(&oct->pci_dev->dev, 856 - g->sg_dma_ptr)) { 857 - kfree((void *)((unsigned long)g->sg - 858 - g->adjust)); 859 - kfree(g); 860 - break; 861 - } 802 + g->sg_dma_ptr = lio->glists_dma_base[i] + 803 + (j * lio->glist_entry_size); 862 804 863 805 list_add_tail(&g->list, &lio->glist[i]); 864 806 } 865 807 866 808 if (j != lio->tx_qsize) { 867 809 delete_glists(lio); 868 - return 1; 810 + return -ENOMEM; 869 811 } 870 812 } 871 813 ··· 1893 1885 i++; 1894 1886 } 1895 1887 1896 - dma_sync_single_for_cpu(&lio->oct_dev->pci_dev->dev, 1897 - g->sg_dma_ptr, g->sg_size, DMA_TO_DEVICE); 1898 - 1899 1888 iq = skb_iq(lio, skb); 1900 1889 spin_lock(&lio->glist_lock[iq]); 1901 1890 list_add_tail(&g->list, &lio->glist[iq]); ··· 1937 1932 frag->size, DMA_TO_DEVICE); 1938 1933 i++; 1939 1934 } 1940 - 1941 - dma_sync_single_for_cpu(&lio->oct_dev->pci_dev->dev, 1942 - g->sg_dma_ptr, g->sg_size, DMA_TO_DEVICE); 1943 1935 1944 1936 iq = skb_iq(lio, skb); 1945 1937 ··· 3275 3273 i++; 3276 3274 } 3277 3275 3278 - dma_sync_single_for_device(&oct->pci_dev->dev, g->sg_dma_ptr, 3279 - g->sg_size, DMA_TO_DEVICE); 3280 3276 dptr = g->sg_dma_ptr; 3281 3277 3282 3278 if (OCTEON_CN23XX_PF(oct))
+55 -49
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
··· 108 108 * received from the IP layer. 109 109 */ 110 110 struct octeon_sg_entry *sg; 111 + 112 + dma_addr_t sg_dma_ptr; 111 113 }; 112 114 113 115 struct octeon_device_priv { ··· 492 490 struct octnic_gather *g; 493 491 int i; 494 492 493 + kfree(lio->glist_lock); 494 + lio->glist_lock = NULL; 495 + 495 496 if (!lio->glist) 496 497 return; 497 498 ··· 502 497 do { 503 498 g = (struct octnic_gather *) 504 499 list_delete_head(&lio->glist[i]); 505 - if (g) { 506 - if (g->sg) 507 - kfree((void *)((unsigned long)g->sg - 508 - g->adjust)); 500 + if (g) 509 501 kfree(g); 510 - } 511 502 } while (g); 503 + 504 + if (lio->glists_virt_base && lio->glists_virt_base[i]) { 505 + lio_dma_free(lio->oct_dev, 506 + lio->glist_entry_size * lio->tx_qsize, 507 + lio->glists_virt_base[i], 508 + lio->glists_dma_base[i]); 509 + } 512 510 } 513 511 512 + kfree(lio->glists_virt_base); 513 + lio->glists_virt_base = NULL; 514 + 515 + kfree(lio->glists_dma_base); 516 + lio->glists_dma_base = NULL; 517 + 514 518 kfree(lio->glist); 515 - kfree(lio->glist_lock); 519 + lio->glist = NULL; 516 520 } 517 521 518 522 /** ··· 536 522 lio->glist_lock = 537 523 kzalloc(sizeof(*lio->glist_lock) * num_iqs, GFP_KERNEL); 538 524 if (!lio->glist_lock) 539 - return 1; 525 + return -ENOMEM; 540 526 541 527 lio->glist = 542 528 kzalloc(sizeof(*lio->glist) * num_iqs, GFP_KERNEL); 543 529 if (!lio->glist) { 544 530 kfree(lio->glist_lock); 545 - return 1; 531 + lio->glist_lock = NULL; 532 + return -ENOMEM; 533 + } 534 + 535 + lio->glist_entry_size = 536 + ROUNDUP8((ROUNDUP4(OCTNIC_MAX_SG) >> 2) * OCT_SG_ENTRY_SIZE); 537 + 538 + /* allocate memory to store virtual and dma base address of 539 + * per glist consistent memory 540 + */ 541 + lio->glists_virt_base = kcalloc(num_iqs, sizeof(*lio->glists_virt_base), 542 + GFP_KERNEL); 543 + lio->glists_dma_base = kcalloc(num_iqs, sizeof(*lio->glists_dma_base), 544 + GFP_KERNEL); 545 + 546 + if (!lio->glists_virt_base || !lio->glists_dma_base) { 547 + delete_glists(lio); 548 + return -ENOMEM; 546 549 } 547 550 548 551 for (i = 0; i < num_iqs; i++) { ··· 567 536 568 537 INIT_LIST_HEAD(&lio->glist[i]); 569 538 539 + lio->glists_virt_base[i] = 540 + lio_dma_alloc(lio->oct_dev, 541 + lio->glist_entry_size * lio->tx_qsize, 542 + &lio->glists_dma_base[i]); 543 + 544 + if (!lio->glists_virt_base[i]) { 545 + delete_glists(lio); 546 + return -ENOMEM; 547 + } 548 + 570 549 for (j = 0; j < lio->tx_qsize; j++) { 571 550 g = kzalloc(sizeof(*g), GFP_KERNEL); 572 551 if (!g) 573 552 break; 574 553 575 - g->sg_size = ((ROUNDUP4(OCTNIC_MAX_SG) >> 2) * 576 - OCT_SG_ENTRY_SIZE); 554 + g->sg = lio->glists_virt_base[i] + 555 + (j * lio->glist_entry_size); 577 556 578 - g->sg = kmalloc(g->sg_size + 8, GFP_KERNEL); 579 - if (!g->sg) { 580 - kfree(g); 581 - break; 582 - } 557 + g->sg_dma_ptr = lio->glists_dma_base[i] + 558 + (j * lio->glist_entry_size); 583 559 584 - /* The gather component should be aligned on 64-bit 585 - * boundary 586 - */ 587 - if (((unsigned long)g->sg) & 7) { 588 - g->adjust = 8 - (((unsigned long)g->sg) & 7); 589 - g->sg = (struct octeon_sg_entry *) 590 - ((unsigned long)g->sg + g->adjust); 591 - } 592 560 list_add_tail(&g->list, &lio->glist[i]); 593 561 } 594 562 595 563 if (j != lio->tx_qsize) { 596 564 delete_glists(lio); 597 - return 1; 565 + return -ENOMEM; 598 566 } 599 567 } 600 568 ··· 1354 1324 i++; 1355 1325 } 1356 1326 1357 - dma_unmap_single(&lio->oct_dev->pci_dev->dev, 1358 - finfo->dptr, g->sg_size, 1359 - DMA_TO_DEVICE); 1360 - 1361 1327 iq = skb_iq(lio, skb); 1362 1328 1363 1329 spin_lock(&lio->glist_lock[iq]); ··· 1399 1373 frag->size, DMA_TO_DEVICE); 1400 1374 i++; 1401 1375 } 1402 - 1403 - dma_unmap_single(&lio->oct_dev->pci_dev->dev, 1404 - finfo->dptr, g->sg_size, 1405 - DMA_TO_DEVICE); 1406 1376 1407 1377 iq = skb_iq(lio, skb); 1408 1378 ··· 2404 2382 i++; 2405 2383 } 2406 2384 2407 - dptr = dma_map_single(&oct->pci_dev->dev, 2408 - g->sg, g->sg_size, 2409 - DMA_TO_DEVICE); 2410 - if (dma_mapping_error(&oct->pci_dev->dev, dptr)) { 2411 - dev_err(&oct->pci_dev->dev, "%s DMA mapping error 4\n", 2412 - __func__); 2413 - dma_unmap_single(&oct->pci_dev->dev, g->sg[0].ptr[0], 2414 - skb->len - skb->data_len, 2415 - DMA_TO_DEVICE); 2416 - for (j = 1; j <= frags; j++) { 2417 - frag = &skb_shinfo(skb)->frags[j - 1]; 2418 - dma_unmap_page(&oct->pci_dev->dev, 2419 - g->sg[j >> 2].ptr[j & 3], 2420 - frag->size, DMA_TO_DEVICE); 2421 - } 2422 - return NETDEV_TX_BUSY; 2423 - } 2385 + dptr = g->sg_dma_ptr; 2424 2386 2425 2387 ndata.cmd.cmd3.dptr = dptr; 2426 2388 finfo->dptr = dptr;
+3 -3
drivers/net/ethernet/cavium/liquidio/octeon_config.h
··· 71 71 #define CN23XX_MAX_RINGS_PER_VF 8 72 72 73 73 #define CN23XX_MAX_INPUT_QUEUES CN23XX_MAX_RINGS_PER_PF 74 - #define CN23XX_MAX_IQ_DESCRIPTORS 2048 74 + #define CN23XX_MAX_IQ_DESCRIPTORS 512 75 75 #define CN23XX_DB_MIN 1 76 76 #define CN23XX_DB_MAX 8 77 77 #define CN23XX_DB_TIMEOUT 1 78 78 79 79 #define CN23XX_MAX_OUTPUT_QUEUES CN23XX_MAX_RINGS_PER_PF 80 - #define CN23XX_MAX_OQ_DESCRIPTORS 2048 80 + #define CN23XX_MAX_OQ_DESCRIPTORS 512 81 81 #define CN23XX_OQ_BUF_SIZE 1536 82 82 #define CN23XX_OQ_PKTSPER_INTR 128 83 83 /*#define CAVIUM_ONLY_CN23XX_RX_PERF*/ 84 - #define CN23XX_OQ_REFIL_THRESHOLD 128 84 + #define CN23XX_OQ_REFIL_THRESHOLD 16 85 85 86 86 #define CN23XX_OQ_INTR_PKT 64 87 87 #define CN23XX_OQ_INTR_TIME 100
+2 -15
drivers/net/ethernet/cavium/liquidio/octeon_droq.c
··· 155 155 recv_buffer_destroy(droq->recv_buf_list[i].buffer, 156 156 pg_info); 157 157 158 - if (droq->desc_ring && droq->desc_ring[i].info_ptr) 159 - lio_unmap_ring_info(oct->pci_dev, 160 - (u64)droq-> 161 - desc_ring[i].info_ptr, 162 - OCT_DROQ_INFO_SIZE); 163 158 droq->recv_buf_list[i].buffer = NULL; 164 159 } 165 160 ··· 206 211 vfree(droq->recv_buf_list); 207 212 208 213 if (droq->info_base_addr) 209 - cnnic_free_aligned_dma(oct->pci_dev, droq->info_list, 210 - droq->info_alloc_size, 211 - droq->info_base_addr, 212 - droq->info_list_dma); 214 + lio_free_info_buffer(oct, droq); 213 215 214 216 if (droq->desc_ring) 215 217 lio_dma_free(oct, (droq->max_count * OCT_DROQ_DESC_SIZE), ··· 286 294 dev_dbg(&oct->pci_dev->dev, "droq[%d]: num_desc: %d\n", q_no, 287 295 droq->max_count); 288 296 289 - droq->info_list = 290 - cnnic_numa_alloc_aligned_dma((droq->max_count * 291 - OCT_DROQ_INFO_SIZE), 292 - &droq->info_alloc_size, 293 - &droq->info_base_addr, 294 - numa_node); 297 + droq->info_list = lio_alloc_info_buffer(oct, droq); 295 298 if (!droq->info_list) { 296 299 dev_err(&oct->pci_dev->dev, "Cannot allocate memory for info list.\n"); 297 300 lio_dma_free(oct, (droq->max_count * OCT_DROQ_DESC_SIZE),
+2 -2
drivers/net/ethernet/cavium/liquidio/octeon_droq.h
··· 325 325 size_t desc_ring_dma; 326 326 327 327 /** Info ptr list are allocated at this virtual address. */ 328 - size_t info_base_addr; 328 + void *info_base_addr; 329 329 330 330 /** DMA mapped address of the info list */ 331 - size_t info_list_dma; 331 + dma_addr_t info_list_dma; 332 332 333 333 /** Allocated size of info list. */ 334 334 u32 info_alloc_size;
-42
drivers/net/ethernet/cavium/liquidio/octeon_main.h
··· 140 140 return 1; 141 141 } 142 142 143 - static inline void * 144 - cnnic_numa_alloc_aligned_dma(u32 size, 145 - u32 *alloc_size, 146 - size_t *orig_ptr, 147 - int numa_node) 148 - { 149 - int retries = 0; 150 - void *ptr = NULL; 151 - 152 - #define OCTEON_MAX_ALLOC_RETRIES 1 153 - do { 154 - struct page *page = NULL; 155 - 156 - page = alloc_pages_node(numa_node, 157 - GFP_KERNEL, 158 - get_order(size)); 159 - if (!page) 160 - page = alloc_pages(GFP_KERNEL, 161 - get_order(size)); 162 - ptr = (void *)page_address(page); 163 - if ((unsigned long)ptr & 0x07) { 164 - __free_pages(page, get_order(size)); 165 - ptr = NULL; 166 - /* Increment the size required if the first 167 - * attempt failed. 168 - */ 169 - if (!retries) 170 - size += 7; 171 - } 172 - retries++; 173 - } while ((retries <= OCTEON_MAX_ALLOC_RETRIES) && !ptr); 174 - 175 - *alloc_size = size; 176 - *orig_ptr = (unsigned long)ptr; 177 - if ((unsigned long)ptr & 0x07) 178 - ptr = (void *)(((unsigned long)ptr + 7) & ~(7UL)); 179 - return ptr; 180 - } 181 - 182 - #define cnnic_free_aligned_dma(pci_dev, ptr, size, orig_ptr, dma_addr) \ 183 - free_pages(orig_ptr, get_order(size)) 184 - 185 143 static inline int 186 144 sleep_cond(wait_queue_head_t *wait_queue, int *condition) 187 145 {
+27 -16
drivers/net/ethernet/cavium/liquidio/octeon_network.h
··· 62 62 63 63 /** Array of gather component linked lists */ 64 64 struct list_head *glist; 65 + void **glists_virt_base; 66 + dma_addr_t *glists_dma_base; 67 + u32 glist_entry_size; 65 68 66 69 /** Pointer to the NIC properties for the Octeon device this network 67 70 * interface is associated with. ··· 347 344 #define lio_dma_free(oct, size, virt_addr, dma_addr) \ 348 345 dma_free_coherent(&(oct)->pci_dev->dev, size, virt_addr, dma_addr) 349 346 347 + static inline void * 348 + lio_alloc_info_buffer(struct octeon_device *oct, 349 + struct octeon_droq *droq) 350 + { 351 + void *virt_ptr; 352 + 353 + virt_ptr = lio_dma_alloc(oct, (droq->max_count * OCT_DROQ_INFO_SIZE), 354 + &droq->info_list_dma); 355 + if (virt_ptr) { 356 + droq->info_alloc_size = droq->max_count * OCT_DROQ_INFO_SIZE; 357 + droq->info_base_addr = virt_ptr; 358 + } 359 + 360 + return virt_ptr; 361 + } 362 + 363 + static inline void lio_free_info_buffer(struct octeon_device *oct, 364 + struct octeon_droq *droq) 365 + { 366 + lio_dma_free(oct, droq->info_alloc_size, droq->info_base_addr, 367 + droq->info_list_dma); 368 + } 369 + 350 370 static inline 351 371 void *get_rbd(struct sk_buff *skb) 352 372 { ··· 385 359 static inline u64 386 360 lio_map_ring_info(struct octeon_droq *droq, u32 i) 387 361 { 388 - dma_addr_t dma_addr; 389 - struct octeon_device *oct = droq->oct_dev; 390 - 391 - dma_addr = dma_map_single(&oct->pci_dev->dev, &droq->info_list[i], 392 - OCT_DROQ_INFO_SIZE, DMA_FROM_DEVICE); 393 - 394 - WARN_ON(dma_mapping_error(&oct->pci_dev->dev, dma_addr)); 395 - 396 - return (u64)dma_addr; 397 - } 398 - 399 - static inline void 400 - lio_unmap_ring_info(struct pci_dev *pci_dev, 401 - u64 info_ptr, u32 size) 402 - { 403 - dma_unmap_single(&pci_dev->dev, info_ptr, size, DMA_FROM_DEVICE); 362 + return droq->info_list_dma + (i * sizeof(struct octeon_droq_info)); 404 363 } 405 364 406 365 static inline u64
+1
drivers/net/ethernet/cavium/thunder/nic.h
··· 269 269 #define MAX_QUEUES_PER_QSET 8 270 270 struct queue_set *qs; 271 271 struct nicvf_cq_poll *napi[8]; 272 + void *iommu_domain; 272 273 u8 vf_id; 273 274 u8 sqs_id; 274 275 bool sqs_mode;
+11 -1
drivers/net/ethernet/cavium/thunder/nicvf_main.c
··· 16 16 #include <linux/log2.h> 17 17 #include <linux/prefetch.h> 18 18 #include <linux/irq.h> 19 + #include <linux/iommu.h> 19 20 20 21 #include "nic_reg.h" 21 22 #include "nic.h" ··· 526 525 /* Get actual TSO descriptors and free them */ 527 526 tso_sqe = 528 527 (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, hdr->rsvd2); 528 + nicvf_unmap_sndq_buffers(nic, sq, hdr->rsvd2, 529 + tso_sqe->subdesc_cnt); 529 530 nicvf_put_sq_desc(sq, tso_sqe->subdesc_cnt + 1); 531 + } else { 532 + nicvf_unmap_sndq_buffers(nic, sq, cqe_tx->sqe_ptr, 533 + hdr->subdesc_cnt); 530 534 } 531 535 nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1); 532 536 prefetch(skb); ··· 582 576 { 583 577 struct sk_buff *skb; 584 578 struct nicvf *nic = netdev_priv(netdev); 579 + struct nicvf *snic = nic; 585 580 int err = 0; 586 581 int rq_idx; 587 582 ··· 599 592 if (err && !cqe_rx->rb_cnt) 600 593 return; 601 594 602 - skb = nicvf_get_rcv_skb(nic, cqe_rx); 595 + skb = nicvf_get_rcv_skb(snic, cqe_rx); 603 596 if (!skb) { 604 597 netdev_dbg(nic->netdev, "Packet not received\n"); 605 598 return; ··· 1649 1642 1650 1643 if (!pass1_silicon(nic->pdev)) 1651 1644 nic->hw_tso = true; 1645 + 1646 + /* Get iommu domain for iova to physical addr conversion */ 1647 + nic->iommu_domain = iommu_get_domain_for_dev(dev); 1652 1648 1653 1649 pci_read_config_word(nic->pdev, PCI_SUBSYSTEM_ID, &sdevid); 1654 1650 if (sdevid == 0xA134)
+145 -39
drivers/net/ethernet/cavium/thunder/nicvf_queues.c
··· 10 10 #include <linux/netdevice.h> 11 11 #include <linux/ip.h> 12 12 #include <linux/etherdevice.h> 13 + #include <linux/iommu.h> 13 14 #include <net/ip.h> 14 15 #include <net/tso.h> 15 16 ··· 18 17 #include "nic.h" 19 18 #include "q_struct.h" 20 19 #include "nicvf_queues.h" 20 + 21 + #define NICVF_PAGE_ORDER ((PAGE_SIZE <= 4096) ? PAGE_ALLOC_COSTLY_ORDER : 0) 22 + 23 + static inline u64 nicvf_iova_to_phys(struct nicvf *nic, dma_addr_t dma_addr) 24 + { 25 + /* Translation is installed only when IOMMU is present */ 26 + if (nic->iommu_domain) 27 + return iommu_iova_to_phys(nic->iommu_domain, dma_addr); 28 + return dma_addr; 29 + } 21 30 22 31 static void nicvf_get_page(struct nicvf *nic) 23 32 { ··· 98 87 static inline int nicvf_alloc_rcv_buffer(struct nicvf *nic, gfp_t gfp, 99 88 u32 buf_len, u64 **rbuf) 100 89 { 101 - int order = (PAGE_SIZE <= 4096) ? PAGE_ALLOC_COSTLY_ORDER : 0; 90 + int order = NICVF_PAGE_ORDER; 102 91 103 92 /* Check if request can be accomodated in previous allocated page */ 104 93 if (nic->rb_page && ··· 108 97 } 109 98 110 99 nicvf_get_page(nic); 111 - nic->rb_page = NULL; 112 100 113 101 /* Allocate a new page */ 102 + nic->rb_page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN, 103 + order); 114 104 if (!nic->rb_page) { 115 - nic->rb_page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN, 116 - order); 117 - if (!nic->rb_page) { 118 - this_cpu_inc(nic->pnicvf->drv_stats-> 119 - rcv_buffer_alloc_failures); 120 - return -ENOMEM; 121 - } 122 - nic->rb_page_offset = 0; 105 + this_cpu_inc(nic->pnicvf->drv_stats->rcv_buffer_alloc_failures); 106 + return -ENOMEM; 123 107 } 124 - 108 + nic->rb_page_offset = 0; 125 109 ret: 126 - *rbuf = (u64 *)((u64)page_address(nic->rb_page) + nic->rb_page_offset); 110 + /* HW will ensure data coherency, CPU sync not required */ 111 + *rbuf = (u64 *)((u64)dma_map_page_attrs(&nic->pdev->dev, nic->rb_page, 112 + nic->rb_page_offset, buf_len, 113 + DMA_FROM_DEVICE, 114 + DMA_ATTR_SKIP_CPU_SYNC)); 115 + if (dma_mapping_error(&nic->pdev->dev, (dma_addr_t)*rbuf)) { 116 + if (!nic->rb_page_offset) 117 + __free_pages(nic->rb_page, order); 118 + nic->rb_page = NULL; 119 + return -ENOMEM; 120 + } 127 121 nic->rb_page_offset += buf_len; 128 122 129 123 return 0; ··· 174 158 rbdr->dma_size = buf_size; 175 159 rbdr->enable = true; 176 160 rbdr->thresh = RBDR_THRESH; 161 + rbdr->head = 0; 162 + rbdr->tail = 0; 177 163 178 164 nic->rb_page = NULL; 179 165 for (idx = 0; idx < ring_len; idx++) { 180 166 err = nicvf_alloc_rcv_buffer(nic, GFP_KERNEL, RCV_FRAG_LEN, 181 167 &rbuf); 182 - if (err) 168 + if (err) { 169 + /* To free already allocated and mapped ones */ 170 + rbdr->tail = idx - 1; 183 171 return err; 172 + } 184 173 185 174 desc = GET_RBDR_DESC(rbdr, idx); 186 - desc->buf_addr = virt_to_phys(rbuf) >> NICVF_RCV_BUF_ALIGN; 175 + desc->buf_addr = (u64)rbuf >> NICVF_RCV_BUF_ALIGN; 187 176 } 188 177 189 178 nicvf_get_page(nic); ··· 200 179 static void nicvf_free_rbdr(struct nicvf *nic, struct rbdr *rbdr) 201 180 { 202 181 int head, tail; 203 - u64 buf_addr; 182 + u64 buf_addr, phys_addr; 204 183 struct rbdr_entry_t *desc; 205 184 206 185 if (!rbdr) ··· 213 192 head = rbdr->head; 214 193 tail = rbdr->tail; 215 194 216 - /* Free SKBs */ 195 + /* Release page references */ 217 196 while (head != tail) { 218 197 desc = GET_RBDR_DESC(rbdr, head); 219 - buf_addr = desc->buf_addr << NICVF_RCV_BUF_ALIGN; 220 - put_page(virt_to_page(phys_to_virt(buf_addr))); 198 + buf_addr = ((u64)desc->buf_addr) << NICVF_RCV_BUF_ALIGN; 199 + phys_addr = nicvf_iova_to_phys(nic, buf_addr); 200 + dma_unmap_page_attrs(&nic->pdev->dev, buf_addr, RCV_FRAG_LEN, 201 + DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); 202 + if (phys_addr) 203 + put_page(virt_to_page(phys_to_virt(phys_addr))); 221 204 head++; 222 205 head &= (rbdr->dmem.q_len - 1); 223 206 } 224 - /* Free SKB of tail desc */ 207 + /* Release buffer of tail desc */ 225 208 desc = GET_RBDR_DESC(rbdr, tail); 226 - buf_addr = desc->buf_addr << NICVF_RCV_BUF_ALIGN; 227 - put_page(virt_to_page(phys_to_virt(buf_addr))); 209 + buf_addr = ((u64)desc->buf_addr) << NICVF_RCV_BUF_ALIGN; 210 + phys_addr = nicvf_iova_to_phys(nic, buf_addr); 211 + dma_unmap_page_attrs(&nic->pdev->dev, buf_addr, RCV_FRAG_LEN, 212 + DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); 213 + if (phys_addr) 214 + put_page(virt_to_page(phys_to_virt(phys_addr))); 228 215 229 216 /* Free RBDR ring */ 230 217 nicvf_free_q_desc_mem(nic, &rbdr->dmem); ··· 279 250 break; 280 251 281 252 desc = GET_RBDR_DESC(rbdr, tail); 282 - desc->buf_addr = virt_to_phys(rbuf) >> NICVF_RCV_BUF_ALIGN; 253 + desc->buf_addr = (u64)rbuf >> NICVF_RCV_BUF_ALIGN; 283 254 refill_rb_cnt--; 284 255 new_rb++; 285 256 } ··· 390 361 return 0; 391 362 } 392 363 364 + void nicvf_unmap_sndq_buffers(struct nicvf *nic, struct snd_queue *sq, 365 + int hdr_sqe, u8 subdesc_cnt) 366 + { 367 + u8 idx; 368 + struct sq_gather_subdesc *gather; 369 + 370 + /* Unmap DMA mapped skb data buffers */ 371 + for (idx = 0; idx < subdesc_cnt; idx++) { 372 + hdr_sqe++; 373 + hdr_sqe &= (sq->dmem.q_len - 1); 374 + gather = (struct sq_gather_subdesc *)GET_SQ_DESC(sq, hdr_sqe); 375 + /* HW will ensure data coherency, CPU sync not required */ 376 + dma_unmap_page_attrs(&nic->pdev->dev, gather->addr, 377 + gather->size, DMA_TO_DEVICE, 378 + DMA_ATTR_SKIP_CPU_SYNC); 379 + } 380 + } 381 + 393 382 static void nicvf_free_snd_queue(struct nicvf *nic, struct snd_queue *sq) 394 383 { 395 384 struct sk_buff *skb; 385 + struct sq_hdr_subdesc *hdr; 386 + struct sq_hdr_subdesc *tso_sqe; 396 387 397 388 if (!sq) 398 389 return; ··· 428 379 smp_rmb(); 429 380 while (sq->head != sq->tail) { 430 381 skb = (struct sk_buff *)sq->skbuff[sq->head]; 431 - if (skb) 432 - dev_kfree_skb_any(skb); 382 + if (!skb) 383 + goto next; 384 + hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, sq->head); 385 + /* Check for dummy descriptor used for HW TSO offload on 88xx */ 386 + if (hdr->dont_send) { 387 + /* Get actual TSO descriptors and unmap them */ 388 + tso_sqe = 389 + (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, hdr->rsvd2); 390 + nicvf_unmap_sndq_buffers(nic, sq, hdr->rsvd2, 391 + tso_sqe->subdesc_cnt); 392 + } else { 393 + nicvf_unmap_sndq_buffers(nic, sq, sq->head, 394 + hdr->subdesc_cnt); 395 + } 396 + dev_kfree_skb_any(skb); 397 + next: 433 398 sq->head++; 434 399 sq->head &= (sq->dmem.q_len - 1); 435 400 } ··· 622 559 nicvf_send_msg_to_pf(nic, &mbx); 623 560 624 561 if (!nic->sqs_mode && (qidx == 0)) { 625 - /* Enable checking L3/L4 length and TCP/UDP checksums */ 562 + /* Enable checking L3/L4 length and TCP/UDP checksums 563 + * Also allow IPv6 pkts with zero UDP checksum. 564 + */ 626 565 nicvf_queue_reg_write(nic, NIC_QSET_RQ_GEN_CFG, 0, 627 - (BIT(24) | BIT(23) | BIT(21))); 566 + (BIT(24) | BIT(23) | BIT(21) | BIT(20))); 628 567 nicvf_config_vlan_stripping(nic, nic->netdev->features); 629 568 } 630 569 ··· 945 880 sq->tail &= (sq->dmem.q_len - 1); 946 881 947 882 return qentry; 883 + } 884 + 885 + /* Rollback to previous tail pointer when descriptors not used */ 886 + static inline void nicvf_rollback_sq_desc(struct snd_queue *sq, 887 + int qentry, int desc_cnt) 888 + { 889 + sq->tail = qentry; 890 + atomic_add(desc_cnt, &sq->free_cnt); 948 891 } 949 892 950 893 /* Free descriptor back to SQ for future use */ ··· 1280 1207 struct sk_buff *skb, u8 sq_num) 1281 1208 { 1282 1209 int i, size; 1283 - int subdesc_cnt, tso_sqe = 0; 1210 + int subdesc_cnt, hdr_sqe = 0; 1284 1211 int qentry; 1212 + u64 dma_addr; 1285 1213 1286 1214 subdesc_cnt = nicvf_sq_subdesc_required(nic, skb); 1287 1215 if (subdesc_cnt > atomic_read(&sq->free_cnt)) ··· 1297 1223 /* Add SQ header subdesc */ 1298 1224 nicvf_sq_add_hdr_subdesc(nic, sq, qentry, subdesc_cnt - 1, 1299 1225 skb, skb->len); 1300 - tso_sqe = qentry; 1226 + hdr_sqe = qentry; 1301 1227 1302 1228 /* Add SQ gather subdescs */ 1303 1229 qentry = nicvf_get_nxt_sqentry(sq, qentry); 1304 1230 size = skb_is_nonlinear(skb) ? skb_headlen(skb) : skb->len; 1305 - nicvf_sq_add_gather_subdesc(sq, qentry, size, virt_to_phys(skb->data)); 1231 + /* HW will ensure data coherency, CPU sync not required */ 1232 + dma_addr = dma_map_page_attrs(&nic->pdev->dev, virt_to_page(skb->data), 1233 + offset_in_page(skb->data), size, 1234 + DMA_TO_DEVICE, DMA_ATTR_SKIP_CPU_SYNC); 1235 + if (dma_mapping_error(&nic->pdev->dev, dma_addr)) { 1236 + nicvf_rollback_sq_desc(sq, qentry, subdesc_cnt); 1237 + return 0; 1238 + } 1239 + 1240 + nicvf_sq_add_gather_subdesc(sq, qentry, size, dma_addr); 1306 1241 1307 1242 /* Check for scattered buffer */ 1308 1243 if (!skb_is_nonlinear(skb)) ··· 1324 1241 1325 1242 qentry = nicvf_get_nxt_sqentry(sq, qentry); 1326 1243 size = skb_frag_size(frag); 1327 - nicvf_sq_add_gather_subdesc(sq, qentry, size, 1328 - virt_to_phys( 1329 - skb_frag_address(frag))); 1244 + dma_addr = dma_map_page_attrs(&nic->pdev->dev, 1245 + skb_frag_page(frag), 1246 + frag->page_offset, size, 1247 + DMA_TO_DEVICE, 1248 + DMA_ATTR_SKIP_CPU_SYNC); 1249 + if (dma_mapping_error(&nic->pdev->dev, dma_addr)) { 1250 + /* Free entire chain of mapped buffers 1251 + * here 'i' = frags mapped + above mapped skb->data 1252 + */ 1253 + nicvf_unmap_sndq_buffers(nic, sq, hdr_sqe, i); 1254 + nicvf_rollback_sq_desc(sq, qentry, subdesc_cnt); 1255 + return 0; 1256 + } 1257 + nicvf_sq_add_gather_subdesc(sq, qentry, size, dma_addr); 1330 1258 } 1331 1259 1332 1260 doorbell: 1333 1261 if (nic->t88 && skb_shinfo(skb)->gso_size) { 1334 1262 qentry = nicvf_get_nxt_sqentry(sq, qentry); 1335 - nicvf_sq_add_cqe_subdesc(sq, qentry, tso_sqe, skb); 1263 + nicvf_sq_add_cqe_subdesc(sq, qentry, hdr_sqe, skb); 1336 1264 } 1337 1265 1338 1266 nicvf_sq_doorbell(nic, skb, sq_num, subdesc_cnt); ··· 1376 1282 int offset; 1377 1283 u16 *rb_lens = NULL; 1378 1284 u64 *rb_ptrs = NULL; 1285 + u64 phys_addr; 1379 1286 1380 1287 rb_lens = (void *)cqe_rx + (3 * sizeof(u64)); 1381 1288 /* Except 88xx pass1 on all other chips CQE_RX2_S is added to ··· 1391 1296 else 1392 1297 rb_ptrs = (void *)cqe_rx + (7 * sizeof(u64)); 1393 1298 1394 - netdev_dbg(nic->netdev, "%s rb_cnt %d rb0_ptr %llx rb0_sz %d\n", 1395 - __func__, cqe_rx->rb_cnt, cqe_rx->rb0_ptr, cqe_rx->rb0_sz); 1396 - 1397 1299 for (frag = 0; frag < cqe_rx->rb_cnt; frag++) { 1398 1300 payload_len = rb_lens[frag_num(frag)]; 1301 + phys_addr = nicvf_iova_to_phys(nic, *rb_ptrs); 1302 + if (!phys_addr) { 1303 + if (skb) 1304 + dev_kfree_skb_any(skb); 1305 + return NULL; 1306 + } 1307 + 1399 1308 if (!frag) { 1400 1309 /* First fragment */ 1310 + dma_unmap_page_attrs(&nic->pdev->dev, 1311 + *rb_ptrs - cqe_rx->align_pad, 1312 + RCV_FRAG_LEN, DMA_FROM_DEVICE, 1313 + DMA_ATTR_SKIP_CPU_SYNC); 1401 1314 skb = nicvf_rb_ptr_to_skb(nic, 1402 - *rb_ptrs - cqe_rx->align_pad, 1315 + phys_addr - cqe_rx->align_pad, 1403 1316 payload_len); 1404 1317 if (!skb) 1405 1318 return NULL; ··· 1415 1312 skb_put(skb, payload_len); 1416 1313 } else { 1417 1314 /* Add fragments */ 1418 - page = virt_to_page(phys_to_virt(*rb_ptrs)); 1419 - offset = phys_to_virt(*rb_ptrs) - page_address(page); 1315 + dma_unmap_page_attrs(&nic->pdev->dev, *rb_ptrs, 1316 + RCV_FRAG_LEN, DMA_FROM_DEVICE, 1317 + DMA_ATTR_SKIP_CPU_SYNC); 1318 + page = virt_to_page(phys_to_virt(phys_addr)); 1319 + offset = phys_to_virt(phys_addr) - page_address(page); 1420 1320 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 1421 1321 offset, payload_len, RCV_FRAG_LEN); 1422 1322 }
+3 -1
drivers/net/ethernet/cavium/thunder/nicvf_queues.h
··· 87 87 #define RCV_BUF_COUNT (1ULL << (RBDR_SIZE + 13)) 88 88 #define MAX_RCV_BUF_COUNT (1ULL << (RBDR_SIZE6 + 13)) 89 89 #define RBDR_THRESH (RCV_BUF_COUNT / 2) 90 - #define DMA_BUFFER_LEN 2048 /* In multiples of 128bytes */ 90 + #define DMA_BUFFER_LEN 1536 /* In multiples of 128bytes */ 91 91 #define RCV_FRAG_LEN (SKB_DATA_ALIGN(DMA_BUFFER_LEN + NET_SKB_PAD) + \ 92 92 SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) 93 93 ··· 301 301 302 302 #define CQ_ERR_MASK (CQ_WR_FULL | CQ_WR_DISABLE | CQ_WR_FAULT) 303 303 304 + void nicvf_unmap_sndq_buffers(struct nicvf *nic, struct snd_queue *sq, 305 + int hdr_sqe, u8 subdesc_cnt); 304 306 void nicvf_config_vlan_stripping(struct nicvf *nic, 305 307 netdev_features_t features); 306 308 int nicvf_set_qset_resources(struct nicvf *nic);
+45 -19
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
··· 123 123 return 1; 124 124 } 125 125 126 + static int max_bgx_per_node; 127 + static void set_max_bgx_per_node(struct pci_dev *pdev) 128 + { 129 + u16 sdevid; 130 + 131 + if (max_bgx_per_node) 132 + return; 133 + 134 + pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &sdevid); 135 + switch (sdevid) { 136 + case PCI_SUBSYS_DEVID_81XX_BGX: 137 + max_bgx_per_node = MAX_BGX_PER_CN81XX; 138 + break; 139 + case PCI_SUBSYS_DEVID_83XX_BGX: 140 + max_bgx_per_node = MAX_BGX_PER_CN83XX; 141 + break; 142 + case PCI_SUBSYS_DEVID_88XX_BGX: 143 + default: 144 + max_bgx_per_node = MAX_BGX_PER_CN88XX; 145 + break; 146 + } 147 + } 148 + 149 + static struct bgx *get_bgx(int node, int bgx_idx) 150 + { 151 + int idx = (node * max_bgx_per_node) + bgx_idx; 152 + 153 + return bgx_vnic[idx]; 154 + } 155 + 126 156 /* Return number of BGX present in HW */ 127 157 unsigned bgx_get_map(int node) 128 158 { 129 159 int i; 130 160 unsigned map = 0; 131 161 132 - for (i = 0; i < MAX_BGX_PER_NODE; i++) { 133 - if (bgx_vnic[(node * MAX_BGX_PER_NODE) + i]) 162 + for (i = 0; i < max_bgx_per_node; i++) { 163 + if (bgx_vnic[(node * max_bgx_per_node) + i]) 134 164 map |= (1 << i); 135 165 } 136 166 ··· 173 143 { 174 144 struct bgx *bgx; 175 145 176 - bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 146 + bgx = get_bgx(node, bgx_idx); 177 147 if (bgx) 178 148 return bgx->lmac_count; 179 149 ··· 188 158 struct bgx *bgx; 189 159 struct lmac *lmac; 190 160 191 - bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 161 + bgx = get_bgx(node, bgx_idx); 192 162 if (!bgx) 193 163 return; 194 164 ··· 202 172 203 173 const u8 *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid) 204 174 { 205 - struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 175 + struct bgx *bgx = get_bgx(node, bgx_idx); 206 176 207 177 if (bgx) 208 178 return bgx->lmac[lmacid].mac; ··· 213 183 214 184 void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac) 215 185 { 216 - struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 186 + struct bgx *bgx = get_bgx(node, bgx_idx); 217 187 218 188 if (!bgx) 219 189 return; ··· 224 194 225 195 void bgx_lmac_rx_tx_enable(int node, int bgx_idx, int lmacid, bool enable) 226 196 { 227 - struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 197 + struct bgx *bgx = get_bgx(node, bgx_idx); 228 198 struct lmac *lmac; 229 199 u64 cfg; 230 200 ··· 247 217 void bgx_lmac_get_pfc(int node, int bgx_idx, int lmacid, void *pause) 248 218 { 249 219 struct pfc *pfc = (struct pfc *)pause; 250 - struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx]; 220 + struct bgx *bgx = get_bgx(node, bgx_idx); 251 221 struct lmac *lmac; 252 222 u64 cfg; 253 223 ··· 267 237 void bgx_lmac_set_pfc(int node, int bgx_idx, int lmacid, void *pause) 268 238 { 269 239 struct pfc *pfc = (struct pfc *)pause; 270 - struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx]; 240 + struct bgx *bgx = get_bgx(node, bgx_idx); 271 241 struct lmac *lmac; 272 242 u64 cfg; 273 243 ··· 399 369 { 400 370 struct bgx *bgx; 401 371 402 - bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 372 + bgx = get_bgx(node, bgx_idx); 403 373 if (!bgx) 404 374 return 0; 405 375 ··· 413 383 { 414 384 struct bgx *bgx; 415 385 416 - bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 386 + bgx = get_bgx(node, bgx_idx); 417 387 if (!bgx) 418 388 return 0; 419 389 ··· 441 411 struct lmac *lmac; 442 412 u64 cfg; 443 413 444 - bgx = bgx_vnic[(node * MAX_BGX_PER_NODE) + bgx_idx]; 414 + bgx = get_bgx(node, bgx_idx); 445 415 if (!bgx) 446 416 return; 447 417 ··· 1041 1011 dev_info(dev, "%s: 40G_KR4\n", (char *)str); 1042 1012 break; 1043 1013 case BGX_MODE_QSGMII: 1044 - if ((lmacid == 0) && 1045 - (bgx_get_lane2sds_cfg(bgx, lmac) != lmacid)) 1046 - return; 1047 - if ((lmacid == 2) && 1048 - (bgx_get_lane2sds_cfg(bgx, lmac) == lmacid)) 1049 - return; 1050 1014 dev_info(dev, "%s: QSGMII\n", (char *)str); 1051 1015 break; 1052 1016 case BGX_MODE_RGMII: ··· 1358 1334 goto err_release_regions; 1359 1335 } 1360 1336 1337 + set_max_bgx_per_node(pdev); 1338 + 1361 1339 pci_read_config_word(pdev, PCI_DEVICE_ID, &sdevid); 1362 1340 if (sdevid != PCI_DEVICE_ID_THUNDER_RGX) { 1363 1341 bgx->bgx_id = (pci_resource_start(pdev, 1364 1342 PCI_CFG_REG_BAR_NUM) >> 24) & BGX_ID_MASK; 1365 - bgx->bgx_id += nic_get_node_id(pdev) * MAX_BGX_PER_NODE; 1343 + bgx->bgx_id += nic_get_node_id(pdev) * max_bgx_per_node; 1366 1344 bgx->max_lmac = MAX_LMAC_PER_BGX; 1367 1345 bgx_vnic[bgx->bgx_id] = bgx; 1368 1346 } else {
-1
drivers/net/ethernet/cavium/thunder/thunder_bgx.h
··· 22 22 #define MAX_BGX_PER_CN88XX 2 23 23 #define MAX_BGX_PER_CN81XX 3 /* 2 BGXs + 1 RGX */ 24 24 #define MAX_BGX_PER_CN83XX 4 25 - #define MAX_BGX_PER_NODE 4 26 25 #define MAX_LMAC_PER_BGX 4 27 26 #define MAX_BGX_CHANS_PER_LMAC 16 28 27 #define MAX_DMAC_PER_LMAC 8
+17 -8
drivers/net/ethernet/ibm/emac/core.c
··· 2589 2589 static int emac_dt_phy_connect(struct emac_instance *dev, 2590 2590 struct device_node *phy_handle) 2591 2591 { 2592 - int res; 2593 - 2594 2592 dev->phy.def = devm_kzalloc(&dev->ofdev->dev, sizeof(*dev->phy.def), 2595 2593 GFP_KERNEL); 2596 2594 if (!dev->phy.def) ··· 2615 2617 { 2616 2618 struct device_node *np = dev->ofdev->dev.of_node; 2617 2619 struct device_node *phy_handle; 2618 - int res = 0; 2620 + int res = 1; 2619 2621 2620 2622 phy_handle = of_parse_phandle(np, "phy-handle", 0); 2621 2623 ··· 2712 2714 if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII)) { 2713 2715 int res = emac_dt_phy_probe(dev); 2714 2716 2715 - mutex_unlock(&emac_phy_map_lock); 2716 - if (!res) 2717 + switch (res) { 2718 + case 1: 2719 + /* No phy-handle property configured. 2720 + * Continue with the existing phy probe 2721 + * and setup code. 2722 + */ 2723 + break; 2724 + 2725 + case 0: 2726 + mutex_unlock(&emac_phy_map_lock); 2717 2727 goto init_phy; 2718 2728 2719 - dev_err(&dev->ofdev->dev, "failed to attach dt phy (%d).\n", 2720 - res); 2721 - return res; 2729 + default: 2730 + mutex_unlock(&emac_phy_map_lock); 2731 + dev_err(&dev->ofdev->dev, "failed to attach dt phy (%d).\n", 2732 + res); 2733 + return res; 2734 + } 2722 2735 } 2723 2736 2724 2737 if (dev->phy_address != 0xffffffff)
+34 -9
drivers/net/ethernet/ibm/ibmvnic.c
··· 404 404 send_map_query(adapter); 405 405 for (i = 0; i < rxadd_subcrqs; i++) { 406 406 init_rx_pool(adapter, &adapter->rx_pool[i], 407 - IBMVNIC_BUFFS_PER_POOL, i, 407 + adapter->req_rx_add_entries_per_subcrq, i, 408 408 be64_to_cpu(size_array[i]), 1); 409 409 if (alloc_rx_pool(adapter, &adapter->rx_pool[i])) { 410 410 dev_err(dev, "Couldn't alloc rx pool\n"); ··· 419 419 for (i = 0; i < tx_subcrqs; i++) { 420 420 tx_pool = &adapter->tx_pool[i]; 421 421 tx_pool->tx_buff = 422 - kcalloc(adapter->max_tx_entries_per_subcrq, 422 + kcalloc(adapter->req_tx_entries_per_subcrq, 423 423 sizeof(struct ibmvnic_tx_buff), GFP_KERNEL); 424 424 if (!tx_pool->tx_buff) 425 425 goto tx_pool_alloc_failed; 426 426 427 427 if (alloc_long_term_buff(adapter, &tx_pool->long_term_buff, 428 - adapter->max_tx_entries_per_subcrq * 428 + adapter->req_tx_entries_per_subcrq * 429 429 adapter->req_mtu)) 430 430 goto tx_ltb_alloc_failed; 431 431 432 432 tx_pool->free_map = 433 - kcalloc(adapter->max_tx_entries_per_subcrq, 433 + kcalloc(adapter->req_tx_entries_per_subcrq, 434 434 sizeof(int), GFP_KERNEL); 435 435 if (!tx_pool->free_map) 436 436 goto tx_fm_alloc_failed; 437 437 438 - for (j = 0; j < adapter->max_tx_entries_per_subcrq; j++) 438 + for (j = 0; j < adapter->req_tx_entries_per_subcrq; j++) 439 439 tx_pool->free_map[j] = j; 440 440 441 441 tx_pool->consumer_index = 0; ··· 705 705 u8 *hdrs = (u8 *)&adapter->tx_rx_desc_req; 706 706 struct device *dev = &adapter->vdev->dev; 707 707 struct ibmvnic_tx_buff *tx_buff = NULL; 708 + struct ibmvnic_sub_crq_queue *tx_scrq; 708 709 struct ibmvnic_tx_pool *tx_pool; 709 710 unsigned int tx_send_failed = 0; 710 711 unsigned int tx_map_failed = 0; ··· 725 724 int ret = 0; 726 725 727 726 tx_pool = &adapter->tx_pool[queue_num]; 727 + tx_scrq = adapter->tx_scrq[queue_num]; 728 728 txq = netdev_get_tx_queue(netdev, skb_get_queue_mapping(skb)); 729 729 handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) + 730 730 be32_to_cpu(adapter->login_rsp_buf-> ··· 746 744 747 745 tx_pool->consumer_index = 748 746 (tx_pool->consumer_index + 1) % 749 - adapter->max_tx_entries_per_subcrq; 747 + adapter->req_tx_entries_per_subcrq; 750 748 751 749 tx_buff = &tx_pool->tx_buff[index]; 752 750 tx_buff->skb = skb; ··· 819 817 820 818 if (tx_pool->consumer_index == 0) 821 819 tx_pool->consumer_index = 822 - adapter->max_tx_entries_per_subcrq - 1; 820 + adapter->req_tx_entries_per_subcrq - 1; 823 821 else 824 822 tx_pool->consumer_index--; 825 823 ··· 828 826 ret = NETDEV_TX_BUSY; 829 827 goto out; 830 828 } 829 + 830 + atomic_inc(&tx_scrq->used); 831 + 832 + if (atomic_read(&tx_scrq->used) >= adapter->req_tx_entries_per_subcrq) { 833 + netdev_info(netdev, "Stopping queue %d\n", queue_num); 834 + netif_stop_subqueue(netdev, queue_num); 835 + } 836 + 831 837 tx_packets++; 832 838 tx_bytes += skb->len; 833 839 txq->trans_start = jiffies; ··· 1223 1213 scrq->adapter = adapter; 1224 1214 scrq->size = 4 * PAGE_SIZE / sizeof(*scrq->msgs); 1225 1215 scrq->cur = 0; 1216 + atomic_set(&scrq->used, 0); 1226 1217 scrq->rx_skb_top = NULL; 1227 1218 spin_lock_init(&scrq->lock); 1228 1219 ··· 1366 1355 DMA_TO_DEVICE); 1367 1356 } 1368 1357 1369 - if (txbuff->last_frag) 1358 + if (txbuff->last_frag) { 1359 + atomic_dec(&scrq->used); 1360 + 1361 + if (atomic_read(&scrq->used) <= 1362 + (adapter->req_tx_entries_per_subcrq / 2) && 1363 + netif_subqueue_stopped(adapter->netdev, 1364 + txbuff->skb)) { 1365 + netif_wake_subqueue(adapter->netdev, 1366 + scrq->pool_index); 1367 + netdev_dbg(adapter->netdev, 1368 + "Started queue %d\n", 1369 + scrq->pool_index); 1370 + } 1371 + 1370 1372 dev_kfree_skb_any(txbuff->skb); 1373 + } 1371 1374 1372 1375 adapter->tx_pool[pool].free_map[adapter->tx_pool[pool]. 1373 1376 producer_index] = index; 1374 1377 adapter->tx_pool[pool].producer_index = 1375 1378 (adapter->tx_pool[pool].producer_index + 1) % 1376 - adapter->max_tx_entries_per_subcrq; 1379 + adapter->req_tx_entries_per_subcrq; 1377 1380 } 1378 1381 /* remove tx_comp scrq*/ 1379 1382 next->tx_comp.first = 0;
+1
drivers/net/ethernet/ibm/ibmvnic.h
··· 863 863 spinlock_t lock; 864 864 struct sk_buff *rx_skb_top; 865 865 struct ibmvnic_adapter *adapter; 866 + atomic_t used; 866 867 }; 867 868 868 869 struct ibmvnic_long_term_buff {
+1
drivers/net/ethernet/mellanox/mlx5/core/Kconfig
··· 14 14 config MLX5_CORE_EN 15 15 bool "Mellanox Technologies ConnectX-4 Ethernet support" 16 16 depends on NETDEVICES && ETHERNET && PCI && MLX5_CORE 17 + depends on IPV6=y || IPV6=n || MLX5_CORE=m 17 18 imply PTP_1588_CLOCK 18 19 default n 19 20 ---help---
+5 -5
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
··· 302 302 struct mlx5e_priv *priv = netdev_priv(dev); 303 303 struct mlx5e_dcbx *dcbx = &priv->dcbx; 304 304 305 + if (mode & DCB_CAP_DCBX_LLD_MANAGED) 306 + return 1; 307 + 305 308 if ((!mode) && MLX5_CAP_GEN(priv->mdev, dcbx)) { 306 309 if (dcbx->mode == MLX5E_DCBX_PARAM_VER_OPER_AUTO) 307 310 return 0; ··· 318 315 return 1; 319 316 } 320 317 321 - if (mlx5e_dcbnl_switch_to_host_mode(netdev_priv(dev))) 318 + if (!(mode & DCB_CAP_DCBX_HOST)) 322 319 return 1; 323 320 324 - if ((mode & DCB_CAP_DCBX_LLD_MANAGED) || 325 - !(mode & DCB_CAP_DCBX_VER_CEE) || 326 - !(mode & DCB_CAP_DCBX_VER_IEEE) || 327 - !(mode & DCB_CAP_DCBX_HOST)) 321 + if (mlx5e_dcbnl_switch_to_host_mode(netdev_priv(dev))) 328 322 return 1; 329 323 330 324 return 0;
+1 -4
drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c
··· 204 204 struct iphdr *iph; 205 205 206 206 /* We are only going to peek, no need to clone the SKB */ 207 - if (skb->protocol != htons(ETH_P_IP)) 208 - goto out; 209 - 210 207 if (MLX5E_TEST_PKT_SIZE - ETH_HLEN > skb_headlen(skb)) 211 208 goto out; 212 209 ··· 246 249 lbtp->loopback_ok = false; 247 250 init_completion(&lbtp->comp); 248 251 249 - lbtp->pt.type = htons(ETH_P_ALL); 252 + lbtp->pt.type = htons(ETH_P_IP); 250 253 lbtp->pt.func = mlx5e_test_loopback_validate; 251 254 lbtp->pt.dev = priv->netdev; 252 255 lbtp->pt.af_packet_priv = lbtp;
+18 -15
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 48 48 #include "eswitch.h" 49 49 #include "vxlan.h" 50 50 51 + enum { 52 + MLX5E_TC_FLOW_ESWITCH = BIT(0), 53 + }; 54 + 51 55 struct mlx5e_tc_flow { 52 56 struct rhash_head node; 53 57 u64 cookie; 58 + u8 flags; 54 59 struct mlx5_flow_handle *rule; 55 60 struct list_head encap; /* flows sharing the same encap */ 56 61 struct mlx5_esw_flow_attr *attr; ··· 182 177 mlx5_fc_destroy(priv->mdev, counter); 183 178 } 184 179 185 - if (esw && esw->mode == SRIOV_OFFLOADS) { 180 + if (flow->flags & MLX5E_TC_FLOW_ESWITCH) { 186 181 mlx5_eswitch_del_vlan_action(esw, flow->attr); 187 182 if (flow->attr->action & MLX5_FLOW_CONTEXT_ACTION_ENCAP) 188 183 mlx5e_detach_encap(priv, flow); ··· 603 598 } 604 599 605 600 static int parse_cls_flower(struct mlx5e_priv *priv, 601 + struct mlx5e_tc_flow *flow, 606 602 struct mlx5_flow_spec *spec, 607 603 struct tc_cls_flower_offload *f) 608 604 { ··· 615 609 616 610 err = __parse_cls_flower(priv, spec, f, &min_inline); 617 611 618 - if (!err && esw->mode == SRIOV_OFFLOADS && 612 + if (!err && (flow->flags & MLX5E_TC_FLOW_ESWITCH) && 619 613 rep->vport != FDB_UPLINK_VPORT) { 620 614 if (min_inline > esw->offloads.inline_mode) { 621 615 netdev_warn(priv->netdev, ··· 1138 1132 struct tc_cls_flower_offload *f) 1139 1133 { 1140 1134 struct mlx5e_tc_table *tc = &priv->fs.tc; 1141 - int err = 0; 1142 - bool fdb_flow = false; 1135 + int err, attr_size = 0; 1143 1136 u32 flow_tag, action; 1144 1137 struct mlx5e_tc_flow *flow; 1145 1138 struct mlx5_flow_spec *spec; 1146 1139 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 1140 + u8 flow_flags = 0; 1147 1141 1148 - if (esw && esw->mode == SRIOV_OFFLOADS) 1149 - fdb_flow = true; 1142 + if (esw && esw->mode == SRIOV_OFFLOADS) { 1143 + flow_flags = MLX5E_TC_FLOW_ESWITCH; 1144 + attr_size = sizeof(struct mlx5_esw_flow_attr); 1145 + } 1150 1146 1151 - if (fdb_flow) 1152 - flow = kzalloc(sizeof(*flow) + 1153 - sizeof(struct mlx5_esw_flow_attr), 1154 - GFP_KERNEL); 1155 - else 1156 - flow = kzalloc(sizeof(*flow), GFP_KERNEL); 1157 - 1147 + flow = kzalloc(sizeof(*flow) + attr_size, GFP_KERNEL); 1158 1148 spec = mlx5_vzalloc(sizeof(*spec)); 1159 1149 if (!spec || !flow) { 1160 1150 err = -ENOMEM; ··· 1158 1156 } 1159 1157 1160 1158 flow->cookie = f->cookie; 1159 + flow->flags = flow_flags; 1161 1160 1162 - err = parse_cls_flower(priv, spec, f); 1161 + err = parse_cls_flower(priv, flow, spec, f); 1163 1162 if (err < 0) 1164 1163 goto err_free; 1165 1164 1166 - if (fdb_flow) { 1165 + if (flow->flags & MLX5E_TC_FLOW_ESWITCH) { 1167 1166 flow->attr = (struct mlx5_esw_flow_attr *)(flow + 1); 1168 1167 err = parse_tc_fdb_actions(priv, f->exts, flow); 1169 1168 if (err < 0)
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
··· 1136 1136 u32 *match_criteria) 1137 1137 { 1138 1138 int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); 1139 - struct list_head *prev = ft->node.children.prev; 1139 + struct list_head *prev = &ft->node.children; 1140 1140 unsigned int candidate_index = 0; 1141 1141 struct mlx5_flow_group *fg; 1142 1142 void *match_criteria_addr;
+3 -2
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 1352 1352 if (err) 1353 1353 goto clean_load; 1354 1354 1355 + pci_save_state(pdev); 1355 1356 return 0; 1356 1357 1357 1358 clean_load: ··· 1408 1407 1409 1408 mlx5_enter_error_state(dev); 1410 1409 mlx5_unload_one(dev, priv, false); 1411 - /* In case of kernel call save the pci state and drain the health wq */ 1410 + /* In case of kernel call drain the health wq */ 1412 1411 if (state) { 1413 - pci_save_state(pdev); 1414 1412 mlx5_drain_health_wq(dev); 1415 1413 mlx5_pci_disable_device(dev); 1416 1414 } ··· 1461 1461 1462 1462 pci_set_master(pdev); 1463 1463 pci_restore_state(pdev); 1464 + pci_save_state(pdev); 1464 1465 1465 1466 if (wait_vital(pdev)) { 1466 1467 dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__);
+2 -2
drivers/net/ethernet/mellanox/mlxsw/reg.h
··· 769 769 #define MLXSW_REG_SPVM_ID 0x200F 770 770 #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */ 771 771 #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */ 772 - #define MLXSW_REG_SPVM_REC_MAX_COUNT 256 772 + #define MLXSW_REG_SPVM_REC_MAX_COUNT 255 773 773 #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \ 774 774 MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT) 775 775 ··· 1702 1702 #define MLXSW_REG_SPVMLR_ID 0x2020 1703 1703 #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */ 1704 1704 #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */ 1705 - #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 256 1705 + #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255 1706 1706 #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \ 1707 1707 MLXSW_REG_SPVMLR_REC_LEN * \ 1708 1708 MLXSW_REG_SPVMLR_REC_MAX_COUNT)
+2 -2
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
··· 303 303 ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, mlxsw_sp_port->dev, 304 304 ingress, 305 305 MLXSW_SP_ACL_PROFILE_FLOWER); 306 - if (WARN_ON(IS_ERR(ruleset))) 306 + if (IS_ERR(ruleset)) 307 307 return; 308 308 309 309 rule = mlxsw_sp_acl_rule_lookup(mlxsw_sp, ruleset, f->cookie); 310 - if (!WARN_ON(!rule)) { 310 + if (rule) { 311 311 mlxsw_sp_acl_rule_del(mlxsw_sp, rule); 312 312 mlxsw_sp_acl_rule_destroy(mlxsw_sp, rule); 313 313 }
+2 -1
drivers/net/ethernet/qlogic/qed/qed_cxt.c
··· 422 422 u32 page_sz = p_mgr->clients[ILT_CLI_CDUC].p_size.val; 423 423 u32 cxt_size = CONN_CXT_SIZE(p_hwfn); 424 424 u32 elems_per_page = ILT_PAGE_IN_BYTES(page_sz) / cxt_size; 425 + u32 align = elems_per_page * DQ_RANGE_ALIGN; 425 426 426 - p_conn->cid_count = roundup(p_conn->cid_count, elems_per_page); 427 + p_conn->cid_count = roundup(p_conn->cid_count, align); 427 428 } 428 429 } 429 430
+2 -3
drivers/net/ethernet/qlogic/qed/qed_dev.c
··· 2389 2389 * size/capacity fields are of a u32 type. 2390 2390 */ 2391 2391 if ((cnt_type == QED_CHAIN_CNT_TYPE_U16 && 2392 - chain_size > 0x10000) || 2393 - (cnt_type == QED_CHAIN_CNT_TYPE_U32 && 2394 - chain_size > 0x100000000ULL)) { 2392 + chain_size > ((u32)U16_MAX + 1)) || 2393 + (cnt_type == QED_CHAIN_CNT_TYPE_U32 && chain_size > U32_MAX)) { 2395 2394 DP_NOTICE(cdev, 2396 2395 "The actual chain size (0x%llx) is larger than the maximal possible value\n", 2397 2396 chain_size);
+31
drivers/net/ethernet/qlogic/qed/qed_iscsi.c
··· 190 190 p_init->num_sq_pages_in_ring = p_params->num_sq_pages_in_ring; 191 191 p_init->num_r2tq_pages_in_ring = p_params->num_r2tq_pages_in_ring; 192 192 p_init->num_uhq_pages_in_ring = p_params->num_uhq_pages_in_ring; 193 + p_init->ooo_enable = p_params->ooo_enable; 194 + p_init->ll2_rx_queue_id = p_hwfn->hw_info.resc_start[QED_LL2_QUEUE] + 195 + p_params->ll2_ooo_queue_id; 193 196 p_init->func_params.log_page_size = p_params->log_page_size; 194 197 val = p_params->num_tasks; 195 198 p_init->func_params.num_tasks = cpu_to_le16(val); ··· 789 786 spin_unlock_bh(&p_hwfn->p_iscsi_info->lock); 790 787 } 791 788 789 + void qed_iscsi_free_connection(struct qed_hwfn *p_hwfn, 790 + struct qed_iscsi_conn *p_conn) 791 + { 792 + qed_chain_free(p_hwfn->cdev, &p_conn->xhq); 793 + qed_chain_free(p_hwfn->cdev, &p_conn->uhq); 794 + qed_chain_free(p_hwfn->cdev, &p_conn->r2tq); 795 + dma_free_coherent(&p_hwfn->cdev->pdev->dev, 796 + sizeof(struct tcp_upload_params), 797 + p_conn->tcp_upload_params_virt_addr, 798 + p_conn->tcp_upload_params_phys_addr); 799 + dma_free_coherent(&p_hwfn->cdev->pdev->dev, 800 + sizeof(struct scsi_terminate_extra_params), 801 + p_conn->queue_cnts_virt_addr, 802 + p_conn->queue_cnts_phys_addr); 803 + kfree(p_conn); 804 + } 805 + 792 806 struct qed_iscsi_info *qed_iscsi_alloc(struct qed_hwfn *p_hwfn) 793 807 { 794 808 struct qed_iscsi_info *p_iscsi_info; ··· 827 807 void qed_iscsi_free(struct qed_hwfn *p_hwfn, 828 808 struct qed_iscsi_info *p_iscsi_info) 829 809 { 810 + struct qed_iscsi_conn *p_conn = NULL; 811 + 812 + while (!list_empty(&p_hwfn->p_iscsi_info->free_list)) { 813 + p_conn = list_first_entry(&p_hwfn->p_iscsi_info->free_list, 814 + struct qed_iscsi_conn, list_entry); 815 + if (p_conn) { 816 + list_del(&p_conn->list_entry); 817 + qed_iscsi_free_connection(p_hwfn, p_conn); 818 + } 819 + } 820 + 830 821 kfree(p_iscsi_info); 831 822 } 832 823
+8 -5
drivers/net/ethernet/qlogic/qed/qed_ll2.c
··· 211 211 /* If need to reuse or there's no replacement buffer, repost this */ 212 212 if (rc) 213 213 goto out_post; 214 + dma_unmap_single(&cdev->pdev->dev, buffer->phys_addr, 215 + cdev->ll2->rx_size, DMA_FROM_DEVICE); 214 216 215 217 skb = build_skb(buffer->data, 0); 216 218 if (!skb) { ··· 476 474 static int qed_ll2_rxq_completion_reg(struct qed_hwfn *p_hwfn, 477 475 struct qed_ll2_info *p_ll2_conn, 478 476 union core_rx_cqe_union *p_cqe, 479 - unsigned long lock_flags, 477 + unsigned long *p_lock_flags, 480 478 bool b_last_cqe) 481 479 { 482 480 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; ··· 497 495 "Mismatch between active_descq and the LL2 Rx chain\n"); 498 496 list_add_tail(&p_pkt->list_entry, &p_rx->free_descq); 499 497 500 - spin_unlock_irqrestore(&p_rx->lock, lock_flags); 498 + spin_unlock_irqrestore(&p_rx->lock, *p_lock_flags); 501 499 qed_ll2b_complete_rx_packet(p_hwfn, p_ll2_conn->my_id, 502 500 p_pkt, &p_cqe->rx_cqe_fp, b_last_cqe); 503 - spin_lock_irqsave(&p_rx->lock, lock_flags); 501 + spin_lock_irqsave(&p_rx->lock, *p_lock_flags); 504 502 505 503 return 0; 506 504 } ··· 540 538 break; 541 539 case CORE_RX_CQE_TYPE_REGULAR: 542 540 rc = qed_ll2_rxq_completion_reg(p_hwfn, p_ll2_conn, 543 - cqe, flags, b_last_cqe); 541 + cqe, &flags, 542 + b_last_cqe); 544 543 break; 545 544 default: 546 545 rc = -EIO; ··· 971 968 { 972 969 struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); 973 970 u8 *handle = &hwfn->pf_params.iscsi_pf_params.ll2_ooo_queue_id; 974 - struct qed_ll2_conn ll2_info; 971 + struct qed_ll2_conn ll2_info = { 0 }; 975 972 int rc; 976 973 977 974 ll2_info.conn_type = QED_LL2_TYPE_ISCSI_OOO;
+2
drivers/net/ethernet/qlogic/qed/qed_ooo.c
··· 159 159 if (!p_ooo_info->ooo_history.p_cqes) 160 160 goto no_history_mem; 161 161 162 + p_ooo_info->ooo_history.num_of_cqes = QED_MAX_NUM_OOO_HISTORY_ENTRIES; 163 + 162 164 return p_ooo_info; 163 165 164 166 no_history_mem:
+25 -22
drivers/net/ethernet/smsc/smc91x.c
··· 1535 1535 * Ethtool support 1536 1536 */ 1537 1537 static int 1538 - smc_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) 1538 + smc_ethtool_get_link_ksettings(struct net_device *dev, 1539 + struct ethtool_link_ksettings *cmd) 1539 1540 { 1540 1541 struct smc_local *lp = netdev_priv(dev); 1541 1542 int ret; 1542 1543 1543 - cmd->maxtxpkt = 1; 1544 - cmd->maxrxpkt = 1; 1545 - 1546 1544 if (lp->phy_type != 0) { 1547 1545 spin_lock_irq(&lp->lock); 1548 - ret = mii_ethtool_gset(&lp->mii, cmd); 1546 + ret = mii_ethtool_get_link_ksettings(&lp->mii, cmd); 1549 1547 spin_unlock_irq(&lp->lock); 1550 1548 } else { 1551 - cmd->supported = SUPPORTED_10baseT_Half | 1549 + u32 supported = SUPPORTED_10baseT_Half | 1552 1550 SUPPORTED_10baseT_Full | 1553 1551 SUPPORTED_TP | SUPPORTED_AUI; 1554 1552 1555 1553 if (lp->ctl_rspeed == 10) 1556 - ethtool_cmd_speed_set(cmd, SPEED_10); 1554 + cmd->base.speed = SPEED_10; 1557 1555 else if (lp->ctl_rspeed == 100) 1558 - ethtool_cmd_speed_set(cmd, SPEED_100); 1556 + cmd->base.speed = SPEED_100; 1559 1557 1560 - cmd->autoneg = AUTONEG_DISABLE; 1561 - cmd->transceiver = XCVR_INTERNAL; 1562 - cmd->port = 0; 1563 - cmd->duplex = lp->tcr_cur_mode & TCR_SWFDUP ? DUPLEX_FULL : DUPLEX_HALF; 1558 + cmd->base.autoneg = AUTONEG_DISABLE; 1559 + cmd->base.port = 0; 1560 + cmd->base.duplex = lp->tcr_cur_mode & TCR_SWFDUP ? 1561 + DUPLEX_FULL : DUPLEX_HALF; 1562 + 1563 + ethtool_convert_legacy_u32_to_link_mode( 1564 + cmd->link_modes.supported, supported); 1564 1565 1565 1566 ret = 0; 1566 1567 } ··· 1570 1569 } 1571 1570 1572 1571 static int 1573 - smc_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd) 1572 + smc_ethtool_set_link_ksettings(struct net_device *dev, 1573 + const struct ethtool_link_ksettings *cmd) 1574 1574 { 1575 1575 struct smc_local *lp = netdev_priv(dev); 1576 1576 int ret; 1577 1577 1578 1578 if (lp->phy_type != 0) { 1579 1579 spin_lock_irq(&lp->lock); 1580 - ret = mii_ethtool_sset(&lp->mii, cmd); 1580 + ret = mii_ethtool_set_link_ksettings(&lp->mii, cmd); 1581 1581 spin_unlock_irq(&lp->lock); 1582 1582 } else { 1583 - if (cmd->autoneg != AUTONEG_DISABLE || 1584 - cmd->speed != SPEED_10 || 1585 - (cmd->duplex != DUPLEX_HALF && cmd->duplex != DUPLEX_FULL) || 1586 - (cmd->port != PORT_TP && cmd->port != PORT_AUI)) 1583 + if (cmd->base.autoneg != AUTONEG_DISABLE || 1584 + cmd->base.speed != SPEED_10 || 1585 + (cmd->base.duplex != DUPLEX_HALF && 1586 + cmd->base.duplex != DUPLEX_FULL) || 1587 + (cmd->base.port != PORT_TP && cmd->base.port != PORT_AUI)) 1587 1588 return -EINVAL; 1588 1589 1589 - // lp->port = cmd->port; 1590 - lp->ctl_rfduplx = cmd->duplex == DUPLEX_FULL; 1590 + // lp->port = cmd->base.port; 1591 + lp->ctl_rfduplx = cmd->base.duplex == DUPLEX_FULL; 1591 1592 1592 1593 // if (netif_running(dev)) 1593 1594 // smc_set_port(dev); ··· 1747 1744 1748 1745 1749 1746 static const struct ethtool_ops smc_ethtool_ops = { 1750 - .get_settings = smc_ethtool_getsettings, 1751 - .set_settings = smc_ethtool_setsettings, 1752 1747 .get_drvinfo = smc_ethtool_getdrvinfo, 1753 1748 1754 1749 .get_msglevel = smc_ethtool_getmsglevel, ··· 1756 1755 .get_eeprom_len = smc_ethtool_geteeprom_len, 1757 1756 .get_eeprom = smc_ethtool_geteeprom, 1758 1757 .set_eeprom = smc_ethtool_seteeprom, 1758 + .get_link_ksettings = smc_ethtool_get_link_ksettings, 1759 + .set_link_ksettings = smc_ethtool_set_link_ksettings, 1759 1760 }; 1760 1761 1761 1762 static const struct net_device_ops smc_netdev_ops = {
+2 -1
drivers/net/hyperv/hyperv_net.h
··· 700 700 701 701 u32 tx_checksum_mask; 702 702 703 + u32 tx_send_table[VRSS_SEND_TAB_SIZE]; 704 + 703 705 /* Ethtool settings */ 704 706 u8 duplex; 705 707 u32 speed; ··· 759 757 760 758 struct nvsp_message revoke_packet; 761 759 762 - u32 send_table[VRSS_SEND_TAB_SIZE]; 763 760 u32 max_chn; 764 761 u32 num_chn; 765 762 spinlock_t sc_lock; /* Protects num_sc_offered variable */
+2 -6
drivers/net/hyperv/netvsc.c
··· 1136 1136 static void netvsc_send_table(struct hv_device *hdev, 1137 1137 struct nvsp_message *nvmsg) 1138 1138 { 1139 - struct netvsc_device *nvscdev; 1140 1139 struct net_device *ndev = hv_get_drvdata(hdev); 1140 + struct net_device_context *net_device_ctx = netdev_priv(ndev); 1141 1141 int i; 1142 1142 u32 count, *tab; 1143 - 1144 - nvscdev = get_outbound_net_device(hdev); 1145 - if (!nvscdev) 1146 - return; 1147 1143 1148 1144 count = nvmsg->msg.v5_msg.send_table.count; 1149 1145 if (count != VRSS_SEND_TAB_SIZE) { ··· 1151 1155 nvmsg->msg.v5_msg.send_table.offset); 1152 1156 1153 1157 for (i = 0; i < count; i++) 1154 - nvscdev->send_table[i] = tab[i]; 1158 + net_device_ctx->tx_send_table[i] = tab[i]; 1155 1159 } 1156 1160 1157 1161 static void netvsc_send_vf(struct net_device_context *net_device_ctx,
+3 -8
drivers/net/hyperv/netvsc_drv.c
··· 206 206 void *accel_priv, select_queue_fallback_t fallback) 207 207 { 208 208 struct net_device_context *net_device_ctx = netdev_priv(ndev); 209 - struct netvsc_device *nvsc_dev = net_device_ctx->nvdev; 209 + unsigned int num_tx_queues = ndev->real_num_tx_queues; 210 210 struct sock *sk = skb->sk; 211 211 int q_idx = sk_tx_queue_get(sk); 212 212 213 - if (q_idx < 0 || skb->ooo_okay || 214 - q_idx >= ndev->real_num_tx_queues) { 213 + if (q_idx < 0 || skb->ooo_okay || q_idx >= num_tx_queues) { 215 214 u16 hash = __skb_tx_hash(ndev, skb, VRSS_SEND_TAB_SIZE); 216 215 int new_idx; 217 216 218 - new_idx = nvsc_dev->send_table[hash] 219 - % nvsc_dev->num_chn; 217 + new_idx = net_device_ctx->tx_send_table[hash] % num_tx_queues; 220 218 221 219 if (q_idx != new_idx && sk && 222 220 sk_fullsock(sk) && rcu_access_pointer(sk->sk_dst_cache)) ··· 222 224 223 225 q_idx = new_idx; 224 226 } 225 - 226 - if (unlikely(!nvsc_dev->chan_table[q_idx].channel)) 227 - q_idx = 0; 228 227 229 228 return q_idx; 230 229 }
-15
drivers/net/phy/marvell.c
··· 1883 1883 return m88e1510_hwmon_probe(phydev); 1884 1884 } 1885 1885 1886 - static void marvell_remove(struct phy_device *phydev) 1887 - { 1888 - #ifdef CONFIG_HWMON 1889 - 1890 - struct marvell_priv *priv = phydev->priv; 1891 - 1892 - if (priv && priv->hwmon_dev) 1893 - hwmon_device_unregister(priv->hwmon_dev); 1894 - #endif 1895 - } 1896 - 1897 1886 static struct phy_driver marvell_drivers[] = { 1898 1887 { 1899 1888 .phy_id = MARVELL_PHY_ID_88E1101, ··· 1963 1974 .features = PHY_GBIT_FEATURES, 1964 1975 .flags = PHY_HAS_INTERRUPT, 1965 1976 .probe = &m88e1121_probe, 1966 - .remove = &marvell_remove, 1967 1977 .config_init = &m88e1121_config_init, 1968 1978 .config_aneg = &m88e1121_config_aneg, 1969 1979 .read_status = &marvell_read_status, ··· 2075 2087 .features = PHY_GBIT_FEATURES | SUPPORTED_FIBRE, 2076 2088 .flags = PHY_HAS_INTERRUPT, 2077 2089 .probe = &m88e1510_probe, 2078 - .remove = &marvell_remove, 2079 2090 .config_init = &m88e1510_config_init, 2080 2091 .config_aneg = &m88e1510_config_aneg, 2081 2092 .read_status = &marvell_read_status, ··· 2096 2109 .features = PHY_GBIT_FEATURES, 2097 2110 .flags = PHY_HAS_INTERRUPT, 2098 2111 .probe = m88e1510_probe, 2099 - .remove = &marvell_remove, 2100 2112 .config_init = &marvell_config_init, 2101 2113 .config_aneg = &m88e1510_config_aneg, 2102 2114 .read_status = &marvell_read_status, ··· 2113 2127 .phy_id_mask = MARVELL_PHY_ID_MASK, 2114 2128 .name = "Marvell 88E1545", 2115 2129 .probe = m88e1510_probe, 2116 - .remove = &marvell_remove, 2117 2130 .features = PHY_GBIT_FEATURES, 2118 2131 .flags = PHY_HAS_INTERRUPT, 2119 2132 .config_init = &marvell_config_init,
+1 -1
drivers/net/phy/phy_device.c
··· 1864 1864 .phy_id = 0xffffffff, 1865 1865 .phy_id_mask = 0xffffffff, 1866 1866 .name = "Generic PHY", 1867 - .soft_reset = genphy_soft_reset, 1867 + .soft_reset = genphy_no_soft_reset, 1868 1868 .config_init = genphy_config_init, 1869 1869 .features = PHY_GBIT_FEATURES | SUPPORTED_MII | 1870 1870 SUPPORTED_AUI | SUPPORTED_FIBRE |
+2 -1
drivers/net/phy/spi_ks8995.c
··· 491 491 if (err) 492 492 return err; 493 493 494 - ks->regs_attr.size = ks->chip->regs_size; 495 494 memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr)); 495 + ks->regs_attr.size = ks->chip->regs_size; 496 496 497 497 err = ks8995_reset(ks); 498 498 if (err) 499 499 return err; 500 500 501 + sysfs_attr_init(&ks->regs_attr.attr); 501 502 err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr); 502 503 if (err) { 503 504 dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
+1
drivers/net/team/team.c
··· 2072 2072 static void team_setup(struct net_device *dev) 2073 2073 { 2074 2074 ether_setup(dev); 2075 + dev->max_mtu = ETH_MAX_MTU; 2075 2076 2076 2077 dev->netdev_ops = &team_netdev_ops; 2077 2078 dev->ethtool_ops = &team_ethtool_ops;
+15 -4
drivers/net/tun.c
··· 822 822 /* Net device open. */ 823 823 static int tun_net_open(struct net_device *dev) 824 824 { 825 + struct tun_struct *tun = netdev_priv(dev); 826 + int i; 827 + 825 828 netif_tx_start_all_queues(dev); 829 + 830 + for (i = 0; i < tun->numqueues; i++) { 831 + struct tun_file *tfile; 832 + 833 + tfile = rtnl_dereference(tun->tfiles[i]); 834 + tfile->socket.sk->sk_write_space(tfile->socket.sk); 835 + } 836 + 826 837 return 0; 827 838 } 828 839 ··· 1114 1103 if (!skb_array_empty(&tfile->tx_array)) 1115 1104 mask |= POLLIN | POLLRDNORM; 1116 1105 1117 - if (sock_writeable(sk) || 1118 - (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) && 1119 - sock_writeable(sk))) 1106 + if (tun->dev->flags & IFF_UP && 1107 + (sock_writeable(sk) || 1108 + (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) && 1109 + sock_writeable(sk)))) 1120 1110 mask |= POLLOUT | POLLWRNORM; 1121 1111 1122 1112 if (tun->dev->reg_state != NETREG_REGISTERED) ··· 2582 2570 int ret = 0; 2583 2571 2584 2572 pr_info("%s, %s\n", DRV_DESCRIPTION, DRV_VERSION); 2585 - pr_info("%s\n", DRV_COPYRIGHT); 2586 2573 2587 2574 ret = rtnl_link_register(&tun_link_ops); 2588 2575 if (ret) {
+2 -1
drivers/net/vrf.c
··· 340 340 341 341 static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev) 342 342 { 343 + int len = skb->len; 343 344 netdev_tx_t ret = is_ip_tx_frame(skb, dev); 344 345 345 346 if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) { ··· 348 347 349 348 u64_stats_update_begin(&dstats->syncp); 350 349 dstats->tx_pkts++; 351 - dstats->tx_bytes += skb->len; 350 + dstats->tx_bytes += len; 352 351 u64_stats_update_end(&dstats->syncp); 353 352 } else { 354 353 this_cpu_inc(dev->dstats->tx_drps);
+40 -33
drivers/net/vxlan.c
··· 2976 2976 return 0; 2977 2977 } 2978 2978 2979 + static int __vxlan_dev_create(struct net *net, struct net_device *dev, 2980 + struct vxlan_config *conf) 2981 + { 2982 + struct vxlan_net *vn = net_generic(net, vxlan_net_id); 2983 + struct vxlan_dev *vxlan = netdev_priv(dev); 2984 + int err; 2985 + 2986 + err = vxlan_dev_configure(net, dev, conf, false); 2987 + if (err) 2988 + return err; 2989 + 2990 + dev->ethtool_ops = &vxlan_ethtool_ops; 2991 + 2992 + /* create an fdb entry for a valid default destination */ 2993 + if (!vxlan_addr_any(&vxlan->default_dst.remote_ip)) { 2994 + err = vxlan_fdb_create(vxlan, all_zeros_mac, 2995 + &vxlan->default_dst.remote_ip, 2996 + NUD_REACHABLE | NUD_PERMANENT, 2997 + NLM_F_EXCL | NLM_F_CREATE, 2998 + vxlan->cfg.dst_port, 2999 + vxlan->default_dst.remote_vni, 3000 + vxlan->default_dst.remote_vni, 3001 + vxlan->default_dst.remote_ifindex, 3002 + NTF_SELF); 3003 + if (err) 3004 + return err; 3005 + } 3006 + 3007 + err = register_netdevice(dev); 3008 + if (err) { 3009 + vxlan_fdb_delete_default(vxlan, vxlan->default_dst.remote_vni); 3010 + return err; 3011 + } 3012 + 3013 + list_add(&vxlan->next, &vn->vxlan_list); 3014 + return 0; 3015 + } 3016 + 2979 3017 static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], 2980 3018 struct net_device *dev, struct vxlan_config *conf, 2981 3019 bool changelink) ··· 3210 3172 static int vxlan_newlink(struct net *src_net, struct net_device *dev, 3211 3173 struct nlattr *tb[], struct nlattr *data[]) 3212 3174 { 3213 - struct vxlan_net *vn = net_generic(src_net, vxlan_net_id); 3214 - struct vxlan_dev *vxlan = netdev_priv(dev); 3215 3175 struct vxlan_config conf; 3216 3176 int err; 3217 3177 ··· 3217 3181 if (err) 3218 3182 return err; 3219 3183 3220 - err = vxlan_dev_configure(src_net, dev, &conf, false); 3221 - if (err) 3222 - return err; 3223 - 3224 - dev->ethtool_ops = &vxlan_ethtool_ops; 3225 - 3226 - /* create an fdb entry for a valid default destination */ 3227 - if (!vxlan_addr_any(&vxlan->default_dst.remote_ip)) { 3228 - err = vxlan_fdb_create(vxlan, all_zeros_mac, 3229 - &vxlan->default_dst.remote_ip, 3230 - NUD_REACHABLE | NUD_PERMANENT, 3231 - NLM_F_EXCL | NLM_F_CREATE, 3232 - vxlan->cfg.dst_port, 3233 - vxlan->default_dst.remote_vni, 3234 - vxlan->default_dst.remote_vni, 3235 - vxlan->default_dst.remote_ifindex, 3236 - NTF_SELF); 3237 - if (err) 3238 - return err; 3239 - } 3240 - 3241 - err = register_netdevice(dev); 3242 - if (err) { 3243 - vxlan_fdb_delete_default(vxlan, vxlan->default_dst.remote_vni); 3244 - return err; 3245 - } 3246 - 3247 - list_add(&vxlan->next, &vn->vxlan_list); 3248 - 3249 - return 0; 3184 + return __vxlan_dev_create(src_net, dev, &conf); 3250 3185 } 3251 3186 3252 3187 static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], ··· 3447 3440 if (IS_ERR(dev)) 3448 3441 return dev; 3449 3442 3450 - err = vxlan_dev_configure(net, dev, conf, false); 3443 + err = __vxlan_dev_create(net, dev, conf); 3451 3444 if (err < 0) { 3452 3445 free_netdev(dev); 3453 3446 return ERR_PTR(err);
+2 -2
drivers/net/wan/fsl_ucc_hdlc.c
··· 381 381 /* set bd status and length */ 382 382 bd_status = (bd_status & T_W_S) | T_R_S | T_I_S | T_L_S | T_TC_S; 383 383 384 - iowrite16be(bd_status, &bd->status); 385 384 iowrite16be(skb->len, &bd->length); 385 + iowrite16be(bd_status, &bd->status); 386 386 387 387 /* Move to next BD in the ring */ 388 388 if (!(bd_status & T_W_S)) ··· 457 457 struct sk_buff *skb; 458 458 hdlc_device *hdlc = dev_to_hdlc(dev); 459 459 struct qe_bd *bd; 460 - u32 bd_status; 460 + u16 bd_status; 461 461 u16 length, howmany = 0; 462 462 u8 *bdbuffer; 463 463 int i;
+3
drivers/net/wimax/i2400m/usb.c
··· 467 467 struct i2400mu *i2400mu; 468 468 struct usb_device *usb_dev = interface_to_usbdev(iface); 469 469 470 + if (iface->cur_altsetting->desc.bNumEndpoints < 4) 471 + return -ENODEV; 472 + 470 473 if (usb_dev->speed != USB_SPEED_HIGH) 471 474 dev_err(dev, "device not connected as high speed\n"); 472 475
+17 -9
drivers/net/xen-netback/interface.c
··· 165 165 { 166 166 struct xenvif *vif = netdev_priv(dev); 167 167 struct xenvif_queue *queue = NULL; 168 - unsigned int num_queues = vif->num_queues; 168 + unsigned int num_queues; 169 169 u16 index; 170 170 struct xenvif_rx_cb *cb; 171 171 172 172 BUG_ON(skb->dev != dev); 173 173 174 - /* Drop the packet if queues are not set up */ 174 + /* Drop the packet if queues are not set up. 175 + * This handler should be called inside an RCU read section 176 + * so we don't need to enter it here explicitly. 177 + */ 178 + num_queues = READ_ONCE(vif->num_queues); 175 179 if (num_queues < 1) 176 180 goto drop; 177 181 ··· 226 222 { 227 223 struct xenvif *vif = netdev_priv(dev); 228 224 struct xenvif_queue *queue = NULL; 225 + unsigned int num_queues; 229 226 u64 rx_bytes = 0; 230 227 u64 rx_packets = 0; 231 228 u64 tx_bytes = 0; 232 229 u64 tx_packets = 0; 233 230 unsigned int index; 234 231 235 - spin_lock(&vif->lock); 236 - if (vif->queues == NULL) 237 - goto out; 232 + rcu_read_lock(); 233 + num_queues = READ_ONCE(vif->num_queues); 238 234 239 235 /* Aggregate tx and rx stats from each queue */ 240 - for (index = 0; index < vif->num_queues; ++index) { 236 + for (index = 0; index < num_queues; ++index) { 241 237 queue = &vif->queues[index]; 242 238 rx_bytes += queue->stats.rx_bytes; 243 239 rx_packets += queue->stats.rx_packets; ··· 245 241 tx_packets += queue->stats.tx_packets; 246 242 } 247 243 248 - out: 249 - spin_unlock(&vif->lock); 244 + rcu_read_unlock(); 250 245 251 246 vif->dev->stats.rx_bytes = rx_bytes; 252 247 vif->dev->stats.rx_packets = rx_packets; ··· 381 378 struct ethtool_stats *stats, u64 * data) 382 379 { 383 380 struct xenvif *vif = netdev_priv(dev); 384 - unsigned int num_queues = vif->num_queues; 381 + unsigned int num_queues; 385 382 int i; 386 383 unsigned int queue_index; 384 + 385 + rcu_read_lock(); 386 + num_queues = READ_ONCE(vif->num_queues); 387 387 388 388 for (i = 0; i < ARRAY_SIZE(xenvif_stats); i++) { 389 389 unsigned long accum = 0; ··· 396 390 } 397 391 data[i] = accum; 398 392 } 393 + 394 + rcu_read_unlock(); 399 395 } 400 396 401 397 static void xenvif_get_strings(struct net_device *dev, u32 stringset, u8 * data)
+1 -1
drivers/net/xen-netback/netback.c
··· 214 214 netdev_err(vif->dev, "fatal error; disabling device\n"); 215 215 vif->disabled = true; 216 216 /* Disable the vif from queue 0's kthread */ 217 - if (vif->queues) 217 + if (vif->num_queues) 218 218 xenvif_kick_thread(&vif->queues[0]); 219 219 } 220 220
+10 -10
drivers/net/xen-netback/xenbus.c
··· 495 495 struct xenvif *vif = be->vif; 496 496 497 497 if (vif) { 498 + unsigned int num_queues = vif->num_queues; 498 499 unsigned int queue_index; 499 - struct xenvif_queue *queues; 500 500 501 501 xen_unregister_watchers(vif); 502 502 #ifdef CONFIG_DEBUG_FS 503 503 xenvif_debugfs_delif(vif); 504 504 #endif /* CONFIG_DEBUG_FS */ 505 505 xenvif_disconnect_data(vif); 506 - for (queue_index = 0; 507 - queue_index < vif->num_queues; 508 - ++queue_index) 506 + 507 + /* At this point some of the handlers may still be active 508 + * so we need to have additional synchronization here. 509 + */ 510 + vif->num_queues = 0; 511 + synchronize_net(); 512 + 513 + for (queue_index = 0; queue_index < num_queues; ++queue_index) 509 514 xenvif_deinit_queue(&vif->queues[queue_index]); 510 515 511 - spin_lock(&vif->lock); 512 - queues = vif->queues; 513 - vif->num_queues = 0; 516 + vfree(vif->queues); 514 517 vif->queues = NULL; 515 - spin_unlock(&vif->lock); 516 - 517 - vfree(queues); 518 518 519 519 xenvif_disconnect_ctrl(vif); 520 520 }
+2 -47
drivers/platform/x86/asus-nb-wmi.c
··· 103 103 .wapf = 2, 104 104 }; 105 105 106 - static struct quirk_entry quirk_no_rfkill = { 107 - .no_rfkill = true, 108 - }; 109 - 110 - static struct quirk_entry quirk_no_rfkill_wapf4 = { 111 - .wapf = 4, 112 - .no_rfkill = true, 113 - }; 114 - 115 106 static struct quirk_entry quirk_asus_ux303ub = { 116 107 .wmi_backlight_native = true, 117 108 }; ··· 185 194 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 186 195 DMI_MATCH(DMI_PRODUCT_NAME, "X456UA"), 187 196 }, 188 - .driver_data = &quirk_no_rfkill_wapf4, 197 + .driver_data = &quirk_asus_wapf4, 189 198 }, 190 199 { 191 200 .callback = dmi_matched, ··· 194 203 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 195 204 DMI_MATCH(DMI_PRODUCT_NAME, "X456UF"), 196 205 }, 197 - .driver_data = &quirk_no_rfkill_wapf4, 206 + .driver_data = &quirk_asus_wapf4, 198 207 }, 199 208 { 200 209 .callback = dmi_matched, ··· 357 366 DMI_MATCH(DMI_PRODUCT_NAME, "X200CA"), 358 367 }, 359 368 .driver_data = &quirk_asus_x200ca, 360 - }, 361 - { 362 - .callback = dmi_matched, 363 - .ident = "ASUSTeK COMPUTER INC. X555UB", 364 - .matches = { 365 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 366 - DMI_MATCH(DMI_PRODUCT_NAME, "X555UB"), 367 - }, 368 - .driver_data = &quirk_no_rfkill, 369 - }, 370 - { 371 - .callback = dmi_matched, 372 - .ident = "ASUSTeK COMPUTER INC. N552VW", 373 - .matches = { 374 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 375 - DMI_MATCH(DMI_PRODUCT_NAME, "N552VW"), 376 - }, 377 - .driver_data = &quirk_no_rfkill, 378 - }, 379 - { 380 - .callback = dmi_matched, 381 - .ident = "ASUSTeK COMPUTER INC. U303LB", 382 - .matches = { 383 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 384 - DMI_MATCH(DMI_PRODUCT_NAME, "U303LB"), 385 - }, 386 - .driver_data = &quirk_no_rfkill, 387 - }, 388 - { 389 - .callback = dmi_matched, 390 - .ident = "ASUSTeK COMPUTER INC. Z550MA", 391 - .matches = { 392 - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 393 - DMI_MATCH(DMI_PRODUCT_NAME, "Z550MA"), 394 - }, 395 - .driver_data = &quirk_no_rfkill, 396 369 }, 397 370 { 398 371 .callback = dmi_matched,
+17 -5
drivers/platform/x86/asus-wmi.c
··· 159 159 #define USB_INTEL_XUSB2PR 0xD0 160 160 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 161 161 162 + static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; 163 + 162 164 struct bios_args { 163 165 u32 arg0; 164 166 u32 arg1; ··· 2053 2051 return 0; 2054 2052 } 2055 2053 2054 + static bool ashs_present(void) 2055 + { 2056 + int i = 0; 2057 + while (ashs_ids[i]) { 2058 + if (acpi_dev_found(ashs_ids[i++])) 2059 + return true; 2060 + } 2061 + return false; 2062 + } 2063 + 2056 2064 /* 2057 2065 * WMI Driver 2058 2066 */ ··· 2107 2095 if (err) 2108 2096 goto fail_leds; 2109 2097 2110 - if (!asus->driver->quirks->no_rfkill) { 2098 + asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result); 2099 + if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT)) 2100 + asus->driver->wlan_ctrl_by_user = 1; 2101 + 2102 + if (!(asus->driver->wlan_ctrl_by_user && ashs_present())) { 2111 2103 err = asus_wmi_rfkill_init(asus); 2112 2104 if (err) 2113 2105 goto fail_rfkill; ··· 2149 2133 err = asus_wmi_debugfs_init(asus); 2150 2134 if (err) 2151 2135 goto fail_debugfs; 2152 - 2153 - asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result); 2154 - if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT)) 2155 - asus->driver->wlan_ctrl_by_user = 1; 2156 2136 2157 2137 return 0; 2158 2138
-1
drivers/platform/x86/asus-wmi.h
··· 39 39 struct asus_wmi; 40 40 41 41 struct quirk_entry { 42 - bool no_rfkill; 43 42 bool hotplug_wireless; 44 43 bool scalar_panel_brightness; 45 44 bool store_backlight_power;
+222 -229
drivers/platform/x86/fujitsu-laptop.c
··· 78 78 79 79 #define FUJITSU_LCD_N_LEVELS 8 80 80 81 - #define ACPI_FUJITSU_CLASS "fujitsu" 82 - #define ACPI_FUJITSU_HID "FUJ02B1" 83 - #define ACPI_FUJITSU_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver" 84 - #define ACPI_FUJITSU_DEVICE_NAME "Fujitsu FUJ02B1" 85 - #define ACPI_FUJITSU_HOTKEY_HID "FUJ02E3" 86 - #define ACPI_FUJITSU_HOTKEY_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver" 87 - #define ACPI_FUJITSU_HOTKEY_DEVICE_NAME "Fujitsu FUJ02E3" 81 + #define ACPI_FUJITSU_CLASS "fujitsu" 82 + #define ACPI_FUJITSU_BL_HID "FUJ02B1" 83 + #define ACPI_FUJITSU_BL_DRIVER_NAME "Fujitsu laptop FUJ02B1 ACPI brightness driver" 84 + #define ACPI_FUJITSU_BL_DEVICE_NAME "Fujitsu FUJ02B1" 85 + #define ACPI_FUJITSU_LAPTOP_HID "FUJ02E3" 86 + #define ACPI_FUJITSU_LAPTOP_DRIVER_NAME "Fujitsu laptop FUJ02E3 ACPI hotkeys driver" 87 + #define ACPI_FUJITSU_LAPTOP_DEVICE_NAME "Fujitsu FUJ02E3" 88 88 89 89 #define ACPI_FUJITSU_NOTIFY_CODE1 0x80 90 90 91 91 /* FUNC interface - command values */ 92 - #define FUNC_RFKILL 0x1000 92 + #define FUNC_FLAGS 0x1000 93 93 #define FUNC_LEDS 0x1001 94 94 #define FUNC_BUTTONS 0x1002 95 95 #define FUNC_BACKLIGHT 0x1004 96 96 97 97 /* FUNC interface - responses */ 98 98 #define UNSUPPORTED_CMD 0x80000000 99 + 100 + /* FUNC interface - status flags */ 101 + #define FLAG_RFKILL 0x020 102 + #define FLAG_LID 0x100 103 + #define FLAG_DOCK 0x200 99 104 100 105 #if IS_ENABLED(CONFIG_LEDS_CLASS) 101 106 /* FUNC interface - LED control */ ··· 141 136 #endif 142 137 143 138 /* Device controlling the backlight and associated keys */ 144 - struct fujitsu_t { 139 + struct fujitsu_bl { 145 140 acpi_handle acpi_handle; 146 141 struct acpi_device *dev; 147 142 struct input_dev *input; ··· 155 150 unsigned int brightness_level; 156 151 }; 157 152 158 - static struct fujitsu_t *fujitsu; 153 + static struct fujitsu_bl *fujitsu_bl; 159 154 static int use_alt_lcd_levels = -1; 160 155 static int disable_brightness_adjust = -1; 161 156 162 - /* Device used to access other hotkeys on the laptop */ 163 - struct fujitsu_hotkey_t { 157 + /* Device used to access hotkeys and other features on the laptop */ 158 + struct fujitsu_laptop { 164 159 acpi_handle acpi_handle; 165 160 struct acpi_device *dev; 166 161 struct input_dev *input; ··· 168 163 struct platform_device *pf_device; 169 164 struct kfifo fifo; 170 165 spinlock_t fifo_lock; 171 - int rfkill_supported; 172 - int rfkill_state; 166 + int flags_supported; 167 + int flags_state; 173 168 int logolamp_registered; 174 169 int kblamps_registered; 175 170 int radio_led_registered; 176 171 int eco_led_registered; 177 172 }; 178 173 179 - static struct fujitsu_hotkey_t *fujitsu_hotkey; 180 - 181 - static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event); 174 + static struct fujitsu_laptop *fujitsu_laptop; 182 175 183 176 #if IS_ENABLED(CONFIG_LEDS_CLASS) 184 177 static enum led_brightness logolamp_get(struct led_classdev *cdev); ··· 225 222 static u32 dbg_level = 0x03; 226 223 #endif 227 224 228 - static void acpi_fujitsu_notify(struct acpi_device *device, u32 event); 229 - 230 225 /* Fujitsu ACPI interface function */ 231 226 232 227 static int call_fext_func(int cmd, int arg0, int arg1, int arg2) ··· 240 239 unsigned long long value; 241 240 acpi_handle handle = NULL; 242 241 243 - status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle); 242 + status = acpi_get_handle(fujitsu_laptop->acpi_handle, "FUNC", &handle); 244 243 if (ACPI_FAILURE(status)) { 245 244 vdbg_printk(FUJLAPTOP_DBG_ERROR, 246 245 "FUNC interface is not present\n"); ··· 301 300 enum led_brightness brightness) 302 301 { 303 302 if (brightness >= LED_FULL) 304 - return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON); 303 + return call_fext_func(FUNC_FLAGS, 0x5, RADIO_LED_ON, RADIO_LED_ON); 305 304 else 306 - return call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0); 305 + return call_fext_func(FUNC_FLAGS, 0x5, RADIO_LED_ON, 0x0); 307 306 } 308 307 309 308 static int eco_led_set(struct led_classdev *cdev, ··· 347 346 { 348 347 enum led_brightness brightness = LED_OFF; 349 348 350 - if (call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0) & RADIO_LED_ON) 349 + if (call_fext_func(FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON) 351 350 brightness = LED_FULL; 352 351 353 352 return brightness; ··· 374 373 vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBLL [%d]\n", 375 374 level); 376 375 377 - if (level < 0 || level >= fujitsu->max_brightness) 376 + if (level < 0 || level >= fujitsu_bl->max_brightness) 378 377 return -EINVAL; 379 378 380 - status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle); 379 + status = acpi_get_handle(fujitsu_bl->acpi_handle, "SBLL", &handle); 381 380 if (ACPI_FAILURE(status)) { 382 381 vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n"); 383 382 return -ENODEV; ··· 399 398 vdbg_printk(FUJLAPTOP_DBG_TRACE, "set lcd level via SBL2 [%d]\n", 400 399 level); 401 400 402 - if (level < 0 || level >= fujitsu->max_brightness) 401 + if (level < 0 || level >= fujitsu_bl->max_brightness) 403 402 return -EINVAL; 404 403 405 - status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle); 404 + status = acpi_get_handle(fujitsu_bl->acpi_handle, "SBL2", &handle); 406 405 if (ACPI_FAILURE(status)) { 407 406 vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n"); 408 407 return -ENODEV; ··· 422 421 423 422 vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLL\n"); 424 423 425 - status = 426 - acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state); 424 + status = acpi_evaluate_integer(fujitsu_bl->acpi_handle, "GBLL", NULL, 425 + &state); 427 426 if (ACPI_FAILURE(status)) 428 427 return 0; 429 428 430 - fujitsu->brightness_level = state & 0x0fffffff; 429 + fujitsu_bl->brightness_level = state & 0x0fffffff; 431 430 432 431 if (state & 0x80000000) 433 - fujitsu->brightness_changed = 1; 432 + fujitsu_bl->brightness_changed = 1; 434 433 else 435 - fujitsu->brightness_changed = 0; 434 + fujitsu_bl->brightness_changed = 0; 436 435 437 - return fujitsu->brightness_level; 436 + return fujitsu_bl->brightness_level; 438 437 } 439 438 440 439 static int get_max_brightness(void) ··· 444 443 445 444 vdbg_printk(FUJLAPTOP_DBG_TRACE, "get max lcd level via RBLL\n"); 446 445 447 - status = 448 - acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state); 446 + status = acpi_evaluate_integer(fujitsu_bl->acpi_handle, "RBLL", NULL, 447 + &state); 449 448 if (ACPI_FAILURE(status)) 450 449 return -1; 451 450 452 - fujitsu->max_brightness = state; 451 + fujitsu_bl->max_brightness = state; 453 452 454 - return fujitsu->max_brightness; 453 + return fujitsu_bl->max_brightness; 455 454 } 456 455 457 456 /* Backlight device stuff */ ··· 484 483 return ret; 485 484 } 486 485 487 - static const struct backlight_ops fujitsubl_ops = { 486 + static const struct backlight_ops fujitsu_bl_ops = { 488 487 .get_brightness = bl_get_brightness, 489 488 .update_status = bl_update_status, 490 489 }; ··· 512 511 513 512 int ret; 514 513 515 - ret = fujitsu->brightness_changed; 514 + ret = fujitsu_bl->brightness_changed; 516 515 if (ret < 0) 517 516 return ret; 518 517 ··· 540 539 int level, ret; 541 540 542 541 if (sscanf(buf, "%i", &level) != 1 543 - || (level < 0 || level >= fujitsu->max_brightness)) 542 + || (level < 0 || level >= fujitsu_bl->max_brightness)) 544 543 return -EINVAL; 545 544 546 545 if (use_alt_lcd_levels) ··· 568 567 show_lid_state(struct device *dev, 569 568 struct device_attribute *attr, char *buf) 570 569 { 571 - if (!(fujitsu_hotkey->rfkill_supported & 0x100)) 570 + if (!(fujitsu_laptop->flags_supported & FLAG_LID)) 572 571 return sprintf(buf, "unknown\n"); 573 - if (fujitsu_hotkey->rfkill_state & 0x100) 572 + if (fujitsu_laptop->flags_state & FLAG_LID) 574 573 return sprintf(buf, "open\n"); 575 574 else 576 575 return sprintf(buf, "closed\n"); ··· 580 579 show_dock_state(struct device *dev, 581 580 struct device_attribute *attr, char *buf) 582 581 { 583 - if (!(fujitsu_hotkey->rfkill_supported & 0x200)) 582 + if (!(fujitsu_laptop->flags_supported & FLAG_DOCK)) 584 583 return sprintf(buf, "unknown\n"); 585 - if (fujitsu_hotkey->rfkill_state & 0x200) 584 + if (fujitsu_laptop->flags_state & FLAG_DOCK) 586 585 return sprintf(buf, "docked\n"); 587 586 else 588 587 return sprintf(buf, "undocked\n"); ··· 592 591 show_radios_state(struct device *dev, 593 592 struct device_attribute *attr, char *buf) 594 593 { 595 - if (!(fujitsu_hotkey->rfkill_supported & 0x20)) 594 + if (!(fujitsu_laptop->flags_supported & FLAG_RFKILL)) 596 595 return sprintf(buf, "unknown\n"); 597 - if (fujitsu_hotkey->rfkill_state & 0x20) 596 + if (fujitsu_laptop->flags_state & FLAG_RFKILL) 598 597 return sprintf(buf, "on\n"); 599 598 else 600 599 return sprintf(buf, "killed\n"); ··· 608 607 static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store); 609 608 static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store); 610 609 611 - static struct attribute *fujitsupf_attributes[] = { 610 + static struct attribute *fujitsu_pf_attributes[] = { 612 611 &dev_attr_brightness_changed.attr, 613 612 &dev_attr_max_brightness.attr, 614 613 &dev_attr_lcd_level.attr, ··· 618 617 NULL 619 618 }; 620 619 621 - static struct attribute_group fujitsupf_attribute_group = { 622 - .attrs = fujitsupf_attributes 620 + static struct attribute_group fujitsu_pf_attribute_group = { 621 + .attrs = fujitsu_pf_attributes 623 622 }; 624 623 625 - static struct platform_driver fujitsupf_driver = { 624 + static struct platform_driver fujitsu_pf_driver = { 626 625 .driver = { 627 626 .name = "fujitsu-laptop", 628 627 } ··· 631 630 static void __init dmi_check_cb_common(const struct dmi_system_id *id) 632 631 { 633 632 pr_info("Identified laptop model '%s'\n", id->ident); 634 - if (use_alt_lcd_levels == -1) { 635 - if (acpi_has_method(NULL, 636 - "\\_SB.PCI0.LPCB.FJEX.SBL2")) 637 - use_alt_lcd_levels = 1; 638 - else 639 - use_alt_lcd_levels = 0; 640 - vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as " 641 - "%i\n", use_alt_lcd_levels); 642 - } 643 633 } 644 634 645 635 static int __init dmi_check_cb_s6410(const struct dmi_system_id *id) 646 636 { 647 637 dmi_check_cb_common(id); 648 - fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */ 649 - fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */ 638 + fujitsu_bl->keycode1 = KEY_SCREENLOCK; /* "Lock" */ 639 + fujitsu_bl->keycode2 = KEY_HELP; /* "Mobility Center" */ 650 640 return 1; 651 641 } 652 642 653 643 static int __init dmi_check_cb_s6420(const struct dmi_system_id *id) 654 644 { 655 645 dmi_check_cb_common(id); 656 - fujitsu->keycode1 = KEY_SCREENLOCK; /* "Lock" */ 657 - fujitsu->keycode2 = KEY_HELP; /* "Mobility Center" */ 646 + fujitsu_bl->keycode1 = KEY_SCREENLOCK; /* "Lock" */ 647 + fujitsu_bl->keycode2 = KEY_HELP; /* "Mobility Center" */ 658 648 return 1; 659 649 } 660 650 661 651 static int __init dmi_check_cb_p8010(const struct dmi_system_id *id) 662 652 { 663 653 dmi_check_cb_common(id); 664 - fujitsu->keycode1 = KEY_HELP; /* "Support" */ 665 - fujitsu->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */ 666 - fujitsu->keycode4 = KEY_WWW; /* "Internet" */ 654 + fujitsu_bl->keycode1 = KEY_HELP; /* "Support" */ 655 + fujitsu_bl->keycode3 = KEY_SWITCHVIDEOMODE; /* "Presentation" */ 656 + fujitsu_bl->keycode4 = KEY_WWW; /* "Internet" */ 667 657 return 1; 668 658 } 669 659 ··· 685 693 686 694 /* ACPI device for LCD brightness control */ 687 695 688 - static int acpi_fujitsu_add(struct acpi_device *device) 696 + static int acpi_fujitsu_bl_add(struct acpi_device *device) 689 697 { 690 698 int state = 0; 691 699 struct input_dev *input; ··· 694 702 if (!device) 695 703 return -EINVAL; 696 704 697 - fujitsu->acpi_handle = device->handle; 698 - sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME); 705 + fujitsu_bl->acpi_handle = device->handle; 706 + sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_BL_DEVICE_NAME); 699 707 sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); 700 - device->driver_data = fujitsu; 708 + device->driver_data = fujitsu_bl; 701 709 702 - fujitsu->input = input = input_allocate_device(); 710 + fujitsu_bl->input = input = input_allocate_device(); 703 711 if (!input) { 704 712 error = -ENOMEM; 705 713 goto err_stop; 706 714 } 707 715 708 - snprintf(fujitsu->phys, sizeof(fujitsu->phys), 716 + snprintf(fujitsu_bl->phys, sizeof(fujitsu_bl->phys), 709 717 "%s/video/input0", acpi_device_hid(device)); 710 718 711 719 input->name = acpi_device_name(device); 712 - input->phys = fujitsu->phys; 720 + input->phys = fujitsu_bl->phys; 713 721 input->id.bustype = BUS_HOST; 714 722 input->id.product = 0x06; 715 723 input->dev.parent = &device->dev; ··· 722 730 if (error) 723 731 goto err_free_input_dev; 724 732 725 - error = acpi_bus_update_power(fujitsu->acpi_handle, &state); 733 + error = acpi_bus_update_power(fujitsu_bl->acpi_handle, &state); 726 734 if (error) { 727 735 pr_err("Error reading power state\n"); 728 736 goto err_unregister_input_dev; ··· 732 740 acpi_device_name(device), acpi_device_bid(device), 733 741 !device->power.state ? "on" : "off"); 734 742 735 - fujitsu->dev = device; 743 + fujitsu_bl->dev = device; 736 744 737 745 if (acpi_has_method(device->handle, METHOD_NAME__INI)) { 738 746 vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); ··· 740 748 (acpi_evaluate_object 741 749 (device->handle, METHOD_NAME__INI, NULL, NULL))) 742 750 pr_err("_INI Method failed\n"); 751 + } 752 + 753 + if (use_alt_lcd_levels == -1) { 754 + if (acpi_has_method(NULL, "\\_SB.PCI0.LPCB.FJEX.SBL2")) 755 + use_alt_lcd_levels = 1; 756 + else 757 + use_alt_lcd_levels = 0; 758 + vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as %i\n", 759 + use_alt_lcd_levels); 743 760 } 744 761 745 762 /* do config (detect defaults) */ ··· 759 758 use_alt_lcd_levels, disable_brightness_adjust); 760 759 761 760 if (get_max_brightness() <= 0) 762 - fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; 761 + fujitsu_bl->max_brightness = FUJITSU_LCD_N_LEVELS; 763 762 get_lcd_level(); 764 763 765 764 return 0; ··· 773 772 return error; 774 773 } 775 774 776 - static int acpi_fujitsu_remove(struct acpi_device *device) 775 + static int acpi_fujitsu_bl_remove(struct acpi_device *device) 777 776 { 778 - struct fujitsu_t *fujitsu = acpi_driver_data(device); 779 - struct input_dev *input = fujitsu->input; 777 + struct fujitsu_bl *fujitsu_bl = acpi_driver_data(device); 778 + struct input_dev *input = fujitsu_bl->input; 780 779 781 780 input_unregister_device(input); 782 781 783 - fujitsu->acpi_handle = NULL; 782 + fujitsu_bl->acpi_handle = NULL; 784 783 785 784 return 0; 786 785 } 787 786 788 787 /* Brightness notify */ 789 788 790 - static void acpi_fujitsu_notify(struct acpi_device *device, u32 event) 789 + static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event) 791 790 { 792 791 struct input_dev *input; 793 792 int keycode; 794 793 int oldb, newb; 795 794 796 - input = fujitsu->input; 795 + input = fujitsu_bl->input; 797 796 798 797 switch (event) { 799 798 case ACPI_FUJITSU_NOTIFY_CODE1: 800 799 keycode = 0; 801 - oldb = fujitsu->brightness_level; 800 + oldb = fujitsu_bl->brightness_level; 802 801 get_lcd_level(); 803 - newb = fujitsu->brightness_level; 802 + newb = fujitsu_bl->brightness_level; 804 803 805 804 vdbg_printk(FUJLAPTOP_DBG_TRACE, 806 805 "brightness button event [%i -> %i (%i)]\n", 807 - oldb, newb, fujitsu->brightness_changed); 806 + oldb, newb, fujitsu_bl->brightness_changed); 808 807 809 808 if (oldb < newb) { 810 809 if (disable_brightness_adjust != 1) { ··· 841 840 842 841 /* ACPI device for hotkey handling */ 843 842 844 - static int acpi_fujitsu_hotkey_add(struct acpi_device *device) 843 + static int acpi_fujitsu_laptop_add(struct acpi_device *device) 845 844 { 846 845 int result = 0; 847 846 int state = 0; ··· 852 851 if (!device) 853 852 return -EINVAL; 854 853 855 - fujitsu_hotkey->acpi_handle = device->handle; 854 + fujitsu_laptop->acpi_handle = device->handle; 856 855 sprintf(acpi_device_name(device), "%s", 857 - ACPI_FUJITSU_HOTKEY_DEVICE_NAME); 856 + ACPI_FUJITSU_LAPTOP_DEVICE_NAME); 858 857 sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS); 859 - device->driver_data = fujitsu_hotkey; 858 + device->driver_data = fujitsu_laptop; 860 859 861 860 /* kfifo */ 862 - spin_lock_init(&fujitsu_hotkey->fifo_lock); 863 - error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int), 861 + spin_lock_init(&fujitsu_laptop->fifo_lock); 862 + error = kfifo_alloc(&fujitsu_laptop->fifo, RINGBUFFERSIZE * sizeof(int), 864 863 GFP_KERNEL); 865 864 if (error) { 866 865 pr_err("kfifo_alloc failed\n"); 867 866 goto err_stop; 868 867 } 869 868 870 - fujitsu_hotkey->input = input = input_allocate_device(); 869 + fujitsu_laptop->input = input = input_allocate_device(); 871 870 if (!input) { 872 871 error = -ENOMEM; 873 872 goto err_free_fifo; 874 873 } 875 874 876 - snprintf(fujitsu_hotkey->phys, sizeof(fujitsu_hotkey->phys), 875 + snprintf(fujitsu_laptop->phys, sizeof(fujitsu_laptop->phys), 877 876 "%s/video/input0", acpi_device_hid(device)); 878 877 879 878 input->name = acpi_device_name(device); 880 - input->phys = fujitsu_hotkey->phys; 879 + input->phys = fujitsu_laptop->phys; 881 880 input->id.bustype = BUS_HOST; 882 881 input->id.product = 0x06; 883 882 input->dev.parent = &device->dev; 884 883 885 884 set_bit(EV_KEY, input->evbit); 886 - set_bit(fujitsu->keycode1, input->keybit); 887 - set_bit(fujitsu->keycode2, input->keybit); 888 - set_bit(fujitsu->keycode3, input->keybit); 889 - set_bit(fujitsu->keycode4, input->keybit); 890 - set_bit(fujitsu->keycode5, input->keybit); 885 + set_bit(fujitsu_bl->keycode1, input->keybit); 886 + set_bit(fujitsu_bl->keycode2, input->keybit); 887 + set_bit(fujitsu_bl->keycode3, input->keybit); 888 + set_bit(fujitsu_bl->keycode4, input->keybit); 889 + set_bit(fujitsu_bl->keycode5, input->keybit); 891 890 set_bit(KEY_TOUCHPAD_TOGGLE, input->keybit); 892 891 set_bit(KEY_UNKNOWN, input->keybit); 893 892 ··· 895 894 if (error) 896 895 goto err_free_input_dev; 897 896 898 - error = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state); 897 + error = acpi_bus_update_power(fujitsu_laptop->acpi_handle, &state); 899 898 if (error) { 900 899 pr_err("Error reading power state\n"); 901 900 goto err_unregister_input_dev; ··· 905 904 acpi_device_name(device), acpi_device_bid(device), 906 905 !device->power.state ? "on" : "off"); 907 906 908 - fujitsu_hotkey->dev = device; 907 + fujitsu_laptop->dev = device; 909 908 910 909 if (acpi_has_method(device->handle, METHOD_NAME__INI)) { 911 910 vdbg_printk(FUJLAPTOP_DBG_INFO, "Invoking _INI\n"); ··· 921 920 ; /* No action, result is discarded */ 922 921 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); 923 922 924 - fujitsu_hotkey->rfkill_supported = 925 - call_fext_func(FUNC_RFKILL, 0x0, 0x0, 0x0); 923 + fujitsu_laptop->flags_supported = 924 + call_fext_func(FUNC_FLAGS, 0x0, 0x0, 0x0); 926 925 927 926 /* Make sure our bitmask of supported functions is cleared if the 928 927 RFKILL function block is not implemented, like on the S7020. */ 929 - if (fujitsu_hotkey->rfkill_supported == UNSUPPORTED_CMD) 930 - fujitsu_hotkey->rfkill_supported = 0; 928 + if (fujitsu_laptop->flags_supported == UNSUPPORTED_CMD) 929 + fujitsu_laptop->flags_supported = 0; 931 930 932 - if (fujitsu_hotkey->rfkill_supported) 933 - fujitsu_hotkey->rfkill_state = 934 - call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 931 + if (fujitsu_laptop->flags_supported) 932 + fujitsu_laptop->flags_state = 933 + call_fext_func(FUNC_FLAGS, 0x4, 0x0, 0x0); 935 934 936 935 /* Suspect this is a keymap of the application panel, print it */ 937 936 pr_info("BTNI: [0x%x]\n", call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0)); 938 937 939 938 #if IS_ENABLED(CONFIG_LEDS_CLASS) 940 939 if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) { 941 - result = led_classdev_register(&fujitsu->pf_device->dev, 940 + result = led_classdev_register(&fujitsu_bl->pf_device->dev, 942 941 &logolamp_led); 943 942 if (result == 0) { 944 - fujitsu_hotkey->logolamp_registered = 1; 943 + fujitsu_laptop->logolamp_registered = 1; 945 944 } else { 946 945 pr_err("Could not register LED handler for logo lamp, error %i\n", 947 946 result); ··· 950 949 951 950 if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) && 952 951 (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) { 953 - result = led_classdev_register(&fujitsu->pf_device->dev, 952 + result = led_classdev_register(&fujitsu_bl->pf_device->dev, 954 953 &kblamps_led); 955 954 if (result == 0) { 956 - fujitsu_hotkey->kblamps_registered = 1; 955 + fujitsu_laptop->kblamps_registered = 1; 957 956 } else { 958 957 pr_err("Could not register LED handler for keyboard lamps, error %i\n", 959 958 result); ··· 967 966 * that an RF LED is present. 968 967 */ 969 968 if (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) & BIT(24)) { 970 - result = led_classdev_register(&fujitsu->pf_device->dev, 969 + result = led_classdev_register(&fujitsu_bl->pf_device->dev, 971 970 &radio_led); 972 971 if (result == 0) { 973 - fujitsu_hotkey->radio_led_registered = 1; 972 + fujitsu_laptop->radio_led_registered = 1; 974 973 } else { 975 974 pr_err("Could not register LED handler for radio LED, error %i\n", 976 975 result); ··· 984 983 */ 985 984 if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & BIT(14)) && 986 985 (call_fext_func(FUNC_LEDS, 0x2, ECO_LED, 0x0) != UNSUPPORTED_CMD)) { 987 - result = led_classdev_register(&fujitsu->pf_device->dev, 986 + result = led_classdev_register(&fujitsu_bl->pf_device->dev, 988 987 &eco_led); 989 988 if (result == 0) { 990 - fujitsu_hotkey->eco_led_registered = 1; 989 + fujitsu_laptop->eco_led_registered = 1; 991 990 } else { 992 991 pr_err("Could not register LED handler for eco LED, error %i\n", 993 992 result); ··· 1003 1002 err_free_input_dev: 1004 1003 input_free_device(input); 1005 1004 err_free_fifo: 1006 - kfifo_free(&fujitsu_hotkey->fifo); 1005 + kfifo_free(&fujitsu_laptop->fifo); 1007 1006 err_stop: 1008 1007 return error; 1009 1008 } 1010 1009 1011 - static int acpi_fujitsu_hotkey_remove(struct acpi_device *device) 1010 + static int acpi_fujitsu_laptop_remove(struct acpi_device *device) 1012 1011 { 1013 - struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device); 1014 - struct input_dev *input = fujitsu_hotkey->input; 1012 + struct fujitsu_laptop *fujitsu_laptop = acpi_driver_data(device); 1013 + struct input_dev *input = fujitsu_laptop->input; 1015 1014 1016 1015 #if IS_ENABLED(CONFIG_LEDS_CLASS) 1017 - if (fujitsu_hotkey->logolamp_registered) 1016 + if (fujitsu_laptop->logolamp_registered) 1018 1017 led_classdev_unregister(&logolamp_led); 1019 1018 1020 - if (fujitsu_hotkey->kblamps_registered) 1019 + if (fujitsu_laptop->kblamps_registered) 1021 1020 led_classdev_unregister(&kblamps_led); 1022 1021 1023 - if (fujitsu_hotkey->radio_led_registered) 1022 + if (fujitsu_laptop->radio_led_registered) 1024 1023 led_classdev_unregister(&radio_led); 1025 1024 1026 - if (fujitsu_hotkey->eco_led_registered) 1025 + if (fujitsu_laptop->eco_led_registered) 1027 1026 led_classdev_unregister(&eco_led); 1028 1027 #endif 1029 1028 1030 1029 input_unregister_device(input); 1031 1030 1032 - kfifo_free(&fujitsu_hotkey->fifo); 1031 + kfifo_free(&fujitsu_laptop->fifo); 1033 1032 1034 - fujitsu_hotkey->acpi_handle = NULL; 1033 + fujitsu_laptop->acpi_handle = NULL; 1035 1034 1036 1035 return 0; 1037 1036 } 1038 1037 1039 - static void acpi_fujitsu_hotkey_press(int keycode) 1038 + static void acpi_fujitsu_laptop_press(int keycode) 1040 1039 { 1041 - struct input_dev *input = fujitsu_hotkey->input; 1040 + struct input_dev *input = fujitsu_laptop->input; 1042 1041 int status; 1043 1042 1044 - status = kfifo_in_locked(&fujitsu_hotkey->fifo, 1043 + status = kfifo_in_locked(&fujitsu_laptop->fifo, 1045 1044 (unsigned char *)&keycode, sizeof(keycode), 1046 - &fujitsu_hotkey->fifo_lock); 1045 + &fujitsu_laptop->fifo_lock); 1047 1046 if (status != sizeof(keycode)) { 1048 1047 vdbg_printk(FUJLAPTOP_DBG_WARN, 1049 1048 "Could not push keycode [0x%x]\n", keycode); ··· 1055 1054 "Push keycode into ringbuffer [%d]\n", keycode); 1056 1055 } 1057 1056 1058 - static void acpi_fujitsu_hotkey_release(void) 1057 + static void acpi_fujitsu_laptop_release(void) 1059 1058 { 1060 - struct input_dev *input = fujitsu_hotkey->input; 1059 + struct input_dev *input = fujitsu_laptop->input; 1061 1060 int keycode, status; 1062 1061 1063 1062 while (true) { 1064 - status = kfifo_out_locked(&fujitsu_hotkey->fifo, 1063 + status = kfifo_out_locked(&fujitsu_laptop->fifo, 1065 1064 (unsigned char *)&keycode, 1066 1065 sizeof(keycode), 1067 - &fujitsu_hotkey->fifo_lock); 1066 + &fujitsu_laptop->fifo_lock); 1068 1067 if (status != sizeof(keycode)) 1069 1068 return; 1070 1069 input_report_key(input, keycode, 0); ··· 1074 1073 } 1075 1074 } 1076 1075 1077 - static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event) 1076 + static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) 1078 1077 { 1079 1078 struct input_dev *input; 1080 1079 int keycode; 1081 1080 unsigned int irb = 1; 1082 1081 int i; 1083 1082 1084 - input = fujitsu_hotkey->input; 1083 + input = fujitsu_laptop->input; 1085 1084 1086 1085 if (event != ACPI_FUJITSU_NOTIFY_CODE1) { 1087 1086 keycode = KEY_UNKNOWN; ··· 1094 1093 return; 1095 1094 } 1096 1095 1097 - if (fujitsu_hotkey->rfkill_supported) 1098 - fujitsu_hotkey->rfkill_state = 1099 - call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0); 1096 + if (fujitsu_laptop->flags_supported) 1097 + fujitsu_laptop->flags_state = 1098 + call_fext_func(FUNC_FLAGS, 0x4, 0x0, 0x0); 1100 1099 1101 1100 i = 0; 1102 1101 while ((irb = ··· 1104 1103 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) { 1105 1104 switch (irb & 0x4ff) { 1106 1105 case KEY1_CODE: 1107 - keycode = fujitsu->keycode1; 1106 + keycode = fujitsu_bl->keycode1; 1108 1107 break; 1109 1108 case KEY2_CODE: 1110 - keycode = fujitsu->keycode2; 1109 + keycode = fujitsu_bl->keycode2; 1111 1110 break; 1112 1111 case KEY3_CODE: 1113 - keycode = fujitsu->keycode3; 1112 + keycode = fujitsu_bl->keycode3; 1114 1113 break; 1115 1114 case KEY4_CODE: 1116 - keycode = fujitsu->keycode4; 1115 + keycode = fujitsu_bl->keycode4; 1117 1116 break; 1118 1117 case KEY5_CODE: 1119 - keycode = fujitsu->keycode5; 1118 + keycode = fujitsu_bl->keycode5; 1120 1119 break; 1121 1120 case 0: 1122 1121 keycode = 0; ··· 1129 1128 } 1130 1129 1131 1130 if (keycode > 0) 1132 - acpi_fujitsu_hotkey_press(keycode); 1131 + acpi_fujitsu_laptop_press(keycode); 1133 1132 else if (keycode == 0) 1134 - acpi_fujitsu_hotkey_release(); 1133 + acpi_fujitsu_laptop_release(); 1135 1134 } 1136 1135 1137 1136 /* On some models (first seen on the Skylake-based Lifebook 1138 1137 * E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is 1139 - * handled in software; its state is queried using FUNC_RFKILL 1138 + * handled in software; its state is queried using FUNC_FLAGS 1140 1139 */ 1141 - if ((fujitsu_hotkey->rfkill_supported & BIT(26)) && 1142 - (call_fext_func(FUNC_RFKILL, 0x1, 0x0, 0x0) & BIT(26))) { 1140 + if ((fujitsu_laptop->flags_supported & BIT(26)) && 1141 + (call_fext_func(FUNC_FLAGS, 0x1, 0x0, 0x0) & BIT(26))) { 1143 1142 keycode = KEY_TOUCHPAD_TOGGLE; 1144 1143 input_report_key(input, keycode, 1); 1145 1144 input_sync(input); ··· 1151 1150 1152 1151 /* Initialization */ 1153 1152 1154 - static const struct acpi_device_id fujitsu_device_ids[] = { 1155 - {ACPI_FUJITSU_HID, 0}, 1153 + static const struct acpi_device_id fujitsu_bl_device_ids[] = { 1154 + {ACPI_FUJITSU_BL_HID, 0}, 1156 1155 {"", 0}, 1157 1156 }; 1158 1157 1159 - static struct acpi_driver acpi_fujitsu_driver = { 1160 - .name = ACPI_FUJITSU_DRIVER_NAME, 1158 + static struct acpi_driver acpi_fujitsu_bl_driver = { 1159 + .name = ACPI_FUJITSU_BL_DRIVER_NAME, 1161 1160 .class = ACPI_FUJITSU_CLASS, 1162 - .ids = fujitsu_device_ids, 1161 + .ids = fujitsu_bl_device_ids, 1163 1162 .ops = { 1164 - .add = acpi_fujitsu_add, 1165 - .remove = acpi_fujitsu_remove, 1166 - .notify = acpi_fujitsu_notify, 1163 + .add = acpi_fujitsu_bl_add, 1164 + .remove = acpi_fujitsu_bl_remove, 1165 + .notify = acpi_fujitsu_bl_notify, 1167 1166 }, 1168 1167 }; 1169 1168 1170 - static const struct acpi_device_id fujitsu_hotkey_device_ids[] = { 1171 - {ACPI_FUJITSU_HOTKEY_HID, 0}, 1169 + static const struct acpi_device_id fujitsu_laptop_device_ids[] = { 1170 + {ACPI_FUJITSU_LAPTOP_HID, 0}, 1172 1171 {"", 0}, 1173 1172 }; 1174 1173 1175 - static struct acpi_driver acpi_fujitsu_hotkey_driver = { 1176 - .name = ACPI_FUJITSU_HOTKEY_DRIVER_NAME, 1174 + static struct acpi_driver acpi_fujitsu_laptop_driver = { 1175 + .name = ACPI_FUJITSU_LAPTOP_DRIVER_NAME, 1177 1176 .class = ACPI_FUJITSU_CLASS, 1178 - .ids = fujitsu_hotkey_device_ids, 1177 + .ids = fujitsu_laptop_device_ids, 1179 1178 .ops = { 1180 - .add = acpi_fujitsu_hotkey_add, 1181 - .remove = acpi_fujitsu_hotkey_remove, 1182 - .notify = acpi_fujitsu_hotkey_notify, 1179 + .add = acpi_fujitsu_laptop_add, 1180 + .remove = acpi_fujitsu_laptop_remove, 1181 + .notify = acpi_fujitsu_laptop_notify, 1183 1182 }, 1184 1183 }; 1185 1184 1186 1185 static const struct acpi_device_id fujitsu_ids[] __used = { 1187 - {ACPI_FUJITSU_HID, 0}, 1188 - {ACPI_FUJITSU_HOTKEY_HID, 0}, 1186 + {ACPI_FUJITSU_BL_HID, 0}, 1187 + {ACPI_FUJITSU_LAPTOP_HID, 0}, 1189 1188 {"", 0} 1190 1189 }; 1191 1190 MODULE_DEVICE_TABLE(acpi, fujitsu_ids); 1192 1191 1193 1192 static int __init fujitsu_init(void) 1194 1193 { 1195 - int ret, result, max_brightness; 1194 + int ret, max_brightness; 1196 1195 1197 1196 if (acpi_disabled) 1198 1197 return -ENODEV; 1199 1198 1200 - fujitsu = kzalloc(sizeof(struct fujitsu_t), GFP_KERNEL); 1201 - if (!fujitsu) 1199 + fujitsu_bl = kzalloc(sizeof(struct fujitsu_bl), GFP_KERNEL); 1200 + if (!fujitsu_bl) 1202 1201 return -ENOMEM; 1203 - fujitsu->keycode1 = KEY_PROG1; 1204 - fujitsu->keycode2 = KEY_PROG2; 1205 - fujitsu->keycode3 = KEY_PROG3; 1206 - fujitsu->keycode4 = KEY_PROG4; 1207 - fujitsu->keycode5 = KEY_RFKILL; 1202 + fujitsu_bl->keycode1 = KEY_PROG1; 1203 + fujitsu_bl->keycode2 = KEY_PROG2; 1204 + fujitsu_bl->keycode3 = KEY_PROG3; 1205 + fujitsu_bl->keycode4 = KEY_PROG4; 1206 + fujitsu_bl->keycode5 = KEY_RFKILL; 1208 1207 dmi_check_system(fujitsu_dmi_table); 1209 1208 1210 - result = acpi_bus_register_driver(&acpi_fujitsu_driver); 1211 - if (result < 0) { 1212 - ret = -ENODEV; 1209 + ret = acpi_bus_register_driver(&acpi_fujitsu_bl_driver); 1210 + if (ret) 1213 1211 goto fail_acpi; 1214 - } 1215 1212 1216 1213 /* Register platform stuff */ 1217 1214 1218 - fujitsu->pf_device = platform_device_alloc("fujitsu-laptop", -1); 1219 - if (!fujitsu->pf_device) { 1215 + fujitsu_bl->pf_device = platform_device_alloc("fujitsu-laptop", -1); 1216 + if (!fujitsu_bl->pf_device) { 1220 1217 ret = -ENOMEM; 1221 1218 goto fail_platform_driver; 1222 1219 } 1223 1220 1224 - ret = platform_device_add(fujitsu->pf_device); 1221 + ret = platform_device_add(fujitsu_bl->pf_device); 1225 1222 if (ret) 1226 1223 goto fail_platform_device1; 1227 1224 1228 1225 ret = 1229 - sysfs_create_group(&fujitsu->pf_device->dev.kobj, 1230 - &fujitsupf_attribute_group); 1226 + sysfs_create_group(&fujitsu_bl->pf_device->dev.kobj, 1227 + &fujitsu_pf_attribute_group); 1231 1228 if (ret) 1232 1229 goto fail_platform_device2; 1233 1230 ··· 1235 1236 struct backlight_properties props; 1236 1237 1237 1238 memset(&props, 0, sizeof(struct backlight_properties)); 1238 - max_brightness = fujitsu->max_brightness; 1239 + max_brightness = fujitsu_bl->max_brightness; 1239 1240 props.type = BACKLIGHT_PLATFORM; 1240 1241 props.max_brightness = max_brightness - 1; 1241 - fujitsu->bl_device = backlight_device_register("fujitsu-laptop", 1242 - NULL, NULL, 1243 - &fujitsubl_ops, 1244 - &props); 1245 - if (IS_ERR(fujitsu->bl_device)) { 1246 - ret = PTR_ERR(fujitsu->bl_device); 1247 - fujitsu->bl_device = NULL; 1242 + fujitsu_bl->bl_device = backlight_device_register("fujitsu-laptop", 1243 + NULL, NULL, 1244 + &fujitsu_bl_ops, 1245 + &props); 1246 + if (IS_ERR(fujitsu_bl->bl_device)) { 1247 + ret = PTR_ERR(fujitsu_bl->bl_device); 1248 + fujitsu_bl->bl_device = NULL; 1248 1249 goto fail_sysfs_group; 1249 1250 } 1250 - fujitsu->bl_device->props.brightness = fujitsu->brightness_level; 1251 + fujitsu_bl->bl_device->props.brightness = fujitsu_bl->brightness_level; 1251 1252 } 1252 1253 1253 - ret = platform_driver_register(&fujitsupf_driver); 1254 + ret = platform_driver_register(&fujitsu_pf_driver); 1254 1255 if (ret) 1255 1256 goto fail_backlight; 1256 1257 1257 - /* Register hotkey driver */ 1258 + /* Register laptop driver */ 1258 1259 1259 - fujitsu_hotkey = kzalloc(sizeof(struct fujitsu_hotkey_t), GFP_KERNEL); 1260 - if (!fujitsu_hotkey) { 1260 + fujitsu_laptop = kzalloc(sizeof(struct fujitsu_laptop), GFP_KERNEL); 1261 + if (!fujitsu_laptop) { 1261 1262 ret = -ENOMEM; 1262 - goto fail_hotkey; 1263 + goto fail_laptop; 1263 1264 } 1264 1265 1265 - result = acpi_bus_register_driver(&acpi_fujitsu_hotkey_driver); 1266 - if (result < 0) { 1267 - ret = -ENODEV; 1268 - goto fail_hotkey1; 1269 - } 1266 + ret = acpi_bus_register_driver(&acpi_fujitsu_laptop_driver); 1267 + if (ret) 1268 + goto fail_laptop1; 1270 1269 1271 1270 /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */ 1272 1271 if (acpi_video_get_backlight_type() == acpi_backlight_vendor) { 1273 1272 if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3) 1274 - fujitsu->bl_device->props.power = FB_BLANK_POWERDOWN; 1273 + fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN; 1275 1274 else 1276 - fujitsu->bl_device->props.power = FB_BLANK_UNBLANK; 1275 + fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK; 1277 1276 } 1278 1277 1279 1278 pr_info("driver " FUJITSU_DRIVER_VERSION " successfully loaded\n"); 1280 1279 1281 1280 return 0; 1282 1281 1283 - fail_hotkey1: 1284 - kfree(fujitsu_hotkey); 1285 - fail_hotkey: 1286 - platform_driver_unregister(&fujitsupf_driver); 1282 + fail_laptop1: 1283 + kfree(fujitsu_laptop); 1284 + fail_laptop: 1285 + platform_driver_unregister(&fujitsu_pf_driver); 1287 1286 fail_backlight: 1288 - backlight_device_unregister(fujitsu->bl_device); 1287 + backlight_device_unregister(fujitsu_bl->bl_device); 1289 1288 fail_sysfs_group: 1290 - sysfs_remove_group(&fujitsu->pf_device->dev.kobj, 1291 - &fujitsupf_attribute_group); 1289 + sysfs_remove_group(&fujitsu_bl->pf_device->dev.kobj, 1290 + &fujitsu_pf_attribute_group); 1292 1291 fail_platform_device2: 1293 - platform_device_del(fujitsu->pf_device); 1292 + platform_device_del(fujitsu_bl->pf_device); 1294 1293 fail_platform_device1: 1295 - platform_device_put(fujitsu->pf_device); 1294 + platform_device_put(fujitsu_bl->pf_device); 1296 1295 fail_platform_driver: 1297 - acpi_bus_unregister_driver(&acpi_fujitsu_driver); 1296 + acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); 1298 1297 fail_acpi: 1299 - kfree(fujitsu); 1298 + kfree(fujitsu_bl); 1300 1299 1301 1300 return ret; 1302 1301 } 1303 1302 1304 1303 static void __exit fujitsu_cleanup(void) 1305 1304 { 1306 - acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver); 1305 + acpi_bus_unregister_driver(&acpi_fujitsu_laptop_driver); 1307 1306 1308 - kfree(fujitsu_hotkey); 1307 + kfree(fujitsu_laptop); 1309 1308 1310 - platform_driver_unregister(&fujitsupf_driver); 1309 + platform_driver_unregister(&fujitsu_pf_driver); 1311 1310 1312 - backlight_device_unregister(fujitsu->bl_device); 1311 + backlight_device_unregister(fujitsu_bl->bl_device); 1313 1312 1314 - sysfs_remove_group(&fujitsu->pf_device->dev.kobj, 1315 - &fujitsupf_attribute_group); 1313 + sysfs_remove_group(&fujitsu_bl->pf_device->dev.kobj, 1314 + &fujitsu_pf_attribute_group); 1316 1315 1317 - platform_device_unregister(fujitsu->pf_device); 1316 + platform_device_unregister(fujitsu_bl->pf_device); 1318 1317 1319 - acpi_bus_unregister_driver(&acpi_fujitsu_driver); 1318 + acpi_bus_unregister_driver(&acpi_fujitsu_bl_driver); 1320 1319 1321 - kfree(fujitsu); 1320 + kfree(fujitsu_bl); 1322 1321 1323 1322 pr_info("driver unloaded\n"); 1324 1323 } ··· 1338 1341 MODULE_DESCRIPTION("Fujitsu laptop extras support"); 1339 1342 MODULE_VERSION(FUJITSU_DRIVER_VERSION); 1340 1343 MODULE_LICENSE("GPL"); 1341 - 1342 - MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*"); 1343 - MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*"); 1344 - MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
+16 -3
drivers/scsi/Kconfig
··· 1241 1241 tristate "Emulex LightPulse Fibre Channel Support" 1242 1242 depends on PCI && SCSI 1243 1243 depends on SCSI_FC_ATTRS 1244 - depends on NVME_FC && NVME_TARGET_FC 1245 1244 select CRC_T10DIF 1246 - help 1245 + ---help--- 1247 1246 This lpfc driver supports the Emulex LightPulse 1248 1247 Family of Fibre Channel PCI host adapters. 1249 1248 1250 1249 config SCSI_LPFC_DEBUG_FS 1251 1250 bool "Emulex LightPulse Fibre Channel debugfs Support" 1252 1251 depends on SCSI_LPFC && DEBUG_FS 1253 - help 1252 + ---help--- 1254 1253 This makes debugging information from the lpfc driver 1255 1254 available via the debugfs filesystem. 1255 + 1256 + config LPFC_NVME_INITIATOR 1257 + bool "Emulex LightPulse Fibre Channel NVME Initiator Support" 1258 + depends on SCSI_LPFC && NVME_FC 1259 + ---help--- 1260 + This enables NVME Initiator support in the Emulex lpfc driver. 1261 + 1262 + config LPFC_NVME_TARGET 1263 + bool "Emulex LightPulse Fibre Channel NVME Initiator Support" 1264 + depends on SCSI_LPFC && NVME_TARGET_FC 1265 + ---help--- 1266 + This enables NVME Target support in the Emulex lpfc driver. 1267 + Target enablement must still be enabled on a per adapter 1268 + basis by module parameters. 1256 1269 1257 1270 config SCSI_SIM710 1258 1271 tristate "Simple 53c710 SCSI support (Compaq, NCR machines)"
+1 -1
drivers/scsi/aacraid/src.c
··· 468 468 return -1; 469 469 470 470 err_blink: 471 - return (status > 16) & 0xFF; 471 + return (status >> 16) & 0xFF; 472 472 } 473 473 474 474 static inline u32 aac_get_vector(struct aac_dev *dev)
+25 -1
drivers/scsi/libiscsi.c
··· 561 561 WARN_ON_ONCE(task->state == ISCSI_TASK_FREE); 562 562 task->state = state; 563 563 564 - if (!list_empty(&task->running)) 564 + spin_lock_bh(&conn->taskqueuelock); 565 + if (!list_empty(&task->running)) { 566 + pr_debug_once("%s while task on list", __func__); 565 567 list_del_init(&task->running); 568 + } 569 + spin_unlock_bh(&conn->taskqueuelock); 566 570 567 571 if (conn->task == task) 568 572 conn->task = NULL; ··· 788 784 if (session->tt->xmit_task(task)) 789 785 goto free_task; 790 786 } else { 787 + spin_lock_bh(&conn->taskqueuelock); 791 788 list_add_tail(&task->running, &conn->mgmtqueue); 789 + spin_unlock_bh(&conn->taskqueuelock); 792 790 iscsi_conn_queue_work(conn); 793 791 } 794 792 ··· 1481 1475 * this may be on the requeue list already if the xmit_task callout 1482 1476 * is handling the r2ts while we are adding new ones 1483 1477 */ 1478 + spin_lock_bh(&conn->taskqueuelock); 1484 1479 if (list_empty(&task->running)) 1485 1480 list_add_tail(&task->running, &conn->requeue); 1481 + spin_unlock_bh(&conn->taskqueuelock); 1486 1482 iscsi_conn_queue_work(conn); 1487 1483 } 1488 1484 EXPORT_SYMBOL_GPL(iscsi_requeue_task); ··· 1521 1513 * only have one nop-out as a ping from us and targets should not 1522 1514 * overflow us with nop-ins 1523 1515 */ 1516 + spin_lock_bh(&conn->taskqueuelock); 1524 1517 check_mgmt: 1525 1518 while (!list_empty(&conn->mgmtqueue)) { 1526 1519 conn->task = list_entry(conn->mgmtqueue.next, 1527 1520 struct iscsi_task, running); 1528 1521 list_del_init(&conn->task->running); 1522 + spin_unlock_bh(&conn->taskqueuelock); 1529 1523 if (iscsi_prep_mgmt_task(conn, conn->task)) { 1530 1524 /* regular RX path uses back_lock */ 1531 1525 spin_lock_bh(&conn->session->back_lock); 1532 1526 __iscsi_put_task(conn->task); 1533 1527 spin_unlock_bh(&conn->session->back_lock); 1534 1528 conn->task = NULL; 1529 + spin_lock_bh(&conn->taskqueuelock); 1535 1530 continue; 1536 1531 } 1537 1532 rc = iscsi_xmit_task(conn); 1538 1533 if (rc) 1539 1534 goto done; 1535 + spin_lock_bh(&conn->taskqueuelock); 1540 1536 } 1541 1537 1542 1538 /* process pending command queue */ ··· 1548 1536 conn->task = list_entry(conn->cmdqueue.next, struct iscsi_task, 1549 1537 running); 1550 1538 list_del_init(&conn->task->running); 1539 + spin_unlock_bh(&conn->taskqueuelock); 1551 1540 if (conn->session->state == ISCSI_STATE_LOGGING_OUT) { 1552 1541 fail_scsi_task(conn->task, DID_IMM_RETRY); 1542 + spin_lock_bh(&conn->taskqueuelock); 1553 1543 continue; 1554 1544 } 1555 1545 rc = iscsi_prep_scsi_cmd_pdu(conn->task); 1556 1546 if (rc) { 1557 1547 if (rc == -ENOMEM || rc == -EACCES) { 1548 + spin_lock_bh(&conn->taskqueuelock); 1558 1549 list_add_tail(&conn->task->running, 1559 1550 &conn->cmdqueue); 1560 1551 conn->task = NULL; 1552 + spin_unlock_bh(&conn->taskqueuelock); 1561 1553 goto done; 1562 1554 } else 1563 1555 fail_scsi_task(conn->task, DID_ABORT); 1556 + spin_lock_bh(&conn->taskqueuelock); 1564 1557 continue; 1565 1558 } 1566 1559 rc = iscsi_xmit_task(conn); ··· 1576 1559 * we need to check the mgmt queue for nops that need to 1577 1560 * be sent to aviod starvation 1578 1561 */ 1562 + spin_lock_bh(&conn->taskqueuelock); 1579 1563 if (!list_empty(&conn->mgmtqueue)) 1580 1564 goto check_mgmt; 1581 1565 } ··· 1596 1578 conn->task = task; 1597 1579 list_del_init(&conn->task->running); 1598 1580 conn->task->state = ISCSI_TASK_RUNNING; 1581 + spin_unlock_bh(&conn->taskqueuelock); 1599 1582 rc = iscsi_xmit_task(conn); 1600 1583 if (rc) 1601 1584 goto done; 1585 + spin_lock_bh(&conn->taskqueuelock); 1602 1586 if (!list_empty(&conn->mgmtqueue)) 1603 1587 goto check_mgmt; 1604 1588 } 1589 + spin_unlock_bh(&conn->taskqueuelock); 1605 1590 spin_unlock_bh(&conn->session->frwd_lock); 1606 1591 return -ENODATA; 1607 1592 ··· 1760 1739 goto prepd_reject; 1761 1740 } 1762 1741 } else { 1742 + spin_lock_bh(&conn->taskqueuelock); 1763 1743 list_add_tail(&task->running, &conn->cmdqueue); 1744 + spin_unlock_bh(&conn->taskqueuelock); 1764 1745 iscsi_conn_queue_work(conn); 1765 1746 } 1766 1747 ··· 2920 2897 INIT_LIST_HEAD(&conn->mgmtqueue); 2921 2898 INIT_LIST_HEAD(&conn->cmdqueue); 2922 2899 INIT_LIST_HEAD(&conn->requeue); 2900 + spin_lock_init(&conn->taskqueuelock); 2923 2901 INIT_WORK(&conn->xmitwork, iscsi_xmitworker); 2924 2902 2925 2903 /* allocate login_task used for the login/text sequences */
+3 -1
drivers/scsi/lpfc/lpfc.h
··· 99 99 #define FC_MAX_ADPTMSG 64 100 100 101 101 #define MAX_HBAEVT 32 102 + #define MAX_HBAS_NO_RESET 16 102 103 103 104 /* Number of MSI-X vectors the driver uses */ 104 105 #define LPFC_MSIX_VECTORS 2 105 106 106 107 /* lpfc wait event data ready flag */ 107 - #define LPFC_DATA_READY (1<<0) 108 + #define LPFC_DATA_READY 0 /* bit 0 */ 108 109 109 110 /* queue dump line buffer size */ 110 111 #define LPFC_LBUF_SZ 128 ··· 693 692 * capability 694 693 */ 695 694 #define HBA_NVME_IOQ_FLUSH 0x80000 /* NVME IO queues flushed. */ 695 + #define NVME_XRI_ABORT_EVENT 0x100000 696 696 697 697 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/ 698 698 struct lpfc_dmabuf slim2p;
+8 -1
drivers/scsi/lpfc/lpfc_attr.c
··· 3010 3010 static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, 3011 3011 lpfc_poll_show, lpfc_poll_store); 3012 3012 3013 + int lpfc_no_hba_reset_cnt; 3014 + unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { 3015 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 3016 + module_param_array(lpfc_no_hba_reset, ulong, &lpfc_no_hba_reset_cnt, 0444); 3017 + MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset"); 3018 + 3013 3019 LPFC_ATTR(sli_mode, 0, 0, 3, 3014 3020 "SLI mode selector:" 3015 3021 " 0 - auto (SLI-3 if supported)," ··· 4457 4451 return -EINVAL; 4458 4452 4459 4453 phba->cfg_fcp_imax = (uint32_t)val; 4460 - for (i = 0; i < phba->io_channel_irqs; i++) 4454 + 4455 + for (i = 0; i < phba->io_channel_irqs; i += LPFC_MAX_EQ_DELAY_EQID_CNT) 4461 4456 lpfc_modify_hba_eq_delay(phba, i); 4462 4457 4463 4458 return strlen(buf);
+3 -1
drivers/scsi/lpfc/lpfc_crtn.h
··· 384 384 extern struct device_attribute *lpfc_hba_attrs[]; 385 385 extern struct device_attribute *lpfc_vport_attrs[]; 386 386 extern struct scsi_host_template lpfc_template; 387 - extern struct scsi_host_template lpfc_template_s3; 387 + extern struct scsi_host_template lpfc_template_no_hr; 388 388 extern struct scsi_host_template lpfc_template_nvme; 389 389 extern struct scsi_host_template lpfc_vport_template; 390 390 extern struct fc_function_template lpfc_transport_functions; ··· 554 554 struct lpfc_wcqe_complete *abts_cmpl); 555 555 extern int lpfc_enable_nvmet_cnt; 556 556 extern unsigned long long lpfc_enable_nvmet[]; 557 + extern int lpfc_no_hba_reset_cnt; 558 + extern unsigned long lpfc_no_hba_reset[];
+1 -1
drivers/scsi/lpfc/lpfc_ct.c
··· 939 939 "FC4 x%08x, Data: x%08x x%08x\n", 940 940 ndlp, did, ndlp->nlp_fc4_type, 941 941 FC_TYPE_FCP, FC_TYPE_NVME); 942 + ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 942 943 } 943 - ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 944 944 lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE); 945 945 lpfc_issue_els_prli(vport, ndlp, 0); 946 946 } else
-22
drivers/scsi/lpfc/lpfc_debugfs.c
··· 3653 3653 idiag.ptr_private = phba->sli4_hba.nvmels_cq; 3654 3654 goto pass_check; 3655 3655 } 3656 - /* NVME LS complete queue */ 3657 - if (phba->sli4_hba.nvmels_cq && 3658 - phba->sli4_hba.nvmels_cq->queue_id == queid) { 3659 - /* Sanity check */ 3660 - rc = lpfc_idiag_que_param_check( 3661 - phba->sli4_hba.nvmels_cq, index, count); 3662 - if (rc) 3663 - goto error_out; 3664 - idiag.ptr_private = phba->sli4_hba.nvmels_cq; 3665 - goto pass_check; 3666 - } 3667 3656 /* FCP complete queue */ 3668 3657 if (phba->sli4_hba.fcp_cq) { 3669 3658 for (qidx = 0; qidx < phba->cfg_fcp_io_channel; ··· 3714 3725 if (rc) 3715 3726 goto error_out; 3716 3727 idiag.ptr_private = phba->sli4_hba.els_wq; 3717 - goto pass_check; 3718 - } 3719 - /* NVME LS work queue */ 3720 - if (phba->sli4_hba.nvmels_wq && 3721 - phba->sli4_hba.nvmels_wq->queue_id == queid) { 3722 - /* Sanity check */ 3723 - rc = lpfc_idiag_que_param_check( 3724 - phba->sli4_hba.nvmels_wq, index, count); 3725 - if (rc) 3726 - goto error_out; 3727 - idiag.ptr_private = phba->sli4_hba.nvmels_wq; 3728 3728 goto pass_check; 3729 3729 } 3730 3730 /* NVME LS work queue */
+14 -8
drivers/scsi/lpfc/lpfc_els.c
··· 5177 5177 5178 5178 static uint32_t 5179 5179 lpfc_rdp_res_diag_port_names(struct fc_rdp_port_name_desc *desc, 5180 - struct lpfc_hba *phba) 5180 + struct lpfc_vport *vport) 5181 5181 { 5182 5182 5183 5183 desc->tag = cpu_to_be32(RDP_PORT_NAMES_DESC_TAG); 5184 5184 5185 - memcpy(desc->port_names.wwnn, phba->wwnn, 5185 + memcpy(desc->port_names.wwnn, &vport->fc_nodename, 5186 5186 sizeof(desc->port_names.wwnn)); 5187 5187 5188 - memcpy(desc->port_names.wwpn, phba->wwpn, 5188 + memcpy(desc->port_names.wwpn, &vport->fc_portname, 5189 5189 sizeof(desc->port_names.wwpn)); 5190 5190 5191 5191 desc->length = cpu_to_be32(sizeof(desc->port_names)); ··· 5279 5279 len += lpfc_rdp_res_link_error((struct fc_rdp_link_error_status_desc *) 5280 5280 (len + pcmd), &rdp_context->link_stat); 5281 5281 len += lpfc_rdp_res_diag_port_names((struct fc_rdp_port_name_desc *) 5282 - (len + pcmd), phba); 5282 + (len + pcmd), vport); 5283 5283 len += lpfc_rdp_res_attach_port_names((struct fc_rdp_port_name_desc *) 5284 5284 (len + pcmd), vport, ndlp); 5285 5285 len += lpfc_rdp_res_fec_desc((struct fc_fec_rdp_desc *)(len + pcmd), ··· 8371 8371 spin_lock_irq(shost->host_lock); 8372 8372 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 8373 8373 spin_unlock_irq(shost->host_lock); 8374 - if (vport->port_type == LPFC_PHYSICAL_PORT 8375 - && !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) 8376 - lpfc_issue_init_vfi(vport); 8377 - else 8374 + if (mb->mbxStatus == MBX_NOT_FINISHED) 8375 + break; 8376 + if ((vport->port_type == LPFC_PHYSICAL_PORT) && 8377 + !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) { 8378 + if (phba->sli_rev == LPFC_SLI_REV4) 8379 + lpfc_issue_init_vfi(vport); 8380 + else 8381 + lpfc_initial_flogi(vport); 8382 + } else { 8378 8383 lpfc_initial_fdisc(vport); 8384 + } 8379 8385 break; 8380 8386 } 8381 8387 } else {
+13 -11
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 313 313 ndlp->nlp_state, ndlp->nlp_rpi); 314 314 } 315 315 316 - if (!(vport->load_flag & FC_UNLOADING) && 317 - !(ndlp->nlp_flag & NLP_DELAY_TMO) && 316 + if (!(ndlp->nlp_flag & NLP_DELAY_TMO) && 318 317 !(ndlp->nlp_flag & NLP_NPR_2B_DISC) && 319 318 (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && 320 319 (ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) && ··· 640 641 lpfc_handle_rrq_active(phba); 641 642 if (phba->hba_flag & FCP_XRI_ABORT_EVENT) 642 643 lpfc_sli4_fcp_xri_abort_event_proc(phba); 644 + if (phba->hba_flag & NVME_XRI_ABORT_EVENT) 645 + lpfc_sli4_nvme_xri_abort_event_proc(phba); 643 646 if (phba->hba_flag & ELS_XRI_ABORT_EVENT) 644 647 lpfc_sli4_els_xri_abort_event_proc(phba); 645 648 if (phba->hba_flag & ASYNC_EVENT) ··· 2174 2173 uint32_t boot_flag, addr_mode; 2175 2174 uint16_t fcf_index, next_fcf_index; 2176 2175 struct lpfc_fcf_rec *fcf_rec = NULL; 2177 - uint16_t vlan_id; 2176 + uint16_t vlan_id = LPFC_FCOE_NULL_VID; 2178 2177 bool select_new_fcf; 2179 2178 int rc; 2180 2179 ··· 4021 4020 rdata = rport->dd_data; 4022 4021 /* break the link before dropping the ref */ 4023 4022 ndlp->rport = NULL; 4024 - if (rdata && rdata->pnode == ndlp) 4025 - lpfc_nlp_put(ndlp); 4026 - rdata->pnode = NULL; 4023 + if (rdata) { 4024 + if (rdata->pnode == ndlp) 4025 + lpfc_nlp_put(ndlp); 4026 + rdata->pnode = NULL; 4027 + } 4027 4028 /* drop reference for earlier registeration */ 4028 4029 put_device(&rport->dev); 4029 4030 } ··· 4347 4344 { 4348 4345 INIT_LIST_HEAD(&ndlp->els_retry_evt.evt_listp); 4349 4346 INIT_LIST_HEAD(&ndlp->dev_loss_evt.evt_listp); 4350 - init_timer(&ndlp->nlp_delayfunc); 4351 - ndlp->nlp_delayfunc.function = lpfc_els_retry_delay; 4352 - ndlp->nlp_delayfunc.data = (unsigned long)ndlp; 4347 + setup_timer(&ndlp->nlp_delayfunc, lpfc_els_retry_delay, 4348 + (unsigned long)ndlp); 4353 4349 ndlp->nlp_DID = did; 4354 4350 ndlp->vport = vport; 4355 4351 ndlp->phba = vport->phba; ··· 4608 4606 pring = qp->pring; 4609 4607 if (!pring) 4610 4608 continue; 4611 - spin_lock_irq(&pring->ring_lock); 4609 + spin_lock(&pring->ring_lock); 4612 4610 __lpfc_dequeue_nport_iocbs(phba, ndlp, pring, dequeue_list); 4613 - spin_unlock_irq(&pring->ring_lock); 4611 + spin_unlock(&pring->ring_lock); 4614 4612 } 4615 4613 spin_unlock_irq(&phba->hbalock); 4616 4614 }
+2 -2
drivers/scsi/lpfc/lpfc_hw4.h
··· 1001 1001 uint32_t phase; 1002 1002 uint32_t delay_multi; 1003 1003 }; 1004 - #define LPFC_MAX_EQ_DELAY 8 1004 + #define LPFC_MAX_EQ_DELAY_EQID_CNT 8 1005 1005 1006 1006 struct sgl_page_pairs { 1007 1007 uint32_t sgl_pg0_addr_lo; ··· 1070 1070 union { 1071 1071 struct { 1072 1072 uint32_t num_eq; 1073 - struct eq_delay_info eq[LPFC_MAX_EQ_DELAY]; 1073 + struct eq_delay_info eq[LPFC_MAX_EQ_DELAY_EQID_CNT]; 1074 1074 } request; 1075 1075 struct { 1076 1076 uint32_t word0;
+85 -43
drivers/scsi/lpfc/lpfc_init.c
··· 3555 3555 return rc; 3556 3556 } 3557 3557 3558 + static uint64_t 3559 + lpfc_get_wwpn(struct lpfc_hba *phba) 3560 + { 3561 + uint64_t wwn; 3562 + int rc; 3563 + LPFC_MBOXQ_t *mboxq; 3564 + MAILBOX_t *mb; 3565 + 3566 + 3567 + mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, 3568 + GFP_KERNEL); 3569 + if (!mboxq) 3570 + return (uint64_t)-1; 3571 + 3572 + /* First get WWN of HBA instance */ 3573 + lpfc_read_nv(phba, mboxq); 3574 + rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); 3575 + if (rc != MBX_SUCCESS) { 3576 + lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3577 + "6019 Mailbox failed , mbxCmd x%x " 3578 + "READ_NV, mbxStatus x%x\n", 3579 + bf_get(lpfc_mqe_command, &mboxq->u.mqe), 3580 + bf_get(lpfc_mqe_status, &mboxq->u.mqe)); 3581 + mempool_free(mboxq, phba->mbox_mem_pool); 3582 + return (uint64_t) -1; 3583 + } 3584 + mb = &mboxq->u.mb; 3585 + memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); 3586 + /* wwn is WWPN of HBA instance */ 3587 + mempool_free(mboxq, phba->mbox_mem_pool); 3588 + if (phba->sli_rev == LPFC_SLI_REV4) 3589 + return be64_to_cpu(wwn); 3590 + else 3591 + return (((wwn & 0xffffffff00000000) >> 32) | 3592 + ((wwn & 0x00000000ffffffff) << 32)); 3593 + 3594 + } 3595 + 3558 3596 /** 3559 3597 * lpfc_sli4_nvme_sgl_update - update xri-sgl sizing and mapping 3560 3598 * @phba: pointer to lpfc hba data structure. ··· 3714 3676 struct lpfc_vport *vport; 3715 3677 struct Scsi_Host *shost = NULL; 3716 3678 int error = 0; 3679 + int i; 3680 + uint64_t wwn; 3681 + bool use_no_reset_hba = false; 3682 + 3683 + wwn = lpfc_get_wwpn(phba); 3684 + 3685 + for (i = 0; i < lpfc_no_hba_reset_cnt; i++) { 3686 + if (wwn == lpfc_no_hba_reset[i]) { 3687 + lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3688 + "6020 Setting use_no_reset port=%llx\n", 3689 + wwn); 3690 + use_no_reset_hba = true; 3691 + break; 3692 + } 3693 + } 3717 3694 3718 3695 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { 3719 3696 if (dev != &phba->pcidev->dev) { 3720 3697 shost = scsi_host_alloc(&lpfc_vport_template, 3721 3698 sizeof(struct lpfc_vport)); 3722 3699 } else { 3723 - if (phba->sli_rev == LPFC_SLI_REV4) 3700 + if (!use_no_reset_hba) 3724 3701 shost = scsi_host_alloc(&lpfc_template, 3725 3702 sizeof(struct lpfc_vport)); 3726 3703 else 3727 - shost = scsi_host_alloc(&lpfc_template_s3, 3704 + shost = scsi_host_alloc(&lpfc_template_no_hr, 3728 3705 sizeof(struct lpfc_vport)); 3729 3706 } 3730 3707 } else if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { ··· 3787 3734 INIT_LIST_HEAD(&vport->rcv_buffer_list); 3788 3735 spin_lock_init(&vport->work_port_lock); 3789 3736 3790 - init_timer(&vport->fc_disctmo); 3791 - vport->fc_disctmo.function = lpfc_disc_timeout; 3792 - vport->fc_disctmo.data = (unsigned long)vport; 3737 + setup_timer(&vport->fc_disctmo, lpfc_disc_timeout, 3738 + (unsigned long)vport); 3793 3739 3794 - init_timer(&vport->els_tmofunc); 3795 - vport->els_tmofunc.function = lpfc_els_timeout; 3796 - vport->els_tmofunc.data = (unsigned long)vport; 3740 + setup_timer(&vport->els_tmofunc, lpfc_els_timeout, 3741 + (unsigned long)vport); 3797 3742 3798 - init_timer(&vport->delayed_disc_tmo); 3799 - vport->delayed_disc_tmo.function = lpfc_delayed_disc_tmo; 3800 - vport->delayed_disc_tmo.data = (unsigned long)vport; 3743 + setup_timer(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 3744 + (unsigned long)vport); 3801 3745 3802 3746 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); 3803 3747 if (error) ··· 5456 5406 INIT_LIST_HEAD(&phba->luns); 5457 5407 5458 5408 /* MBOX heartbeat timer */ 5459 - init_timer(&psli->mbox_tmo); 5460 - psli->mbox_tmo.function = lpfc_mbox_timeout; 5461 - psli->mbox_tmo.data = (unsigned long) phba; 5409 + setup_timer(&psli->mbox_tmo, lpfc_mbox_timeout, (unsigned long)phba); 5462 5410 /* Fabric block timer */ 5463 - init_timer(&phba->fabric_block_timer); 5464 - phba->fabric_block_timer.function = lpfc_fabric_block_timeout; 5465 - phba->fabric_block_timer.data = (unsigned long) phba; 5411 + setup_timer(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 5412 + (unsigned long)phba); 5466 5413 /* EA polling mode timer */ 5467 - init_timer(&phba->eratt_poll); 5468 - phba->eratt_poll.function = lpfc_poll_eratt; 5469 - phba->eratt_poll.data = (unsigned long) phba; 5414 + setup_timer(&phba->eratt_poll, lpfc_poll_eratt, 5415 + (unsigned long)phba); 5470 5416 /* Heartbeat timer */ 5471 - init_timer(&phba->hb_tmofunc); 5472 - phba->hb_tmofunc.function = lpfc_hb_timeout; 5473 - phba->hb_tmofunc.data = (unsigned long)phba; 5417 + setup_timer(&phba->hb_tmofunc, lpfc_hb_timeout, (unsigned long)phba); 5474 5418 5475 5419 return 0; 5476 5420 } ··· 5490 5446 */ 5491 5447 5492 5448 /* FCP polling mode timer */ 5493 - init_timer(&phba->fcp_poll_timer); 5494 - phba->fcp_poll_timer.function = lpfc_poll_timeout; 5495 - phba->fcp_poll_timer.data = (unsigned long) phba; 5449 + setup_timer(&phba->fcp_poll_timer, lpfc_poll_timeout, 5450 + (unsigned long)phba); 5496 5451 5497 5452 /* Host attention work mask setup */ 5498 5453 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); ··· 5525 5482 5526 5483 /* Initialize the host templates the configured values. */ 5527 5484 lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt; 5528 - lpfc_template_s3.sg_tablesize = phba->cfg_sg_seg_cnt; 5485 + lpfc_template_no_hr.sg_tablesize = phba->cfg_sg_seg_cnt; 5486 + lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt; 5529 5487 5530 5488 /* There are going to be 2 reserved BDEs: 1 FCP cmnd + 1 FCP rsp */ 5531 5489 if (phba->cfg_enable_bg) { ··· 5661 5617 * Initialize timers used by driver 5662 5618 */ 5663 5619 5664 - init_timer(&phba->rrq_tmr); 5665 - phba->rrq_tmr.function = lpfc_rrq_timeout; 5666 - phba->rrq_tmr.data = (unsigned long)phba; 5620 + setup_timer(&phba->rrq_tmr, lpfc_rrq_timeout, (unsigned long)phba); 5667 5621 5668 5622 /* FCF rediscover timer */ 5669 - init_timer(&phba->fcf.redisc_wait); 5670 - phba->fcf.redisc_wait.function = lpfc_sli4_fcf_redisc_wait_tmo; 5671 - phba->fcf.redisc_wait.data = (unsigned long)phba; 5623 + setup_timer(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 5624 + (unsigned long)phba); 5672 5625 5673 5626 /* 5674 5627 * Control structure for handling external multi-buffer mailbox ··· 5747 5706 /* Initialize the host templates with the updated values. */ 5748 5707 lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt; 5749 5708 lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt; 5709 + lpfc_template_no_hr.sg_tablesize = phba->cfg_sg_seg_cnt; 5750 5710 5751 5711 if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) 5752 5712 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; ··· 5778 5736 /* Initialize the Abort nvme buffer list used by driver */ 5779 5737 spin_lock_init(&phba->sli4_hba.abts_nvme_buf_list_lock); 5780 5738 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvme_buf_list); 5739 + /* Fast-path XRI aborted CQ Event work queue list */ 5740 + INIT_LIST_HEAD(&phba->sli4_hba.sp_nvme_xri_aborted_work_queue); 5781 5741 } 5782 5742 5783 5743 /* This abort list used by worker thread */ ··· 8756 8712 } 8757 8713 } 8758 8714 8759 - /* 8760 - * Configure EQ delay multipier for interrupt coalescing using 8761 - * MODIFY_EQ_DELAY for all EQs created, LPFC_MAX_EQ_DELAY at a time. 8762 - */ 8763 - for (qidx = 0; qidx < io_channel; qidx += LPFC_MAX_EQ_DELAY) 8715 + for (qidx = 0; qidx < io_channel; qidx += LPFC_MAX_EQ_DELAY_EQID_CNT) 8764 8716 lpfc_modify_hba_eq_delay(phba, qidx); 8717 + 8765 8718 return 0; 8766 8719 8767 8720 out_destroy: ··· 9014 8973 /* Pending ELS XRI abort events */ 9015 8974 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, 9016 8975 &cqelist); 8976 + if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { 8977 + /* Pending NVME XRI abort events */ 8978 + list_splice_init(&phba->sli4_hba.sp_nvme_xri_aborted_work_queue, 8979 + &cqelist); 8980 + } 9017 8981 /* Pending asynnc events */ 9018 8982 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, 9019 8983 &cqelist); ··· 10446 10400 fc_remove_host(shost); 10447 10401 scsi_remove_host(shost); 10448 10402 10449 - /* Perform ndlp cleanup on the physical port. The nvme and nvmet 10450 - * localports are destroyed after to cleanup all transport memory. 10451 - */ 10452 10403 lpfc_cleanup(vport); 10453 - lpfc_nvmet_destroy_targetport(phba); 10454 - lpfc_nvme_destroy_localport(vport); 10455 10404 10456 10405 /* 10457 10406 * Bring down the SLI Layer. This step disable all interrupts, ··· 12059 12018 .id_table = lpfc_id_table, 12060 12019 .probe = lpfc_pci_probe_one, 12061 12020 .remove = lpfc_pci_remove_one, 12021 + .shutdown = lpfc_pci_remove_one, 12062 12022 .suspend = lpfc_pci_suspend_one, 12063 12023 .resume = lpfc_pci_resume_one, 12064 12024 .err_handler = &lpfc_err_handler,
+1 -1
drivers/scsi/lpfc/lpfc_mem.c
··· 646 646 } 647 647 648 648 dma_buf->iocbq = lpfc_sli_get_iocbq(phba); 649 - dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET; 650 649 if (!dma_buf->iocbq) { 651 650 kfree(dma_buf->context); 652 651 pci_pool_free(phba->lpfc_drb_pool, dma_buf->dbuf.virt, ··· 657 658 "2621 Ran out of nvmet iocb/WQEs\n"); 658 659 return NULL; 659 660 } 661 + dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET; 660 662 nvmewqe = dma_buf->iocbq; 661 663 wqe = (union lpfc_wqe128 *)&nvmewqe->wqe; 662 664 /* Initialize WQE */
+82 -25
drivers/scsi/lpfc/lpfc_nvme.c
··· 316 316 bf_set(wqe_dfctl, &wqe->gen_req.wge_ctl, 0); 317 317 bf_set(wqe_si, &wqe->gen_req.wge_ctl, 1); 318 318 bf_set(wqe_la, &wqe->gen_req.wge_ctl, 1); 319 - bf_set(wqe_rctl, &wqe->gen_req.wge_ctl, FC_RCTL_DD_UNSOL_CTL); 319 + bf_set(wqe_rctl, &wqe->gen_req.wge_ctl, FC_RCTL_ELS4_REQ); 320 320 bf_set(wqe_type, &wqe->gen_req.wge_ctl, FC_TYPE_NVME); 321 321 322 322 /* Word 6 */ ··· 620 620 * Embed the payload in the last half of the WQE 621 621 * WQE words 16-30 get the NVME CMD IU payload 622 622 * 623 - * WQE Word 16 is already setup with flags 624 - * WQE words 17-19 get payload Words 2-4 623 + * WQE words 16-19 get payload Words 1-4 625 624 * WQE words 20-21 get payload Words 6-7 626 625 * WQE words 22-29 get payload Words 16-23 627 626 */ 628 - wptr = &wqe->words[17]; /* WQE ptr */ 627 + wptr = &wqe->words[16]; /* WQE ptr */ 629 628 dptr = (uint32_t *)nCmd->cmdaddr; /* payload ptr */ 630 - dptr += 2; /* Skip Words 0-1 in payload */ 629 + dptr++; /* Skip Word 0 in payload */ 631 630 631 + *wptr++ = *dptr++; /* Word 1 */ 632 632 *wptr++ = *dptr++; /* Word 2 */ 633 633 *wptr++ = *dptr++; /* Word 3 */ 634 634 *wptr++ = *dptr++; /* Word 4 */ ··· 978 978 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, 979 979 NVME_WRITE_CMD); 980 980 981 - /* Word 16 */ 982 - wqe->words[16] = LPFC_NVME_EMBED_WRITE; 983 - 984 981 phba->fc4NvmeOutputRequests++; 985 982 } else { 986 983 /* Word 7 */ ··· 999 1002 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, 1000 1003 NVME_READ_CMD); 1001 1004 1002 - /* Word 16 */ 1003 - wqe->words[16] = LPFC_NVME_EMBED_READ; 1004 - 1005 1005 phba->fc4NvmeInputRequests++; 1006 1006 } 1007 1007 } else { ··· 1019 1025 1020 1026 /* Word 11 */ 1021 1027 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, NVME_READ_CMD); 1022 - 1023 - /* Word 16 */ 1024 - wqe->words[16] = LPFC_NVME_EMBED_CMD; 1025 1028 1026 1029 phba->fc4NvmeControlRequests++; 1027 1030 } ··· 1277 1286 pnvme_fcreq->private = (void *)lpfc_ncmd; 1278 1287 lpfc_ncmd->nvmeCmd = pnvme_fcreq; 1279 1288 lpfc_ncmd->nrport = rport; 1289 + lpfc_ncmd->ndlp = ndlp; 1280 1290 lpfc_ncmd->start_time = jiffies; 1281 1291 1282 1292 lpfc_nvme_prep_io_cmd(vport, lpfc_ncmd, ndlp); ··· 1311 1319 "sid: x%x did: x%x oxid: x%x\n", 1312 1320 ret, vport->fc_myDID, ndlp->nlp_DID, 1313 1321 lpfc_ncmd->cur_iocbq.sli4_xritag); 1314 - ret = -EINVAL; 1322 + ret = -EBUSY; 1315 1323 goto out_free_nvme_buf; 1316 1324 } 1317 1325 ··· 1813 1821 pdma_phys_sgl1, cur_xritag); 1814 1822 if (status) { 1815 1823 /* failure, put on abort nvme list */ 1816 - lpfc_ncmd->exch_busy = 1; 1824 + lpfc_ncmd->flags |= LPFC_SBUF_XBUSY; 1817 1825 } else { 1818 1826 /* success, put on NVME buffer list */ 1819 - lpfc_ncmd->exch_busy = 0; 1827 + lpfc_ncmd->flags &= ~LPFC_SBUF_XBUSY; 1820 1828 lpfc_ncmd->status = IOSTAT_SUCCESS; 1821 1829 num_posted++; 1822 1830 } ··· 1846 1854 struct lpfc_nvme_buf, list); 1847 1855 if (status) { 1848 1856 /* failure, put on abort nvme list */ 1849 - lpfc_ncmd->exch_busy = 1; 1857 + lpfc_ncmd->flags |= LPFC_SBUF_XBUSY; 1850 1858 } else { 1851 1859 /* success, put on NVME buffer list */ 1852 - lpfc_ncmd->exch_busy = 0; 1860 + lpfc_ncmd->flags &= ~LPFC_SBUF_XBUSY; 1853 1861 lpfc_ncmd->status = IOSTAT_SUCCESS; 1854 1862 num_posted++; 1855 1863 } ··· 2091 2099 unsigned long iflag = 0; 2092 2100 2093 2101 lpfc_ncmd->nonsg_phys = 0; 2094 - if (lpfc_ncmd->exch_busy) { 2102 + if (lpfc_ncmd->flags & LPFC_SBUF_XBUSY) { 2095 2103 spin_lock_irqsave(&phba->sli4_hba.abts_nvme_buf_list_lock, 2096 2104 iflag); 2097 2105 lpfc_ncmd->nvmeCmd = NULL; ··· 2127 2135 int 2128 2136 lpfc_nvme_create_localport(struct lpfc_vport *vport) 2129 2137 { 2138 + int ret = 0; 2130 2139 struct lpfc_hba *phba = vport->phba; 2131 2140 struct nvme_fc_port_info nfcp_info; 2132 2141 struct nvme_fc_local_port *localport; 2133 2142 struct lpfc_nvme_lport *lport; 2134 - int len, ret = 0; 2143 + int len; 2135 2144 2136 2145 /* Initialize this localport instance. The vport wwn usage ensures 2137 2146 * that NPIV is accounted for. ··· 2149 2156 /* localport is allocated from the stack, but the registration 2150 2157 * call allocates heap memory as well as the private area. 2151 2158 */ 2159 + #ifdef CONFIG_LPFC_NVME_INITIATOR 2152 2160 ret = nvme_fc_register_localport(&nfcp_info, &lpfc_nvme_template, 2153 2161 &vport->phba->pcidev->dev, &localport); 2162 + #else 2163 + ret = -ENOMEM; 2164 + #endif 2154 2165 if (!ret) { 2155 2166 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME | LOG_NVME_DISC, 2156 2167 "6005 Successfully registered local " ··· 2170 2173 lport->vport = vport; 2171 2174 INIT_LIST_HEAD(&lport->rport_list); 2172 2175 vport->nvmei_support = 1; 2176 + len = lpfc_new_nvme_buf(vport, phba->sli4_hba.nvme_xri_max); 2177 + vport->phba->total_nvme_bufs += len; 2173 2178 } 2174 2179 2175 - len = lpfc_new_nvme_buf(vport, phba->sli4_hba.nvme_xri_max); 2176 - vport->phba->total_nvme_bufs += len; 2177 2180 return ret; 2178 2181 } 2179 2182 ··· 2190 2193 void 2191 2194 lpfc_nvme_destroy_localport(struct lpfc_vport *vport) 2192 2195 { 2196 + #ifdef CONFIG_LPFC_NVME_INITIATOR 2193 2197 struct nvme_fc_local_port *localport; 2194 2198 struct lpfc_nvme_lport *lport; 2195 2199 struct lpfc_nvme_rport *rport = NULL, *rport_next = NULL; ··· 2206 2208 lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME, 2207 2209 "6011 Destroying NVME localport %p\n", 2208 2210 localport); 2209 - 2210 2211 list_for_each_entry_safe(rport, rport_next, &lport->rport_list, list) { 2211 2212 /* The last node ref has to get released now before the rport 2212 2213 * private memory area is released by the transport. ··· 2219 2222 "6008 rport fail destroy %x\n", ret); 2220 2223 wait_for_completion_timeout(&rport->rport_unreg_done, 5); 2221 2224 } 2225 + 2222 2226 /* lport's rport list is clear. Unregister 2223 2227 * lport and release resources. 2224 2228 */ ··· 2243 2245 "Failed, status x%x\n", 2244 2246 ret); 2245 2247 } 2248 + #endif 2246 2249 } 2247 2250 2248 2251 void ··· 2274 2275 int 2275 2276 lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) 2276 2277 { 2278 + #ifdef CONFIG_LPFC_NVME_INITIATOR 2277 2279 int ret = 0; 2278 2280 struct nvme_fc_local_port *localport; 2279 2281 struct lpfc_nvme_lport *lport; ··· 2348 2348 rpinfo.port_role |= FC_PORT_ROLE_NVME_INITIATOR; 2349 2349 rpinfo.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn); 2350 2350 rpinfo.node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn); 2351 - 2352 2351 ret = nvme_fc_register_remoteport(localport, &rpinfo, 2353 2352 &remote_port); 2354 2353 if (!ret) { ··· 2383 2384 ndlp->nlp_type, ndlp->nlp_DID, ndlp); 2384 2385 } 2385 2386 return ret; 2387 + #else 2388 + return 0; 2389 + #endif 2386 2390 } 2387 2391 2388 2392 /* lpfc_nvme_unregister_port - unbind the DID and port_role from this rport. ··· 2403 2401 void 2404 2402 lpfc_nvme_unregister_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) 2405 2403 { 2404 + #ifdef CONFIG_LPFC_NVME_INITIATOR 2406 2405 int ret; 2407 2406 struct nvme_fc_local_port *localport; 2408 2407 struct lpfc_nvme_lport *lport; ··· 2461 2458 return; 2462 2459 2463 2460 input_err: 2461 + #endif 2464 2462 lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC, 2465 2463 "6168: State error: lport %p, rport%p FCID x%06x\n", 2466 2464 vport->localport, ndlp->rport, ndlp->nlp_DID); 2465 + } 2466 + 2467 + /** 2468 + * lpfc_sli4_nvme_xri_aborted - Fast-path process of NVME xri abort 2469 + * @phba: pointer to lpfc hba data structure. 2470 + * @axri: pointer to the fcp xri abort wcqe structure. 2471 + * 2472 + * This routine is invoked by the worker thread to process a SLI4 fast-path 2473 + * FCP aborted xri. 2474 + **/ 2475 + void 2476 + lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba, 2477 + struct sli4_wcqe_xri_aborted *axri) 2478 + { 2479 + uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); 2480 + uint16_t rxid = bf_get(lpfc_wcqe_xa_remote_xid, axri); 2481 + struct lpfc_nvme_buf *lpfc_ncmd, *next_lpfc_ncmd; 2482 + struct lpfc_nodelist *ndlp; 2483 + unsigned long iflag = 0; 2484 + int rrq_empty = 0; 2485 + 2486 + if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) 2487 + return; 2488 + spin_lock_irqsave(&phba->hbalock, iflag); 2489 + spin_lock(&phba->sli4_hba.abts_nvme_buf_list_lock); 2490 + list_for_each_entry_safe(lpfc_ncmd, next_lpfc_ncmd, 2491 + &phba->sli4_hba.lpfc_abts_nvme_buf_list, 2492 + list) { 2493 + if (lpfc_ncmd->cur_iocbq.sli4_xritag == xri) { 2494 + list_del(&lpfc_ncmd->list); 2495 + lpfc_ncmd->flags &= ~LPFC_SBUF_XBUSY; 2496 + lpfc_ncmd->status = IOSTAT_SUCCESS; 2497 + spin_unlock( 2498 + &phba->sli4_hba.abts_nvme_buf_list_lock); 2499 + 2500 + rrq_empty = list_empty(&phba->active_rrq_list); 2501 + spin_unlock_irqrestore(&phba->hbalock, iflag); 2502 + ndlp = lpfc_ncmd->ndlp; 2503 + if (ndlp) { 2504 + lpfc_set_rrq_active( 2505 + phba, ndlp, 2506 + lpfc_ncmd->cur_iocbq.sli4_lxritag, 2507 + rxid, 1); 2508 + lpfc_sli4_abts_err_handler(phba, ndlp, axri); 2509 + } 2510 + lpfc_release_nvme_buf(phba, lpfc_ncmd); 2511 + if (rrq_empty) 2512 + lpfc_worker_wake_up(phba); 2513 + return; 2514 + } 2515 + } 2516 + spin_unlock(&phba->sli4_hba.abts_nvme_buf_list_lock); 2517 + spin_unlock_irqrestore(&phba->hbalock, iflag); 2467 2518 }
+1
drivers/scsi/lpfc/lpfc_nvme.h
··· 57 57 struct list_head list; 58 58 struct nvmefc_fcp_req *nvmeCmd; 59 59 struct lpfc_nvme_rport *nrport; 60 + struct lpfc_nodelist *ndlp; 60 61 61 62 uint32_t timeout; 62 63
+35 -8
drivers/scsi/lpfc/lpfc_nvmet.c
··· 571 571 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 572 572 "6102 Bad state IO x%x aborted\n", 573 573 ctxp->oxid); 574 + rc = -ENXIO; 574 575 goto aerr; 575 576 } 576 577 ··· 581 580 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 582 581 "6152 FCP Drop IO x%x: Prep\n", 583 582 ctxp->oxid); 583 + rc = -ENXIO; 584 584 goto aerr; 585 585 } 586 586 ··· 620 618 ctxp->wqeq->hba_wqidx = 0; 621 619 nvmewqeq->context2 = NULL; 622 620 nvmewqeq->context3 = NULL; 621 + rc = -EBUSY; 623 622 aerr: 624 - return -ENXIO; 623 + return rc; 625 624 } 626 625 627 626 static void ··· 671 668 lpfc_tgttemplate.target_features = NVMET_FCTGTFEAT_READDATA_RSP | 672 669 NVMET_FCTGTFEAT_NEEDS_CMD_CPUSCHED; 673 670 671 + #ifdef CONFIG_LPFC_NVME_TARGET 674 672 error = nvmet_fc_register_targetport(&pinfo, &lpfc_tgttemplate, 675 673 &phba->pcidev->dev, 676 674 &phba->targetport); 675 + #else 676 + error = -ENOMEM; 677 + #endif 677 678 if (error) { 678 679 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_DISC, 679 680 "6025 Cannot register NVME targetport " ··· 738 731 return 0; 739 732 } 740 733 734 + /** 735 + * lpfc_sli4_nvmet_xri_aborted - Fast-path process of nvmet xri abort 736 + * @phba: pointer to lpfc hba data structure. 737 + * @axri: pointer to the nvmet xri abort wcqe structure. 738 + * 739 + * This routine is invoked by the worker thread to process a SLI4 fast-path 740 + * NVMET aborted xri. 741 + **/ 742 + void 743 + lpfc_sli4_nvmet_xri_aborted(struct lpfc_hba *phba, 744 + struct sli4_wcqe_xri_aborted *axri) 745 + { 746 + /* TODO: work in progress */ 747 + } 748 + 741 749 void 742 750 lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba) 743 751 { 752 + #ifdef CONFIG_LPFC_NVME_TARGET 744 753 struct lpfc_nvmet_tgtport *tgtp; 745 754 746 755 if (phba->nvmet_support == 0) ··· 768 745 wait_for_completion_timeout(&tgtp->tport_unreg_done, 5); 769 746 } 770 747 phba->targetport = NULL; 748 + #endif 771 749 } 772 750 773 751 /** ··· 788 764 lpfc_nvmet_unsol_ls_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 789 765 struct hbq_dmabuf *nvmebuf) 790 766 { 767 + #ifdef CONFIG_LPFC_NVME_TARGET 791 768 struct lpfc_nvmet_tgtport *tgtp; 792 769 struct fc_frame_header *fc_hdr; 793 770 struct lpfc_nvmet_rcv_ctx *ctxp; ··· 869 844 870 845 atomic_inc(&tgtp->xmt_ls_abort); 871 846 lpfc_nvmet_unsol_ls_issue_abort(phba, ctxp, sid, oxid); 847 + #endif 872 848 } 873 849 874 850 /** ··· 891 865 struct rqb_dmabuf *nvmebuf, 892 866 uint64_t isr_timestamp) 893 867 { 868 + #ifdef CONFIG_LPFC_NVME_TARGET 894 869 struct lpfc_nvmet_rcv_ctx *ctxp; 895 870 struct lpfc_nvmet_tgtport *tgtp; 896 871 struct fc_frame_header *fc_hdr; ··· 982 955 983 956 atomic_inc(&tgtp->rcv_fcp_cmd_drop); 984 957 lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR, 985 - "6159 FCP Drop IO x%x: nvmet_fc_rcv_fcp_req x%x\n", 958 + "6159 FCP Drop IO x%x: err x%x\n", 986 959 ctxp->oxid, rc); 987 960 dropit: 988 961 lpfc_nvmeio_data(phba, "NVMET FCP DROP: xri x%x sz %d from %06x\n", ··· 997 970 /* We assume a rcv'ed cmd ALWAYs fits into 1 buffer */ 998 971 lpfc_nvmet_rq_post(phba, NULL, &nvmebuf->hbuf); 999 972 } 973 + #endif 1000 974 } 1001 975 1002 976 /** ··· 1142 1114 bf_set(wqe_dfctl, &wqe->xmit_sequence.wge_ctl, 0); 1143 1115 bf_set(wqe_ls, &wqe->xmit_sequence.wge_ctl, 1); 1144 1116 bf_set(wqe_la, &wqe->xmit_sequence.wge_ctl, 0); 1145 - bf_set(wqe_rctl, &wqe->xmit_sequence.wge_ctl, FC_RCTL_DD_SOL_CTL); 1117 + bf_set(wqe_rctl, &wqe->xmit_sequence.wge_ctl, FC_RCTL_ELS4_REP); 1146 1118 bf_set(wqe_type, &wqe->xmit_sequence.wge_ctl, FC_TYPE_NVME); 1147 1119 1148 1120 /* Word 6 */ ··· 1473 1445 1474 1446 case NVMET_FCOP_RSP: 1475 1447 /* Words 0 - 2 */ 1476 - sgel = &rsp->sg[0]; 1477 1448 physaddr = rsp->rspdma; 1478 1449 wqe->fcp_trsp.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; 1479 1450 wqe->fcp_trsp.bde.tus.f.bdeSize = rsp->rsplen; ··· 1708 1681 struct lpfc_nodelist *ndlp; 1709 1682 1710 1683 lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, 1711 - "6067 %s: Entrypoint: sid %x xri %x\n", __func__, 1712 - sid, xri); 1684 + "6067 Abort: sid %x xri x%x/x%x\n", 1685 + sid, xri, ctxp->wqeq->sli4_xritag); 1713 1686 1714 1687 tgtp = (struct lpfc_nvmet_tgtport *)phba->targetport->private; 1715 1688 ··· 1720 1693 atomic_inc(&tgtp->xmt_abort_rsp_error); 1721 1694 lpfc_printf_log(phba, KERN_WARNING, LOG_NVME_ABTS, 1722 1695 "6134 Drop ABTS - wrong NDLP state x%x.\n", 1723 - ndlp->nlp_state); 1696 + (ndlp) ? ndlp->nlp_state : NLP_STE_MAX_STATE); 1724 1697 1725 1698 /* No failure to an ABTS request. */ 1726 1699 return 0; ··· 1818 1791 atomic_inc(&tgtp->xmt_abort_rsp_error); 1819 1792 lpfc_printf_log(phba, KERN_WARNING, LOG_NVME_ABTS, 1820 1793 "6160 Drop ABTS - wrong NDLP state x%x.\n", 1821 - ndlp->nlp_state); 1794 + (ndlp) ? ndlp->nlp_state : NLP_STE_MAX_STATE); 1822 1795 1823 1796 /* No failure to an ABTS request. */ 1824 1797 return 0;
+2 -2
drivers/scsi/lpfc/lpfc_scsi.c
··· 5953 5953 .track_queue_depth = 0, 5954 5954 }; 5955 5955 5956 - struct scsi_host_template lpfc_template_s3 = { 5956 + struct scsi_host_template lpfc_template_no_hr = { 5957 5957 .module = THIS_MODULE, 5958 5958 .name = LPFC_DRIVER_NAME, 5959 5959 .proc_name = LPFC_DRIVER_NAME, 5960 5960 .info = lpfc_info, 5961 5961 .queuecommand = lpfc_queuecommand, 5962 + .eh_timed_out = fc_eh_timed_out, 5962 5963 .eh_abort_handler = lpfc_abort_handler, 5963 5964 .eh_device_reset_handler = lpfc_device_reset_handler, 5964 5965 .eh_target_reset_handler = lpfc_target_reset_handler, ··· 6016 6015 .eh_abort_handler = lpfc_abort_handler, 6017 6016 .eh_device_reset_handler = lpfc_device_reset_handler, 6018 6017 .eh_target_reset_handler = lpfc_target_reset_handler, 6019 - .eh_bus_reset_handler = lpfc_bus_reset_handler, 6020 6018 .slave_alloc = lpfc_slave_alloc, 6021 6019 .slave_configure = lpfc_slave_configure, 6022 6020 .slave_destroy = lpfc_slave_destroy,
+59 -9
drivers/scsi/lpfc/lpfc_sli.c
··· 1 + 1 2 /******************************************************************* 2 3 * This file is part of the Emulex Linux Device Driver for * 3 4 * Fibre Channel Host Bus Adapters. * ··· 953 952 start_sglq = sglq; 954 953 while (!found) { 955 954 if (!sglq) 956 - return NULL; 955 + break; 957 956 if (ndlp && ndlp->active_rrqs_xri_bitmap && 958 957 test_bit(sglq->sli4_lxritag, 959 958 ndlp->active_rrqs_xri_bitmap)) { ··· 12214 12213 } 12215 12214 12216 12215 /** 12216 + * lpfc_sli4_nvme_xri_abort_event_proc - Process nvme xri abort event 12217 + * @phba: pointer to lpfc hba data structure. 12218 + * 12219 + * This routine is invoked by the worker thread to process all the pending 12220 + * SLI4 NVME abort XRI events. 12221 + **/ 12222 + void lpfc_sli4_nvme_xri_abort_event_proc(struct lpfc_hba *phba) 12223 + { 12224 + struct lpfc_cq_event *cq_event; 12225 + 12226 + /* First, declare the fcp xri abort event has been handled */ 12227 + spin_lock_irq(&phba->hbalock); 12228 + phba->hba_flag &= ~NVME_XRI_ABORT_EVENT; 12229 + spin_unlock_irq(&phba->hbalock); 12230 + /* Now, handle all the fcp xri abort events */ 12231 + while (!list_empty(&phba->sli4_hba.sp_nvme_xri_aborted_work_queue)) { 12232 + /* Get the first event from the head of the event queue */ 12233 + spin_lock_irq(&phba->hbalock); 12234 + list_remove_head(&phba->sli4_hba.sp_nvme_xri_aborted_work_queue, 12235 + cq_event, struct lpfc_cq_event, list); 12236 + spin_unlock_irq(&phba->hbalock); 12237 + /* Notify aborted XRI for NVME work queue */ 12238 + if (phba->nvmet_support) { 12239 + lpfc_sli4_nvmet_xri_aborted(phba, 12240 + &cq_event->cqe.wcqe_axri); 12241 + } else { 12242 + lpfc_sli4_nvme_xri_aborted(phba, 12243 + &cq_event->cqe.wcqe_axri); 12244 + } 12245 + /* Free the event processed back to the free pool */ 12246 + lpfc_sli4_cq_event_release(phba, cq_event); 12247 + } 12248 + } 12249 + 12250 + /** 12217 12251 * lpfc_sli4_els_xri_abort_event_proc - Process els xri abort event 12218 12252 * @phba: pointer to lpfc hba data structure. 12219 12253 * ··· 12745 12709 spin_unlock_irqrestore(&phba->hbalock, iflags); 12746 12710 workposted = true; 12747 12711 break; 12712 + case LPFC_NVME: 12713 + spin_lock_irqsave(&phba->hbalock, iflags); 12714 + list_add_tail(&cq_event->list, 12715 + &phba->sli4_hba.sp_nvme_xri_aborted_work_queue); 12716 + /* Set the nvme xri abort event flag */ 12717 + phba->hba_flag |= NVME_XRI_ABORT_EVENT; 12718 + spin_unlock_irqrestore(&phba->hbalock, iflags); 12719 + workposted = true; 12720 + break; 12748 12721 default: 12749 12722 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 12750 - "0603 Invalid work queue CQE subtype (x%x)\n", 12751 - cq->subtype); 12723 + "0603 Invalid CQ subtype %d: " 12724 + "%08x %08x %08x %08x\n", 12725 + cq->subtype, wcqe->word0, wcqe->parameter, 12726 + wcqe->word2, wcqe->word3); 12727 + lpfc_sli4_cq_event_release(phba, cq_event); 12752 12728 workposted = false; 12753 12729 break; 12754 12730 } ··· 13875 13827 * @startq: The starting FCP EQ to modify 13876 13828 * 13877 13829 * This function sends an MODIFY_EQ_DELAY mailbox command to the HBA. 13830 + * The command allows up to LPFC_MAX_EQ_DELAY_EQID_CNT EQ ID's to be 13831 + * updated in one mailbox command. 13878 13832 * 13879 13833 * The @phba struct is used to send mailbox command to HBA. The @startq 13880 13834 * is used to get the starting FCP EQ to change. ··· 13929 13879 eq_delay->u.request.eq[cnt].phase = 0; 13930 13880 eq_delay->u.request.eq[cnt].delay_multi = dmult; 13931 13881 cnt++; 13932 - if (cnt >= LPFC_MAX_EQ_DELAY) 13882 + if (cnt >= LPFC_MAX_EQ_DELAY_EQID_CNT) 13933 13883 break; 13934 13884 } 13935 13885 eq_delay->u.request.num_eq = cnt; ··· 15235 15185 drq = drqp[idx]; 15236 15186 cq = cqp[idx]; 15237 15187 15238 - if (hrq->entry_count != drq->entry_count) { 15239 - status = -EINVAL; 15240 - goto out; 15241 - } 15242 - 15243 15188 /* sanity check on queue memory */ 15244 15189 if (!hrq || !drq || !cq) { 15245 15190 status = -ENODEV; 15191 + goto out; 15192 + } 15193 + 15194 + if (hrq->entry_count != drq->entry_count) { 15195 + status = -EINVAL; 15246 15196 goto out; 15247 15197 } 15248 15198
+6
drivers/scsi/lpfc/lpfc_sli4.h
··· 642 642 struct list_head sp_asynce_work_queue; 643 643 struct list_head sp_fcp_xri_aborted_work_queue; 644 644 struct list_head sp_els_xri_aborted_work_queue; 645 + struct list_head sp_nvme_xri_aborted_work_queue; 645 646 struct list_head sp_unsol_work_queue; 646 647 struct lpfc_sli4_link link_state; 647 648 struct lpfc_sli4_lnk_info lnk_info; ··· 795 794 int lpfc_sli4_resume_rpi(struct lpfc_nodelist *, 796 795 void (*)(struct lpfc_hba *, LPFC_MBOXQ_t *), void *); 797 796 void lpfc_sli4_fcp_xri_abort_event_proc(struct lpfc_hba *); 797 + void lpfc_sli4_nvme_xri_abort_event_proc(struct lpfc_hba *phba); 798 798 void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *); 799 799 void lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *, 800 800 struct sli4_wcqe_xri_aborted *); 801 + void lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba, 802 + struct sli4_wcqe_xri_aborted *axri); 803 + void lpfc_sli4_nvmet_xri_aborted(struct lpfc_hba *phba, 804 + struct sli4_wcqe_xri_aborted *axri); 801 805 void lpfc_sli4_els_xri_aborted(struct lpfc_hba *, 802 806 struct sli4_wcqe_xri_aborted *); 803 807 void lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *);
+1 -1
drivers/scsi/lpfc/lpfc_version.h
··· 20 20 * included with this package. * 21 21 *******************************************************************/ 22 22 23 - #define LPFC_DRIVER_VERSION "11.2.0.7" 23 + #define LPFC_DRIVER_VERSION "11.2.0.10" 24 24 #define LPFC_DRIVER_NAME "lpfc" 25 25 26 26 /* Used for SLI 2/3 */
-3
drivers/scsi/mpt3sas/mpt3sas_base.h
··· 1442 1442 u64 sas_address, u16 handle, u8 phy_number, u8 link_rate); 1443 1443 extern struct sas_function_template mpt3sas_transport_functions; 1444 1444 extern struct scsi_transport_template *mpt3sas_transport_template; 1445 - extern int scsi_internal_device_block(struct scsi_device *sdev); 1446 - extern int scsi_internal_device_unblock(struct scsi_device *sdev, 1447 - enum scsi_device_state new_state); 1448 1445 /* trigger data externs */ 1449 1446 void mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc, 1450 1447 struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data);
+2 -17
drivers/scsi/mpt3sas/mpt3sas_scsih.c
··· 2859 2859 sas_device_priv_data->sas_target->handle); 2860 2860 sas_device_priv_data->block = 1; 2861 2861 2862 - r = scsi_internal_device_block(sdev); 2862 + r = scsi_internal_device_block(sdev, false); 2863 2863 if (r == -EINVAL) 2864 2864 sdev_printk(KERN_WARNING, sdev, 2865 2865 "device_block failed with return(%d) for handle(0x%04x)\n", ··· 2895 2895 "performing a block followed by an unblock\n", 2896 2896 r, sas_device_priv_data->sas_target->handle); 2897 2897 sas_device_priv_data->block = 1; 2898 - r = scsi_internal_device_block(sdev); 2898 + r = scsi_internal_device_block(sdev, false); 2899 2899 if (r) 2900 2900 sdev_printk(KERN_WARNING, sdev, "retried device_block " 2901 2901 "failed with return(%d) for handle(0x%04x)\n", ··· 4677 4677 struct MPT3SAS_DEVICE *sas_device_priv_data; 4678 4678 u32 response_code = 0; 4679 4679 unsigned long flags; 4680 - unsigned int sector_sz; 4681 4680 4682 4681 mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply); 4683 4682 ··· 4741 4742 } 4742 4743 4743 4744 xfer_cnt = le32_to_cpu(mpi_reply->TransferCount); 4744 - 4745 - /* In case of bogus fw or device, we could end up having 4746 - * unaligned partial completion. We can force alignment here, 4747 - * then scsi-ml does not need to handle this misbehavior. 4748 - */ 4749 - sector_sz = scmd->device->sector_size; 4750 - if (unlikely(!blk_rq_is_passthrough(scmd->request) && sector_sz && 4751 - xfer_cnt % sector_sz)) { 4752 - sdev_printk(KERN_INFO, scmd->device, 4753 - "unaligned partial completion avoided (xfer_cnt=%u, sector_sz=%u)\n", 4754 - xfer_cnt, sector_sz); 4755 - xfer_cnt = round_down(xfer_cnt, sector_sz); 4756 - } 4757 - 4758 4745 scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt); 4759 4746 if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) 4760 4747 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
+8 -5
drivers/scsi/qedf/qedf_dbg.h
··· 81 81 #define QEDF_INFO(pdev, level, fmt, ...) \ 82 82 qedf_dbg_info(pdev, __func__, __LINE__, level, fmt, \ 83 83 ## __VA_ARGS__) 84 - 85 - extern void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 84 + __printf(4, 5) 85 + void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 86 86 const char *fmt, ...); 87 - extern void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 87 + __printf(4, 5) 88 + void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 88 89 const char *, ...); 89 - extern void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, 90 + __printf(4, 5) 91 + void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func, 90 92 u32 line, const char *, ...); 91 - extern void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 93 + __printf(5, 6) 94 + void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line, 92 95 u32 info, const char *fmt, ...); 93 96 94 97 /* GRC Dump related defines */
+1 -1
drivers/scsi/qedf/qedf_fip.c
··· 203 203 case FIP_DT_MAC: 204 204 mp = (struct fip_mac_desc *)desc; 205 205 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, 206 - "fd_mac=%pM.\n", __func__, mp->fd_mac); 206 + "fd_mac=%pM\n", mp->fd_mac); 207 207 ether_addr_copy(cvl_mac, mp->fd_mac); 208 208 break; 209 209 case FIP_DT_NAME:
+2 -2
drivers/scsi/qedf/qedf_io.c
··· 1342 1342 } else { 1343 1343 refcount = kref_read(&io_req->refcount); 1344 1344 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, 1345 - "%d:0:%d:%d xid=0x%0x op=0x%02x " 1345 + "%d:0:%d:%lld xid=0x%0x op=0x%02x " 1346 1346 "lba=%02x%02x%02x%02x cdb_status=%d " 1347 1347 "fcp_resid=0x%x refcount=%d.\n", 1348 1348 qedf->lport->host->host_no, sc_cmd->device->id, ··· 1426 1426 1427 1427 sc_cmd->result = result << 16; 1428 1428 refcount = kref_read(&io_req->refcount); 1429 - QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, "%d:0:%d:%d: Completing " 1429 + QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, "%d:0:%d:%lld: Completing " 1430 1430 "sc_cmd=%p result=0x%08x op=0x%02x lba=0x%02x%02x%02x%02x, " 1431 1431 "allowed=%d retries=%d refcount=%d.\n", 1432 1432 qedf->lport->host->host_no, sc_cmd->device->id,
+2 -2
drivers/scsi/qedf/qedf_main.c
··· 2456 2456 } 2457 2457 2458 2458 QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, 2459 - "BDQ PBL addr=0x%p dma=0x%llx.\n", qedf->bdq_pbl, 2460 - qedf->bdq_pbl_dma); 2459 + "BDQ PBL addr=0x%p dma=%pad\n", 2460 + qedf->bdq_pbl, &qedf->bdq_pbl_dma); 2461 2461 2462 2462 /* 2463 2463 * Populate BDQ PBL with physical and virtual address of individual
+8 -8
drivers/scsi/qedi/qedi_debugfs.c
··· 14 14 #include <linux/debugfs.h> 15 15 #include <linux/module.h> 16 16 17 - int do_not_recover; 17 + int qedi_do_not_recover; 18 18 static struct dentry *qedi_dbg_root; 19 19 20 20 void ··· 74 74 static ssize_t 75 75 qedi_dbg_do_not_recover_enable(struct qedi_dbg_ctx *qedi_dbg) 76 76 { 77 - if (!do_not_recover) 78 - do_not_recover = 1; 77 + if (!qedi_do_not_recover) 78 + qedi_do_not_recover = 1; 79 79 80 80 QEDI_INFO(qedi_dbg, QEDI_LOG_DEBUGFS, "do_not_recover=%d\n", 81 - do_not_recover); 81 + qedi_do_not_recover); 82 82 return 0; 83 83 } 84 84 85 85 static ssize_t 86 86 qedi_dbg_do_not_recover_disable(struct qedi_dbg_ctx *qedi_dbg) 87 87 { 88 - if (do_not_recover) 89 - do_not_recover = 0; 88 + if (qedi_do_not_recover) 89 + qedi_do_not_recover = 0; 90 90 91 91 QEDI_INFO(qedi_dbg, QEDI_LOG_DEBUGFS, "do_not_recover=%d\n", 92 - do_not_recover); 92 + qedi_do_not_recover); 93 93 return 0; 94 94 } 95 95 ··· 141 141 if (*ppos) 142 142 return 0; 143 143 144 - cnt = sprintf(buffer, "do_not_recover=%d\n", do_not_recover); 144 + cnt = sprintf(buffer, "do_not_recover=%d\n", qedi_do_not_recover); 145 145 cnt = min_t(int, count, cnt - *ppos); 146 146 *ppos += cnt; 147 147 return cnt;
+2 -2
drivers/scsi/qedi/qedi_fw.c
··· 1461 1461 get_itt(tmf_hdr->rtt), get_itt(ctask->itt), cmd->task_id, 1462 1462 qedi_conn->iscsi_conn_id); 1463 1463 1464 - if (do_not_recover) { 1464 + if (qedi_do_not_recover) { 1465 1465 QEDI_ERR(&qedi->dbg_ctx, "DONT SEND CLEANUP/ABORT %d\n", 1466 - do_not_recover); 1466 + qedi_do_not_recover); 1467 1467 goto abort_ret; 1468 1468 } 1469 1469
+7 -1
drivers/scsi/qedi/qedi_gbl.h
··· 12 12 13 13 #include "qedi_iscsi.h" 14 14 15 + #ifdef CONFIG_DEBUG_FS 16 + extern int qedi_do_not_recover; 17 + #else 18 + #define qedi_do_not_recover (0) 19 + #endif 20 + 15 21 extern uint qedi_io_tracing; 16 - extern int do_not_recover; 22 + 17 23 extern struct scsi_host_template qedi_host_template; 18 24 extern struct iscsi_transport qedi_iscsi_transport; 19 25 extern const struct qed_iscsi_ops *qedi_ops;
+4 -4
drivers/scsi/qedi/qedi_iscsi.c
··· 833 833 return ERR_PTR(ret); 834 834 } 835 835 836 - if (do_not_recover) { 836 + if (qedi_do_not_recover) { 837 837 ret = -ENOMEM; 838 838 return ERR_PTR(ret); 839 839 } ··· 957 957 struct qedi_endpoint *qedi_ep; 958 958 int ret = 0; 959 959 960 - if (do_not_recover) 960 + if (qedi_do_not_recover) 961 961 return 1; 962 962 963 963 qedi_ep = ep->dd_data; ··· 1025 1025 } 1026 1026 1027 1027 if (test_bit(QEDI_IN_RECOVERY, &qedi->flags)) { 1028 - if (do_not_recover) { 1028 + if (qedi_do_not_recover) { 1029 1029 QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, 1030 1030 "Do not recover cid=0x%x\n", 1031 1031 qedi_ep->iscsi_cid); ··· 1039 1039 } 1040 1040 } 1041 1041 1042 - if (do_not_recover) 1042 + if (qedi_do_not_recover) 1043 1043 goto ep_exit_recover; 1044 1044 1045 1045 switch (qedi_ep->state) {
+1 -1
drivers/scsi/qedi/qedi_main.c
··· 1805 1805 */ 1806 1806 qedi_ops->common->update_pf_params(qedi->cdev, &qedi->pf_params); 1807 1807 1808 - qedi_setup_int(qedi); 1808 + rc = qedi_setup_int(qedi); 1809 1809 if (rc) 1810 1810 goto stop_iscsi_func; 1811 1811
+4 -8
drivers/scsi/qla2xxx/qla_dbg.c
··· 2707 2707 "%-+5d 0 1 2 3 4 5 6 7 8 9 A B C D E F\n", size); 2708 2708 ql_dbg(level, vha, id, 2709 2709 "----- -----------------------------------------------\n"); 2710 - for (cnt = 0; cnt < size; cnt++, buf++) { 2711 - if (cnt % 16 == 0) 2712 - ql_dbg(level, vha, id, "%04x:", cnt & ~0xFU); 2713 - printk(" %02x", *buf); 2714 - if (cnt % 16 == 15) 2715 - printk("\n"); 2710 + for (cnt = 0; cnt < size; cnt += 16) { 2711 + ql_dbg(level, vha, id, "%04x: ", cnt); 2712 + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, 2713 + buf + cnt, min(16U, size - cnt), false); 2716 2714 } 2717 - if (cnt % 16 != 0) 2718 - printk("\n"); 2719 2715 }
+10 -4
drivers/scsi/scsi_lib.c
··· 2932 2932 /** 2933 2933 * scsi_internal_device_block - internal function to put a device temporarily into the SDEV_BLOCK state 2934 2934 * @sdev: device to block 2935 + * @wait: Whether or not to wait until ongoing .queuecommand() / 2936 + * .queue_rq() calls have finished. 2935 2937 * 2936 2938 * Block request made by scsi lld's to temporarily stop all 2937 2939 * scsi commands on the specified device. May sleep. ··· 2951 2949 * remove the rport mutex lock and unlock calls from srp_queuecommand(). 2952 2950 */ 2953 2951 int 2954 - scsi_internal_device_block(struct scsi_device *sdev) 2952 + scsi_internal_device_block(struct scsi_device *sdev, bool wait) 2955 2953 { 2956 2954 struct request_queue *q = sdev->request_queue; 2957 2955 unsigned long flags; ··· 2971 2969 * request queue. 2972 2970 */ 2973 2971 if (q->mq_ops) { 2974 - blk_mq_quiesce_queue(q); 2972 + if (wait) 2973 + blk_mq_quiesce_queue(q); 2974 + else 2975 + blk_mq_stop_hw_queues(q); 2975 2976 } else { 2976 2977 spin_lock_irqsave(q->queue_lock, flags); 2977 2978 blk_stop_queue(q); 2978 2979 spin_unlock_irqrestore(q->queue_lock, flags); 2979 - scsi_wait_for_queuecommand(sdev); 2980 + if (wait) 2981 + scsi_wait_for_queuecommand(sdev); 2980 2982 } 2981 2983 2982 2984 return 0; ··· 3042 3036 static void 3043 3037 device_block(struct scsi_device *sdev, void *data) 3044 3038 { 3045 - scsi_internal_device_block(sdev); 3039 + scsi_internal_device_block(sdev, true); 3046 3040 } 3047 3041 3048 3042 static int
-3
drivers/scsi/scsi_priv.h
··· 188 188 */ 189 189 190 190 #define SCSI_DEVICE_BLOCK_MAX_TIMEOUT 600 /* units in seconds */ 191 - extern int scsi_internal_device_block(struct scsi_device *sdev); 192 - extern int scsi_internal_device_unblock(struct scsi_device *sdev, 193 - enum scsi_device_state new_state); 194 191 195 192 #endif /* _SCSI_PRIV_H */
+17
drivers/scsi/sd.c
··· 1783 1783 { 1784 1784 int result = SCpnt->result; 1785 1785 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt); 1786 + unsigned int sector_size = SCpnt->device->sector_size; 1787 + unsigned int resid; 1786 1788 struct scsi_sense_hdr sshdr; 1787 1789 struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); 1788 1790 struct request *req = SCpnt->request; ··· 1815 1813 scsi_set_resid(SCpnt, blk_rq_bytes(req)); 1816 1814 } 1817 1815 break; 1816 + default: 1817 + /* 1818 + * In case of bogus fw or device, we could end up having 1819 + * an unaligned partial completion. Check this here and force 1820 + * alignment. 1821 + */ 1822 + resid = scsi_get_resid(SCpnt); 1823 + if (resid & (sector_size - 1)) { 1824 + sd_printk(KERN_INFO, sdkp, 1825 + "Unaligned partial completion (resid=%u, sector_sz=%u)\n", 1826 + resid, sector_size); 1827 + resid = min(scsi_bufflen(SCpnt), 1828 + round_up(resid, sector_size)); 1829 + scsi_set_resid(SCpnt, resid); 1830 + } 1818 1831 } 1819 1832 1820 1833 if (result) {
+17 -10
drivers/scsi/storvsc_drv.c
··· 400 400 */ 401 401 static int storvsc_timeout = 180; 402 402 403 - static int msft_blist_flags = BLIST_TRY_VPD_PAGES; 404 - 405 403 #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS) 406 404 static struct scsi_transport_template *fc_transport_template; 407 405 #endif ··· 1381 1383 return ret; 1382 1384 } 1383 1385 1386 + static int storvsc_device_alloc(struct scsi_device *sdevice) 1387 + { 1388 + /* 1389 + * Set blist flag to permit the reading of the VPD pages even when 1390 + * the target may claim SPC-2 compliance. MSFT targets currently 1391 + * claim SPC-2 compliance while they implement post SPC-2 features. 1392 + * With this flag we can correctly handle WRITE_SAME_16 issues. 1393 + * 1394 + * Hypervisor reports SCSI_UNKNOWN type for DVD ROM device but 1395 + * still supports REPORT LUN. 1396 + */ 1397 + sdevice->sdev_bflags = BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES; 1398 + 1399 + return 0; 1400 + } 1401 + 1384 1402 static int storvsc_device_configure(struct scsi_device *sdevice) 1385 1403 { 1386 1404 ··· 1408 1394 blk_queue_virt_boundary(sdevice->request_queue, PAGE_SIZE - 1); 1409 1395 1410 1396 sdevice->no_write_same = 1; 1411 - 1412 - /* 1413 - * Add blist flags to permit the reading of the VPD pages even when 1414 - * the target may claim SPC-2 compliance. MSFT targets currently 1415 - * claim SPC-2 compliance while they implement post SPC-2 features. 1416 - * With this patch we can correctly handle WRITE_SAME_16 issues. 1417 - */ 1418 - sdevice->sdev_bflags |= msft_blist_flags; 1419 1397 1420 1398 /* 1421 1399 * If the host is WIN8 or WIN8 R2, claim conformance to SPC-3 ··· 1667 1661 .eh_host_reset_handler = storvsc_host_reset_handler, 1668 1662 .proc_name = "storvsc_host", 1669 1663 .eh_timed_out = storvsc_eh_timed_out, 1664 + .slave_alloc = storvsc_device_alloc, 1670 1665 .slave_configure = storvsc_device_configure, 1671 1666 .cmd_per_lun = 255, 1672 1667 .this_id = -1,
+8 -14
drivers/scsi/ufs/ufs.h
··· 146 146 /* Descriptor idn for Query requests */ 147 147 enum desc_idn { 148 148 QUERY_DESC_IDN_DEVICE = 0x0, 149 - QUERY_DESC_IDN_CONFIGURAION = 0x1, 149 + QUERY_DESC_IDN_CONFIGURATION = 0x1, 150 150 QUERY_DESC_IDN_UNIT = 0x2, 151 151 QUERY_DESC_IDN_RFU_0 = 0x3, 152 152 QUERY_DESC_IDN_INTERCONNECT = 0x4, ··· 162 162 QUERY_DESC_DESC_TYPE_OFFSET = 0x01, 163 163 }; 164 164 165 - enum ufs_desc_max_size { 166 - QUERY_DESC_DEVICE_MAX_SIZE = 0x40, 167 - QUERY_DESC_CONFIGURAION_MAX_SIZE = 0x90, 168 - QUERY_DESC_UNIT_MAX_SIZE = 0x23, 169 - QUERY_DESC_INTERCONNECT_MAX_SIZE = 0x06, 170 - /* 171 - * Max. 126 UNICODE characters (2 bytes per character) plus 2 bytes 172 - * of descriptor header. 173 - */ 174 - QUERY_DESC_STRING_MAX_SIZE = 0xFE, 175 - QUERY_DESC_GEOMETRY_MAX_SIZE = 0x44, 176 - QUERY_DESC_POWER_MAX_SIZE = 0x62, 177 - QUERY_DESC_RFU_MAX_SIZE = 0x00, 165 + enum ufs_desc_def_size { 166 + QUERY_DESC_DEVICE_DEF_SIZE = 0x40, 167 + QUERY_DESC_CONFIGURATION_DEF_SIZE = 0x90, 168 + QUERY_DESC_UNIT_DEF_SIZE = 0x23, 169 + QUERY_DESC_INTERCONNECT_DEF_SIZE = 0x06, 170 + QUERY_DESC_GEOMETRY_DEF_SIZE = 0x44, 171 + QUERY_DESC_POWER_DEF_SIZE = 0x62, 178 172 }; 179 173 180 174 /* Unit descriptor parameters offsets in bytes*/
+173 -58
drivers/scsi/ufs/ufshcd.c
··· 100 100 #define ufshcd_hex_dump(prefix_str, buf, len) \ 101 101 print_hex_dump(KERN_ERR, prefix_str, DUMP_PREFIX_OFFSET, 16, 4, buf, len, false) 102 102 103 - static u32 ufs_query_desc_max_size[] = { 104 - QUERY_DESC_DEVICE_MAX_SIZE, 105 - QUERY_DESC_CONFIGURAION_MAX_SIZE, 106 - QUERY_DESC_UNIT_MAX_SIZE, 107 - QUERY_DESC_RFU_MAX_SIZE, 108 - QUERY_DESC_INTERCONNECT_MAX_SIZE, 109 - QUERY_DESC_STRING_MAX_SIZE, 110 - QUERY_DESC_RFU_MAX_SIZE, 111 - QUERY_DESC_GEOMETRY_MAX_SIZE, 112 - QUERY_DESC_POWER_MAX_SIZE, 113 - QUERY_DESC_RFU_MAX_SIZE, 114 - }; 115 - 116 103 enum { 117 104 UFSHCD_MAX_CHANNEL = 0, 118 105 UFSHCD_MAX_ID = 1, ··· 2844 2857 goto out; 2845 2858 } 2846 2859 2847 - if (*buf_len <= QUERY_DESC_MIN_SIZE || *buf_len > QUERY_DESC_MAX_SIZE) { 2860 + if (*buf_len < QUERY_DESC_MIN_SIZE || *buf_len > QUERY_DESC_MAX_SIZE) { 2848 2861 dev_err(hba->dev, "%s: descriptor buffer size (%d) is out of range\n", 2849 2862 __func__, *buf_len); 2850 2863 err = -EINVAL; ··· 2925 2938 } 2926 2939 2927 2940 /** 2941 + * ufshcd_read_desc_length - read the specified descriptor length from header 2942 + * @hba: Pointer to adapter instance 2943 + * @desc_id: descriptor idn value 2944 + * @desc_index: descriptor index 2945 + * @desc_length: pointer to variable to read the length of descriptor 2946 + * 2947 + * Return 0 in case of success, non-zero otherwise 2948 + */ 2949 + static int ufshcd_read_desc_length(struct ufs_hba *hba, 2950 + enum desc_idn desc_id, 2951 + int desc_index, 2952 + int *desc_length) 2953 + { 2954 + int ret; 2955 + u8 header[QUERY_DESC_HDR_SIZE]; 2956 + int header_len = QUERY_DESC_HDR_SIZE; 2957 + 2958 + if (desc_id >= QUERY_DESC_IDN_MAX) 2959 + return -EINVAL; 2960 + 2961 + ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, 2962 + desc_id, desc_index, 0, header, 2963 + &header_len); 2964 + 2965 + if (ret) { 2966 + dev_err(hba->dev, "%s: Failed to get descriptor header id %d", 2967 + __func__, desc_id); 2968 + return ret; 2969 + } else if (desc_id != header[QUERY_DESC_DESC_TYPE_OFFSET]) { 2970 + dev_warn(hba->dev, "%s: descriptor header id %d and desc_id %d mismatch", 2971 + __func__, header[QUERY_DESC_DESC_TYPE_OFFSET], 2972 + desc_id); 2973 + ret = -EINVAL; 2974 + } 2975 + 2976 + *desc_length = header[QUERY_DESC_LENGTH_OFFSET]; 2977 + return ret; 2978 + 2979 + } 2980 + 2981 + /** 2982 + * ufshcd_map_desc_id_to_length - map descriptor IDN to its length 2983 + * @hba: Pointer to adapter instance 2984 + * @desc_id: descriptor idn value 2985 + * @desc_len: mapped desc length (out) 2986 + * 2987 + * Return 0 in case of success, non-zero otherwise 2988 + */ 2989 + int ufshcd_map_desc_id_to_length(struct ufs_hba *hba, 2990 + enum desc_idn desc_id, int *desc_len) 2991 + { 2992 + switch (desc_id) { 2993 + case QUERY_DESC_IDN_DEVICE: 2994 + *desc_len = hba->desc_size.dev_desc; 2995 + break; 2996 + case QUERY_DESC_IDN_POWER: 2997 + *desc_len = hba->desc_size.pwr_desc; 2998 + break; 2999 + case QUERY_DESC_IDN_GEOMETRY: 3000 + *desc_len = hba->desc_size.geom_desc; 3001 + break; 3002 + case QUERY_DESC_IDN_CONFIGURATION: 3003 + *desc_len = hba->desc_size.conf_desc; 3004 + break; 3005 + case QUERY_DESC_IDN_UNIT: 3006 + *desc_len = hba->desc_size.unit_desc; 3007 + break; 3008 + case QUERY_DESC_IDN_INTERCONNECT: 3009 + *desc_len = hba->desc_size.interc_desc; 3010 + break; 3011 + case QUERY_DESC_IDN_STRING: 3012 + *desc_len = QUERY_DESC_MAX_SIZE; 3013 + break; 3014 + case QUERY_DESC_IDN_RFU_0: 3015 + case QUERY_DESC_IDN_RFU_1: 3016 + *desc_len = 0; 3017 + break; 3018 + default: 3019 + *desc_len = 0; 3020 + return -EINVAL; 3021 + } 3022 + return 0; 3023 + } 3024 + EXPORT_SYMBOL(ufshcd_map_desc_id_to_length); 3025 + 3026 + /** 2928 3027 * ufshcd_read_desc_param - read the specified descriptor parameter 2929 3028 * @hba: Pointer to adapter instance 2930 3029 * @desc_id: descriptor idn value ··· 3024 2951 static int ufshcd_read_desc_param(struct ufs_hba *hba, 3025 2952 enum desc_idn desc_id, 3026 2953 int desc_index, 3027 - u32 param_offset, 2954 + u8 param_offset, 3028 2955 u8 *param_read_buf, 3029 - u32 param_size) 2956 + u8 param_size) 3030 2957 { 3031 2958 int ret; 3032 2959 u8 *desc_buf; 3033 - u32 buff_len; 2960 + int buff_len; 3034 2961 bool is_kmalloc = true; 3035 2962 3036 - /* safety checks */ 3037 - if (desc_id >= QUERY_DESC_IDN_MAX) 2963 + /* Safety check */ 2964 + if (desc_id >= QUERY_DESC_IDN_MAX || !param_size) 3038 2965 return -EINVAL; 3039 2966 3040 - buff_len = ufs_query_desc_max_size[desc_id]; 3041 - if ((param_offset + param_size) > buff_len) 3042 - return -EINVAL; 2967 + /* Get the max length of descriptor from structure filled up at probe 2968 + * time. 2969 + */ 2970 + ret = ufshcd_map_desc_id_to_length(hba, desc_id, &buff_len); 3043 2971 3044 - if (!param_offset && (param_size == buff_len)) { 3045 - /* memory space already available to hold full descriptor */ 3046 - desc_buf = param_read_buf; 3047 - is_kmalloc = false; 3048 - } else { 3049 - /* allocate memory to hold full descriptor */ 2972 + /* Sanity checks */ 2973 + if (ret || !buff_len) { 2974 + dev_err(hba->dev, "%s: Failed to get full descriptor length", 2975 + __func__); 2976 + return ret; 2977 + } 2978 + 2979 + /* Check whether we need temp memory */ 2980 + if (param_offset != 0 || param_size < buff_len) { 3050 2981 desc_buf = kmalloc(buff_len, GFP_KERNEL); 3051 2982 if (!desc_buf) 3052 2983 return -ENOMEM; 2984 + } else { 2985 + desc_buf = param_read_buf; 2986 + is_kmalloc = false; 3053 2987 } 3054 2988 2989 + /* Request for full descriptor */ 3055 2990 ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, 3056 - desc_id, desc_index, 0, desc_buf, 3057 - &buff_len); 2991 + desc_id, desc_index, 0, 2992 + desc_buf, &buff_len); 3058 2993 3059 2994 if (ret) { 3060 2995 dev_err(hba->dev, "%s: Failed reading descriptor. desc_id %d, desc_index %d, param_offset %d, ret %d", 3061 2996 __func__, desc_id, desc_index, param_offset, ret); 3062 - 3063 2997 goto out; 3064 2998 } 3065 2999 ··· 3078 2998 goto out; 3079 2999 } 3080 3000 3081 - /* 3082 - * While reading variable size descriptors (like string descriptor), 3083 - * some UFS devices may report the "LENGTH" (field in "Transaction 3084 - * Specific fields" of Query Response UPIU) same as what was requested 3085 - * in Query Request UPIU instead of reporting the actual size of the 3086 - * variable size descriptor. 3087 - * Although it's safe to ignore the "LENGTH" field for variable size 3088 - * descriptors as we can always derive the length of the descriptor from 3089 - * the descriptor header fields. Hence this change impose the length 3090 - * match check only for fixed size descriptors (for which we always 3091 - * request the correct size as part of Query Request UPIU). 3092 - */ 3093 - if ((desc_id != QUERY_DESC_IDN_STRING) && 3094 - (buff_len != desc_buf[QUERY_DESC_LENGTH_OFFSET])) { 3095 - dev_err(hba->dev, "%s: desc_buf length mismatch: buff_len %d, buff_len(desc_header) %d", 3096 - __func__, buff_len, desc_buf[QUERY_DESC_LENGTH_OFFSET]); 3097 - ret = -EINVAL; 3098 - goto out; 3099 - } 3001 + /* Check wherher we will not copy more data, than available */ 3002 + if (is_kmalloc && param_size > buff_len) 3003 + param_size = buff_len; 3100 3004 3101 3005 if (is_kmalloc) 3102 3006 memcpy(param_read_buf, &desc_buf[param_offset], param_size); ··· 5983 5919 static void ufshcd_init_icc_levels(struct ufs_hba *hba) 5984 5920 { 5985 5921 int ret; 5986 - int buff_len = QUERY_DESC_POWER_MAX_SIZE; 5987 - u8 desc_buf[QUERY_DESC_POWER_MAX_SIZE]; 5922 + int buff_len = hba->desc_size.pwr_desc; 5923 + u8 desc_buf[hba->desc_size.pwr_desc]; 5988 5924 5989 5925 ret = ufshcd_read_power_desc(hba, desc_buf, buff_len); 5990 5926 if (ret) { ··· 6081 6017 { 6082 6018 int err; 6083 6019 u8 model_index; 6084 - u8 str_desc_buf[QUERY_DESC_STRING_MAX_SIZE + 1] = {0}; 6085 - u8 desc_buf[QUERY_DESC_DEVICE_MAX_SIZE]; 6020 + u8 str_desc_buf[QUERY_DESC_MAX_SIZE + 1] = {0}; 6021 + u8 desc_buf[hba->desc_size.dev_desc]; 6086 6022 6087 - err = ufshcd_read_device_desc(hba, desc_buf, 6088 - QUERY_DESC_DEVICE_MAX_SIZE); 6023 + err = ufshcd_read_device_desc(hba, desc_buf, hba->desc_size.dev_desc); 6089 6024 if (err) { 6090 6025 dev_err(hba->dev, "%s: Failed reading Device Desc. err = %d\n", 6091 6026 __func__, err); ··· 6101 6038 model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME]; 6102 6039 6103 6040 err = ufshcd_read_string_desc(hba, model_index, str_desc_buf, 6104 - QUERY_DESC_STRING_MAX_SIZE, ASCII_STD); 6041 + QUERY_DESC_MAX_SIZE, ASCII_STD); 6105 6042 if (err) { 6106 6043 dev_err(hba->dev, "%s: Failed reading Product Name. err = %d\n", 6107 6044 __func__, err); 6108 6045 goto out; 6109 6046 } 6110 6047 6111 - str_desc_buf[QUERY_DESC_STRING_MAX_SIZE] = '\0'; 6048 + str_desc_buf[QUERY_DESC_MAX_SIZE] = '\0'; 6112 6049 strlcpy(dev_desc->model, (str_desc_buf + QUERY_DESC_HDR_SIZE), 6113 6050 min_t(u8, str_desc_buf[QUERY_DESC_LENGTH_OFFSET], 6114 6051 MAX_MODEL_LEN)); ··· 6314 6251 hba->req_abort_count = 0; 6315 6252 } 6316 6253 6254 + static void ufshcd_init_desc_sizes(struct ufs_hba *hba) 6255 + { 6256 + int err; 6257 + 6258 + err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_DEVICE, 0, 6259 + &hba->desc_size.dev_desc); 6260 + if (err) 6261 + hba->desc_size.dev_desc = QUERY_DESC_DEVICE_DEF_SIZE; 6262 + 6263 + err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_POWER, 0, 6264 + &hba->desc_size.pwr_desc); 6265 + if (err) 6266 + hba->desc_size.pwr_desc = QUERY_DESC_POWER_DEF_SIZE; 6267 + 6268 + err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_INTERCONNECT, 0, 6269 + &hba->desc_size.interc_desc); 6270 + if (err) 6271 + hba->desc_size.interc_desc = QUERY_DESC_INTERCONNECT_DEF_SIZE; 6272 + 6273 + err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_CONFIGURATION, 0, 6274 + &hba->desc_size.conf_desc); 6275 + if (err) 6276 + hba->desc_size.conf_desc = QUERY_DESC_CONFIGURATION_DEF_SIZE; 6277 + 6278 + err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_UNIT, 0, 6279 + &hba->desc_size.unit_desc); 6280 + if (err) 6281 + hba->desc_size.unit_desc = QUERY_DESC_UNIT_DEF_SIZE; 6282 + 6283 + err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_GEOMETRY, 0, 6284 + &hba->desc_size.geom_desc); 6285 + if (err) 6286 + hba->desc_size.geom_desc = QUERY_DESC_GEOMETRY_DEF_SIZE; 6287 + } 6288 + 6289 + static void ufshcd_def_desc_sizes(struct ufs_hba *hba) 6290 + { 6291 + hba->desc_size.dev_desc = QUERY_DESC_DEVICE_DEF_SIZE; 6292 + hba->desc_size.pwr_desc = QUERY_DESC_POWER_DEF_SIZE; 6293 + hba->desc_size.interc_desc = QUERY_DESC_INTERCONNECT_DEF_SIZE; 6294 + hba->desc_size.conf_desc = QUERY_DESC_CONFIGURATION_DEF_SIZE; 6295 + hba->desc_size.unit_desc = QUERY_DESC_UNIT_DEF_SIZE; 6296 + hba->desc_size.geom_desc = QUERY_DESC_GEOMETRY_DEF_SIZE; 6297 + } 6298 + 6317 6299 /** 6318 6300 * ufshcd_probe_hba - probe hba to detect device and initialize 6319 6301 * @hba: per-adapter instance ··· 6392 6284 ret = ufshcd_complete_dev_init(hba); 6393 6285 if (ret) 6394 6286 goto out; 6287 + 6288 + /* Init check for device descriptor sizes */ 6289 + ufshcd_init_desc_sizes(hba); 6395 6290 6396 6291 ret = ufs_get_device_desc(hba, &card); 6397 6292 if (ret) { ··· 6431 6320 6432 6321 /* set the state as operational after switching to desired gear */ 6433 6322 hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL; 6323 + 6434 6324 /* 6435 6325 * If we are in error handling context or in power management callbacks 6436 6326 * context, no need to scan the host ··· 7885 7773 7886 7774 hba->mmio_base = mmio_base; 7887 7775 hba->irq = irq; 7776 + 7777 + /* Set descriptor lengths to specification defaults */ 7778 + ufshcd_def_desc_sizes(hba); 7888 7779 7889 7780 err = ufshcd_hba_init(hba); 7890 7781 if (err)
+15
drivers/scsi/ufs/ufshcd.h
··· 220 220 struct ufs_query query; 221 221 }; 222 222 223 + struct ufs_desc_size { 224 + int dev_desc; 225 + int pwr_desc; 226 + int geom_desc; 227 + int interc_desc; 228 + int unit_desc; 229 + int conf_desc; 230 + }; 231 + 223 232 /** 224 233 * struct ufs_clk_info - UFS clock related info 225 234 * @list: list headed by hba->clk_list_head ··· 492 483 * @clk_list_head: UFS host controller clocks list node head 493 484 * @pwr_info: holds current power mode 494 485 * @max_pwr_info: keeps the device max valid pwm 486 + * @desc_size: descriptor sizes reported by device 495 487 * @urgent_bkops_lvl: keeps track of urgent bkops level for device 496 488 * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for 497 489 * device is known or not. ··· 676 666 bool is_urgent_bkops_lvl_checked; 677 667 678 668 struct rw_semaphore clk_scaling_lock; 669 + struct ufs_desc_size desc_size; 679 670 }; 680 671 681 672 /* Returns true if clocks can be gated. Otherwise false */ ··· 843 832 enum flag_idn idn, bool *flag_res); 844 833 int ufshcd_hold(struct ufs_hba *hba, bool async); 845 834 void ufshcd_release(struct ufs_hba *hba); 835 + 836 + int ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id, 837 + int *desc_length); 838 + 846 839 u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba); 847 840 848 841 /* Wrapper functions for safely calling variant operations */
+1 -1
drivers/scsi/vmw_pvscsi.c
··· 1487 1487 irq_flag &= ~PCI_IRQ_MSI; 1488 1488 1489 1489 error = pci_alloc_irq_vectors(adapter->dev, 1, 1, irq_flag); 1490 - if (error) 1490 + if (error < 0) 1491 1491 goto out_reset_adapter; 1492 1492 1493 1493 adapter->use_req_threshold = pvscsi_setup_req_threshold(adapter, true);
+2 -2
drivers/staging/lustre/lnet/lnet/lib-socket.c
··· 532 532 533 533 newsock->ops = sock->ops; 534 534 535 - rc = sock->ops->accept(sock, newsock, O_NONBLOCK); 535 + rc = sock->ops->accept(sock, newsock, O_NONBLOCK, false); 536 536 if (rc == -EAGAIN) { 537 537 /* Nothing ready, so wait for activity */ 538 538 init_waitqueue_entry(&wait, current); ··· 540 540 set_current_state(TASK_INTERRUPTIBLE); 541 541 schedule(); 542 542 remove_wait_queue(sk_sleep(sock->sk), &wait); 543 - rc = sock->ops->accept(sock, newsock, O_NONBLOCK); 543 + rc = sock->ops->accept(sock, newsock, O_NONBLOCK, false); 544 544 } 545 545 546 546 if (rc)
+1 -1
fs/dlm/lowcomms.c
··· 743 743 newsock->type = con->sock->type; 744 744 newsock->ops = con->sock->ops; 745 745 746 - result = con->sock->ops->accept(con->sock, newsock, O_NONBLOCK); 746 + result = con->sock->ops->accept(con->sock, newsock, O_NONBLOCK, true); 747 747 if (result < 0) 748 748 goto accept_err; 749 749
+21 -14
fs/fs-writeback.c
··· 173 173 spin_unlock_bh(&wb->work_lock); 174 174 } 175 175 176 + static void finish_writeback_work(struct bdi_writeback *wb, 177 + struct wb_writeback_work *work) 178 + { 179 + struct wb_completion *done = work->done; 180 + 181 + if (work->auto_free) 182 + kfree(work); 183 + if (done && atomic_dec_and_test(&done->cnt)) 184 + wake_up_all(&wb->bdi->wb_waitq); 185 + } 186 + 176 187 static void wb_queue_work(struct bdi_writeback *wb, 177 188 struct wb_writeback_work *work) 178 189 { 179 190 trace_writeback_queue(wb, work); 180 191 181 - spin_lock_bh(&wb->work_lock); 182 - if (!test_bit(WB_registered, &wb->state)) 183 - goto out_unlock; 184 192 if (work->done) 185 193 atomic_inc(&work->done->cnt); 186 - list_add_tail(&work->list, &wb->work_list); 187 - mod_delayed_work(bdi_wq, &wb->dwork, 0); 188 - out_unlock: 194 + 195 + spin_lock_bh(&wb->work_lock); 196 + 197 + if (test_bit(WB_registered, &wb->state)) { 198 + list_add_tail(&work->list, &wb->work_list); 199 + mod_delayed_work(bdi_wq, &wb->dwork, 0); 200 + } else 201 + finish_writeback_work(wb, work); 202 + 189 203 spin_unlock_bh(&wb->work_lock); 190 204 } 191 205 ··· 1887 1873 1888 1874 set_bit(WB_writeback_running, &wb->state); 1889 1875 while ((work = get_next_work_item(wb)) != NULL) { 1890 - struct wb_completion *done = work->done; 1891 - 1892 1876 trace_writeback_exec(wb, work); 1893 - 1894 1877 wrote += wb_writeback(wb, work); 1895 - 1896 - if (work->auto_free) 1897 - kfree(work); 1898 - if (done && atomic_dec_and_test(&done->cnt)) 1899 - wake_up_all(&wb->bdi->wb_waitq); 1878 + finish_writeback_work(wb, work); 1900 1879 } 1901 1880 1902 1881 /*
+1 -1
fs/gfs2/incore.h
··· 207 207 struct gfs2_sbd *ln_sbd; 208 208 u64 ln_number; 209 209 unsigned int ln_type; 210 - }; 210 + } __packed __aligned(sizeof(int)); 211 211 212 212 #define lm_name_equal(name1, name2) \ 213 213 (((name1)->ln_number == (name2)->ln_number) && \
+1 -1
fs/ocfs2/cluster/tcp.c
··· 1863 1863 1864 1864 new_sock->type = sock->type; 1865 1865 new_sock->ops = sock->ops; 1866 - ret = sock->ops->accept(sock, new_sock, O_NONBLOCK); 1866 + ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, false); 1867 1867 if (ret < 0) 1868 1868 goto out; 1869 1869
+1 -1
include/crypto/if_alg.h
··· 73 73 74 74 int af_alg_release(struct socket *sock); 75 75 void af_alg_release_parent(struct sock *sk); 76 - int af_alg_accept(struct sock *sk, struct socket *newsock); 76 + int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern); 77 77 78 78 int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len); 79 79 void af_alg_free_sg(struct af_alg_sgl *sgl);
+1
include/linux/dccp.h
··· 163 163 __u64 dreq_isr; 164 164 __u64 dreq_gsr; 165 165 __be32 dreq_service; 166 + spinlock_t dreq_lock; 166 167 struct list_head dreq_featneg; 167 168 __u32 dreq_timestamp_echo; 168 169 __u32 dreq_timestamp_time;
+12 -4
include/linux/filter.h
··· 409 409 u16 pages; /* Number of allocated pages */ 410 410 kmemcheck_bitfield_begin(meta); 411 411 u16 jited:1, /* Is our filter JIT'ed? */ 412 + locked:1, /* Program image locked? */ 412 413 gpl_compatible:1, /* Is filter GPL compatible? */ 413 414 cb_access:1, /* Is control block accessed? */ 414 415 dst_needed:1, /* Do we need dst entry? */ ··· 555 554 #ifdef CONFIG_ARCH_HAS_SET_MEMORY 556 555 static inline void bpf_prog_lock_ro(struct bpf_prog *fp) 557 556 { 558 - set_memory_ro((unsigned long)fp, fp->pages); 557 + fp->locked = 1; 558 + WARN_ON_ONCE(set_memory_ro((unsigned long)fp, fp->pages)); 559 559 } 560 560 561 561 static inline void bpf_prog_unlock_ro(struct bpf_prog *fp) 562 562 { 563 - set_memory_rw((unsigned long)fp, fp->pages); 563 + if (fp->locked) { 564 + WARN_ON_ONCE(set_memory_rw((unsigned long)fp, fp->pages)); 565 + /* In case set_memory_rw() fails, we want to be the first 566 + * to crash here instead of some random place later on. 567 + */ 568 + fp->locked = 0; 569 + } 564 570 } 565 571 566 572 static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr) 567 573 { 568 - set_memory_ro((unsigned long)hdr, hdr->pages); 574 + WARN_ON_ONCE(set_memory_ro((unsigned long)hdr, hdr->pages)); 569 575 } 570 576 571 577 static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr) 572 578 { 573 - set_memory_rw((unsigned long)hdr, hdr->pages); 579 + WARN_ON_ONCE(set_memory_rw((unsigned long)hdr, hdr->pages)); 574 580 } 575 581 #else 576 582 static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
+5
include/linux/list_nulls.h
··· 29 29 ((ptr)->first = (struct hlist_nulls_node *) NULLS_MARKER(nulls)) 30 30 31 31 #define hlist_nulls_entry(ptr, type, member) container_of(ptr,type,member) 32 + 33 + #define hlist_nulls_entry_safe(ptr, type, member) \ 34 + ({ typeof(ptr) ____ptr = (ptr); \ 35 + !is_a_nulls(____ptr) ? hlist_nulls_entry(____ptr, type, member) : NULL; \ 36 + }) 32 37 /** 33 38 * ptr_is_a_nulls - Test if a ptr is a nulls 34 39 * @ptr: ptr to be tested
+1 -1
include/linux/net.h
··· 146 146 int (*socketpair)(struct socket *sock1, 147 147 struct socket *sock2); 148 148 int (*accept) (struct socket *sock, 149 - struct socket *newsock, int flags); 149 + struct socket *newsock, int flags, bool kern); 150 150 int (*getname) (struct socket *sock, 151 151 struct sockaddr *addr, 152 152 int *sockaddr_len, int peer);
+4
include/linux/phy.h
··· 837 837 int genphy_suspend(struct phy_device *phydev); 838 838 int genphy_resume(struct phy_device *phydev); 839 839 int genphy_soft_reset(struct phy_device *phydev); 840 + static inline int genphy_no_soft_reset(struct phy_device *phydev) 841 + { 842 + return 0; 843 + } 840 844 void phy_driver_unregister(struct phy_driver *drv); 841 845 void phy_drivers_unregister(struct phy_driver *drv, int n); 842 846 int phy_driver_register(struct phy_driver *new_driver, struct module *owner);
+14
include/linux/rculist_nulls.h
··· 156 156 ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1; }); \ 157 157 pos = rcu_dereference_raw(hlist_nulls_next_rcu(pos))) 158 158 159 + /** 160 + * hlist_nulls_for_each_entry_safe - 161 + * iterate over list of given type safe against removal of list entry 162 + * @tpos: the type * to use as a loop cursor. 163 + * @pos: the &struct hlist_nulls_node to use as a loop cursor. 164 + * @head: the head for your list. 165 + * @member: the name of the hlist_nulls_node within the struct. 166 + */ 167 + #define hlist_nulls_for_each_entry_safe(tpos, pos, head, member) \ 168 + for (({barrier();}), \ 169 + pos = rcu_dereference_raw(hlist_nulls_first_rcu(head)); \ 170 + (!is_a_nulls(pos)) && \ 171 + ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); \ 172 + pos = rcu_dereference_raw(hlist_nulls_next_rcu(pos)); 1; });) 159 173 #endif 160 174 #endif
+2 -1
include/net/inet_common.h
··· 20 20 int addr_len, int flags, int is_sendmsg); 21 21 int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, 22 22 int addr_len, int flags); 23 - int inet_accept(struct socket *sock, struct socket *newsock, int flags); 23 + int inet_accept(struct socket *sock, struct socket *newsock, int flags, 24 + bool kern); 24 25 int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size); 25 26 ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset, 26 27 size_t size, int flags);
+1 -1
include/net/inet_connection_sock.h
··· 258 258 return (unsigned long)min_t(u64, when, max_when); 259 259 } 260 260 261 - struct sock *inet_csk_accept(struct sock *sk, int flags, int *err); 261 + struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern); 262 262 263 263 int inet_csk_get_port(struct sock *sk, unsigned short snum); 264 264
+2 -1
include/net/sctp/structs.h
··· 476 476 int (*send_verify) (struct sctp_sock *, union sctp_addr *); 477 477 int (*supported_addrs)(const struct sctp_sock *, __be16 *); 478 478 struct sock *(*create_accept_sk) (struct sock *sk, 479 - struct sctp_association *asoc); 479 + struct sctp_association *asoc, 480 + bool kern); 480 481 int (*addr_to_user)(struct sctp_sock *sk, union sctp_addr *addr); 481 482 void (*to_sk_saddr)(union sctp_addr *, struct sock *sk); 482 483 void (*to_sk_daddr)(union sctp_addr *, struct sock *sk);
+6 -3
include/net/sock.h
··· 236 236 * @sk_shutdown: mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN 237 237 * @sk_userlocks: %SO_SNDBUF and %SO_RCVBUF settings 238 238 * @sk_lock: synchronizer 239 + * @sk_kern_sock: True if sock is using kernel lock classes 239 240 * @sk_rcvbuf: size of receive buffer in bytes 240 241 * @sk_wq: sock wait queue and async head 241 242 * @sk_rx_dst: receive input route used by early demux ··· 431 430 #endif 432 431 433 432 kmemcheck_bitfield_begin(flags); 434 - unsigned int sk_padding : 2, 433 + unsigned int sk_padding : 1, 434 + sk_kern_sock : 1, 435 435 sk_no_check_tx : 1, 436 436 sk_no_check_rx : 1, 437 437 sk_userlocks : 4, ··· 1017 1015 int addr_len); 1018 1016 int (*disconnect)(struct sock *sk, int flags); 1019 1017 1020 - struct sock * (*accept)(struct sock *sk, int flags, int *err); 1018 + struct sock * (*accept)(struct sock *sk, int flags, int *err, 1019 + bool kern); 1021 1020 1022 1021 int (*ioctl)(struct sock *sk, int cmd, 1023 1022 unsigned long arg); ··· 1576 1573 int sock_no_bind(struct socket *, struct sockaddr *, int); 1577 1574 int sock_no_connect(struct socket *, struct sockaddr *, int, int); 1578 1575 int sock_no_socketpair(struct socket *, struct socket *); 1579 - int sock_no_accept(struct socket *, struct socket *, int); 1576 + int sock_no_accept(struct socket *, struct socket *, int, bool); 1580 1577 int sock_no_getname(struct socket *, struct sockaddr *, int *, int); 1581 1578 unsigned int sock_no_poll(struct file *, struct socket *, 1582 1579 struct poll_table_struct *);
+1
include/scsi/libiscsi.h
··· 196 196 struct iscsi_task *task; /* xmit task in progress */ 197 197 198 198 /* xmit */ 199 + spinlock_t taskqueuelock; /* protects the next three lists */ 199 200 struct list_head mgmtqueue; /* mgmt (control) xmit queue */ 200 201 struct list_head cmdqueue; /* data-path cmd queue */ 201 202 struct list_head requeue; /* tasks needing another run */
+4
include/scsi/scsi_device.h
··· 472 472 sdev->sdev_state == SDEV_CREATED_BLOCK; 473 473 } 474 474 475 + int scsi_internal_device_block(struct scsi_device *sdev, bool wait); 476 + int scsi_internal_device_unblock(struct scsi_device *sdev, 477 + enum scsi_device_state new_state); 478 + 475 479 /* accessor functions for the SCSI parameters */ 476 480 static inline int scsi_device_sync(struct scsi_device *sdev) 477 481 {
+1 -1
include/uapi/linux/packet_diag.h
··· 64 64 __u32 pdmc_count; 65 65 __u16 pdmc_type; 66 66 __u16 pdmc_alen; 67 - __u8 pdmc_addr[MAX_ADDR_LEN]; 67 + __u8 pdmc_addr[32]; /* MAX_ADDR_LEN */ 68 68 }; 69 69 70 70 struct packet_diag_ring {
+80 -39
kernel/bpf/hashtab.c
··· 13 13 #include <linux/bpf.h> 14 14 #include <linux/jhash.h> 15 15 #include <linux/filter.h> 16 + #include <linux/rculist_nulls.h> 16 17 #include "percpu_freelist.h" 17 18 #include "bpf_lru_list.h" 18 19 19 20 struct bucket { 20 - struct hlist_head head; 21 + struct hlist_nulls_head head; 21 22 raw_spinlock_t lock; 22 23 }; 23 24 ··· 45 44 /* each htab element is struct htab_elem + key + value */ 46 45 struct htab_elem { 47 46 union { 48 - struct hlist_node hash_node; 49 - struct bpf_htab *htab; 50 - struct pcpu_freelist_node fnode; 47 + struct hlist_nulls_node hash_node; 48 + struct { 49 + void *padding; 50 + union { 51 + struct bpf_htab *htab; 52 + struct pcpu_freelist_node fnode; 53 + }; 54 + }; 51 55 }; 52 56 union { 53 57 struct rcu_head rcu; ··· 168 162 offsetof(struct htab_elem, lru_node), 169 163 htab->elem_size, htab->map.max_entries); 170 164 else 171 - pcpu_freelist_populate(&htab->freelist, htab->elems, 165 + pcpu_freelist_populate(&htab->freelist, 166 + htab->elems + offsetof(struct htab_elem, fnode), 172 167 htab->elem_size, htab->map.max_entries); 173 168 174 169 return 0; ··· 223 216 struct bpf_htab *htab; 224 217 int err, i; 225 218 u64 cost; 219 + 220 + BUILD_BUG_ON(offsetof(struct htab_elem, htab) != 221 + offsetof(struct htab_elem, hash_node.pprev)); 222 + BUILD_BUG_ON(offsetof(struct htab_elem, fnode.next) != 223 + offsetof(struct htab_elem, hash_node.pprev)); 226 224 227 225 if (lru && !capable(CAP_SYS_ADMIN)) 228 226 /* LRU implementation is much complicated than other ··· 338 326 goto free_htab; 339 327 340 328 for (i = 0; i < htab->n_buckets; i++) { 341 - INIT_HLIST_HEAD(&htab->buckets[i].head); 329 + INIT_HLIST_NULLS_HEAD(&htab->buckets[i].head, i); 342 330 raw_spin_lock_init(&htab->buckets[i].lock); 343 331 } 344 332 ··· 378 366 return &htab->buckets[hash & (htab->n_buckets - 1)]; 379 367 } 380 368 381 - static inline struct hlist_head *select_bucket(struct bpf_htab *htab, u32 hash) 369 + static inline struct hlist_nulls_head *select_bucket(struct bpf_htab *htab, u32 hash) 382 370 { 383 371 return &__select_bucket(htab, hash)->head; 384 372 } 385 373 386 - static struct htab_elem *lookup_elem_raw(struct hlist_head *head, u32 hash, 374 + /* this lookup function can only be called with bucket lock taken */ 375 + static struct htab_elem *lookup_elem_raw(struct hlist_nulls_head *head, u32 hash, 387 376 void *key, u32 key_size) 388 377 { 378 + struct hlist_nulls_node *n; 389 379 struct htab_elem *l; 390 380 391 - hlist_for_each_entry_rcu(l, head, hash_node) 381 + hlist_nulls_for_each_entry_rcu(l, n, head, hash_node) 392 382 if (l->hash == hash && !memcmp(&l->key, key, key_size)) 393 383 return l; 384 + 385 + return NULL; 386 + } 387 + 388 + /* can be called without bucket lock. it will repeat the loop in 389 + * the unlikely event when elements moved from one bucket into another 390 + * while link list is being walked 391 + */ 392 + static struct htab_elem *lookup_nulls_elem_raw(struct hlist_nulls_head *head, 393 + u32 hash, void *key, 394 + u32 key_size, u32 n_buckets) 395 + { 396 + struct hlist_nulls_node *n; 397 + struct htab_elem *l; 398 + 399 + again: 400 + hlist_nulls_for_each_entry_rcu(l, n, head, hash_node) 401 + if (l->hash == hash && !memcmp(&l->key, key, key_size)) 402 + return l; 403 + 404 + if (unlikely(get_nulls_value(n) != (hash & (n_buckets - 1)))) 405 + goto again; 394 406 395 407 return NULL; 396 408 } ··· 423 387 static void *__htab_map_lookup_elem(struct bpf_map *map, void *key) 424 388 { 425 389 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 426 - struct hlist_head *head; 390 + struct hlist_nulls_head *head; 427 391 struct htab_elem *l; 428 392 u32 hash, key_size; 429 393 ··· 436 400 437 401 head = select_bucket(htab, hash); 438 402 439 - l = lookup_elem_raw(head, hash, key, key_size); 403 + l = lookup_nulls_elem_raw(head, hash, key, key_size, htab->n_buckets); 440 404 441 405 return l; 442 406 } ··· 469 433 static bool htab_lru_map_delete_node(void *arg, struct bpf_lru_node *node) 470 434 { 471 435 struct bpf_htab *htab = (struct bpf_htab *)arg; 472 - struct htab_elem *l, *tgt_l; 473 - struct hlist_head *head; 436 + struct htab_elem *l = NULL, *tgt_l; 437 + struct hlist_nulls_head *head; 438 + struct hlist_nulls_node *n; 474 439 unsigned long flags; 475 440 struct bucket *b; 476 441 ··· 481 444 482 445 raw_spin_lock_irqsave(&b->lock, flags); 483 446 484 - hlist_for_each_entry_rcu(l, head, hash_node) 447 + hlist_nulls_for_each_entry_rcu(l, n, head, hash_node) 485 448 if (l == tgt_l) { 486 - hlist_del_rcu(&l->hash_node); 449 + hlist_nulls_del_rcu(&l->hash_node); 487 450 break; 488 451 } 489 452 ··· 496 459 static int htab_map_get_next_key(struct bpf_map *map, void *key, void *next_key) 497 460 { 498 461 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 499 - struct hlist_head *head; 462 + struct hlist_nulls_head *head; 500 463 struct htab_elem *l, *next_l; 501 464 u32 hash, key_size; 502 465 int i; ··· 510 473 head = select_bucket(htab, hash); 511 474 512 475 /* lookup the key */ 513 - l = lookup_elem_raw(head, hash, key, key_size); 476 + l = lookup_nulls_elem_raw(head, hash, key, key_size, htab->n_buckets); 514 477 515 478 if (!l) { 516 479 i = 0; ··· 518 481 } 519 482 520 483 /* key was found, get next key in the same bucket */ 521 - next_l = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&l->hash_node)), 484 + next_l = hlist_nulls_entry_safe(rcu_dereference_raw(hlist_nulls_next_rcu(&l->hash_node)), 522 485 struct htab_elem, hash_node); 523 486 524 487 if (next_l) { ··· 537 500 head = select_bucket(htab, i); 538 501 539 502 /* pick first element in the bucket */ 540 - next_l = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)), 503 + next_l = hlist_nulls_entry_safe(rcu_dereference_raw(hlist_nulls_first_rcu(head)), 541 504 struct htab_elem, hash_node); 542 505 if (next_l) { 543 506 /* if it's not empty, just return it */ ··· 619 582 int err = 0; 620 583 621 584 if (prealloc) { 622 - l_new = (struct htab_elem *)pcpu_freelist_pop(&htab->freelist); 623 - if (!l_new) 585 + struct pcpu_freelist_node *l; 586 + 587 + l = pcpu_freelist_pop(&htab->freelist); 588 + if (!l) 624 589 err = -E2BIG; 590 + else 591 + l_new = container_of(l, struct htab_elem, fnode); 625 592 } else { 626 593 if (atomic_inc_return(&htab->count) > htab->map.max_entries) { 627 594 atomic_dec(&htab->count); ··· 702 661 { 703 662 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 704 663 struct htab_elem *l_new = NULL, *l_old; 705 - struct hlist_head *head; 664 + struct hlist_nulls_head *head; 706 665 unsigned long flags; 707 666 struct bucket *b; 708 667 u32 key_size, hash; ··· 741 700 /* add new element to the head of the list, so that 742 701 * concurrent search will find it before old elem 743 702 */ 744 - hlist_add_head_rcu(&l_new->hash_node, head); 703 + hlist_nulls_add_head_rcu(&l_new->hash_node, head); 745 704 if (l_old) { 746 - hlist_del_rcu(&l_old->hash_node); 705 + hlist_nulls_del_rcu(&l_old->hash_node); 747 706 free_htab_elem(htab, l_old); 748 707 } 749 708 ret = 0; ··· 757 716 { 758 717 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 759 718 struct htab_elem *l_new, *l_old = NULL; 760 - struct hlist_head *head; 719 + struct hlist_nulls_head *head; 761 720 unsigned long flags; 762 721 struct bucket *b; 763 722 u32 key_size, hash; ··· 798 757 /* add new element to the head of the list, so that 799 758 * concurrent search will find it before old elem 800 759 */ 801 - hlist_add_head_rcu(&l_new->hash_node, head); 760 + hlist_nulls_add_head_rcu(&l_new->hash_node, head); 802 761 if (l_old) { 803 762 bpf_lru_node_set_ref(&l_new->lru_node); 804 - hlist_del_rcu(&l_old->hash_node); 763 + hlist_nulls_del_rcu(&l_old->hash_node); 805 764 } 806 765 ret = 0; 807 766 ··· 822 781 { 823 782 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 824 783 struct htab_elem *l_new = NULL, *l_old; 825 - struct hlist_head *head; 784 + struct hlist_nulls_head *head; 826 785 unsigned long flags; 827 786 struct bucket *b; 828 787 u32 key_size, hash; ··· 861 820 ret = PTR_ERR(l_new); 862 821 goto err; 863 822 } 864 - hlist_add_head_rcu(&l_new->hash_node, head); 823 + hlist_nulls_add_head_rcu(&l_new->hash_node, head); 865 824 } 866 825 ret = 0; 867 826 err: ··· 875 834 { 876 835 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 877 836 struct htab_elem *l_new = NULL, *l_old; 878 - struct hlist_head *head; 837 + struct hlist_nulls_head *head; 879 838 unsigned long flags; 880 839 struct bucket *b; 881 840 u32 key_size, hash; ··· 923 882 } else { 924 883 pcpu_copy_value(htab, htab_elem_get_ptr(l_new, key_size), 925 884 value, onallcpus); 926 - hlist_add_head_rcu(&l_new->hash_node, head); 885 + hlist_nulls_add_head_rcu(&l_new->hash_node, head); 927 886 l_new = NULL; 928 887 } 929 888 ret = 0; ··· 951 910 static int htab_map_delete_elem(struct bpf_map *map, void *key) 952 911 { 953 912 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 954 - struct hlist_head *head; 913 + struct hlist_nulls_head *head; 955 914 struct bucket *b; 956 915 struct htab_elem *l; 957 916 unsigned long flags; ··· 971 930 l = lookup_elem_raw(head, hash, key, key_size); 972 931 973 932 if (l) { 974 - hlist_del_rcu(&l->hash_node); 933 + hlist_nulls_del_rcu(&l->hash_node); 975 934 free_htab_elem(htab, l); 976 935 ret = 0; 977 936 } ··· 983 942 static int htab_lru_map_delete_elem(struct bpf_map *map, void *key) 984 943 { 985 944 struct bpf_htab *htab = container_of(map, struct bpf_htab, map); 986 - struct hlist_head *head; 945 + struct hlist_nulls_head *head; 987 946 struct bucket *b; 988 947 struct htab_elem *l; 989 948 unsigned long flags; ··· 1003 962 l = lookup_elem_raw(head, hash, key, key_size); 1004 963 1005 964 if (l) { 1006 - hlist_del_rcu(&l->hash_node); 965 + hlist_nulls_del_rcu(&l->hash_node); 1007 966 ret = 0; 1008 967 } 1009 968 ··· 1018 977 int i; 1019 978 1020 979 for (i = 0; i < htab->n_buckets; i++) { 1021 - struct hlist_head *head = select_bucket(htab, i); 1022 - struct hlist_node *n; 980 + struct hlist_nulls_head *head = select_bucket(htab, i); 981 + struct hlist_nulls_node *n; 1023 982 struct htab_elem *l; 1024 983 1025 - hlist_for_each_entry_safe(l, n, head, hash_node) { 1026 - hlist_del_rcu(&l->hash_node); 984 + hlist_nulls_for_each_entry_safe(l, n, head, hash_node) { 985 + hlist_nulls_del_rcu(&l->hash_node); 1027 986 if (l->state != HTAB_EXTRA_ELEM_USED) 1028 987 htab_elem_free(htab, l); 1029 988 }
+6
kernel/bpf/lpm_trie.c
··· 500 500 raw_spin_unlock(&trie->lock); 501 501 } 502 502 503 + static int trie_get_next_key(struct bpf_map *map, void *key, void *next_key) 504 + { 505 + return -ENOTSUPP; 506 + } 507 + 503 508 static const struct bpf_map_ops trie_ops = { 504 509 .map_alloc = trie_alloc, 505 510 .map_free = trie_free, 511 + .map_get_next_key = trie_get_next_key, 506 512 .map_lookup_elem = trie_lookup_elem, 507 513 .map_update_elem = trie_update_elem, 508 514 .map_delete_elem = trie_delete_elem,
+1 -1
kernel/cgroup/cgroup-v1.c
··· 1329 1329 struct task_struct *task; 1330 1330 int count = 0; 1331 1331 1332 - seq_printf(seq, "css_set %p\n", cset); 1332 + seq_printf(seq, "css_set %pK\n", cset); 1333 1333 1334 1334 list_for_each_entry(task, &cset->tasks, cg_list) { 1335 1335 if (count++ > MAX_TASKS_SHOWN_PER_CSS)
+1 -1
kernel/cgroup/pids.c
··· 229 229 /* Only log the first time events_limit is incremented. */ 230 230 if (atomic64_inc_return(&pids->events_limit) == 1) { 231 231 pr_info("cgroup: fork rejected by pids controller in "); 232 - pr_cont_cgroup_path(task_cgroup(current, pids_cgrp_id)); 232 + pr_cont_cgroup_path(css->cgroup); 233 233 pr_cont("\n"); 234 234 } 235 235 cgroup_file_notify(&pids->events_file);
+103 -98
kernel/sched/core.c
··· 86 86 cpumask_var_t cpu_isolated_map; 87 87 88 88 /* 89 - * this_rq_lock - lock this runqueue and disable interrupts. 90 - */ 91 - static struct rq *this_rq_lock(void) 92 - __acquires(rq->lock) 93 - { 94 - struct rq *rq; 95 - 96 - local_irq_disable(); 97 - rq = this_rq(); 98 - raw_spin_lock(&rq->lock); 99 - 100 - return rq; 101 - } 102 - 103 - /* 104 89 * __task_rq_lock - lock the rq @p resides on. 105 90 */ 106 91 struct rq *__task_rq_lock(struct task_struct *p, struct rq_flags *rf) ··· 218 233 return; 219 234 220 235 #ifdef CONFIG_SCHED_DEBUG 236 + if (sched_feat(WARN_DOUBLE_CLOCK)) 237 + SCHED_WARN_ON(rq->clock_update_flags & RQCF_UPDATED); 221 238 rq->clock_update_flags |= RQCF_UPDATED; 222 239 #endif 240 + 223 241 delta = sched_clock_cpu(cpu_of(rq)) - rq->clock; 224 242 if (delta < 0) 225 243 return; ··· 249 261 static enum hrtimer_restart hrtick(struct hrtimer *timer) 250 262 { 251 263 struct rq *rq = container_of(timer, struct rq, hrtick_timer); 264 + struct rq_flags rf; 252 265 253 266 WARN_ON_ONCE(cpu_of(rq) != smp_processor_id()); 254 267 255 - raw_spin_lock(&rq->lock); 268 + rq_lock(rq, &rf); 256 269 update_rq_clock(rq); 257 270 rq->curr->sched_class->task_tick(rq, rq->curr, 1); 258 - raw_spin_unlock(&rq->lock); 271 + rq_unlock(rq, &rf); 259 272 260 273 return HRTIMER_NORESTART; 261 274 } ··· 276 287 static void __hrtick_start(void *arg) 277 288 { 278 289 struct rq *rq = arg; 290 + struct rq_flags rf; 279 291 280 - raw_spin_lock(&rq->lock); 292 + rq_lock(rq, &rf); 281 293 __hrtick_restart(rq); 282 294 rq->hrtick_csd_pending = 0; 283 - raw_spin_unlock(&rq->lock); 295 + rq_unlock(rq, &rf); 284 296 } 285 297 286 298 /* ··· 752 762 753 763 static inline void enqueue_task(struct rq *rq, struct task_struct *p, int flags) 754 764 { 755 - update_rq_clock(rq); 765 + if (!(flags & ENQUEUE_NOCLOCK)) 766 + update_rq_clock(rq); 767 + 756 768 if (!(flags & ENQUEUE_RESTORE)) 757 769 sched_info_queued(rq, p); 770 + 758 771 p->sched_class->enqueue_task(rq, p, flags); 759 772 } 760 773 761 774 static inline void dequeue_task(struct rq *rq, struct task_struct *p, int flags) 762 775 { 763 - update_rq_clock(rq); 776 + if (!(flags & DEQUEUE_NOCLOCK)) 777 + update_rq_clock(rq); 778 + 764 779 if (!(flags & DEQUEUE_SAVE)) 765 780 sched_info_dequeued(rq, p); 781 + 766 782 p->sched_class->dequeue_task(rq, p, flags); 767 783 } 768 784 ··· 942 946 * 943 947 * Returns (locked) new rq. Old rq's lock is released. 944 948 */ 945 - static struct rq *move_queued_task(struct rq *rq, struct task_struct *p, int new_cpu) 949 + static struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf, 950 + struct task_struct *p, int new_cpu) 946 951 { 947 952 lockdep_assert_held(&rq->lock); 948 953 949 954 p->on_rq = TASK_ON_RQ_MIGRATING; 950 - dequeue_task(rq, p, 0); 955 + dequeue_task(rq, p, DEQUEUE_NOCLOCK); 951 956 set_task_cpu(p, new_cpu); 952 - raw_spin_unlock(&rq->lock); 957 + rq_unlock(rq, rf); 953 958 954 959 rq = cpu_rq(new_cpu); 955 960 956 - raw_spin_lock(&rq->lock); 961 + rq_lock(rq, rf); 957 962 BUG_ON(task_cpu(p) != new_cpu); 958 963 enqueue_task(rq, p, 0); 959 964 p->on_rq = TASK_ON_RQ_QUEUED; ··· 977 980 * So we race with normal scheduler movements, but that's OK, as long 978 981 * as the task is no longer on this CPU. 979 982 */ 980 - static struct rq *__migrate_task(struct rq *rq, struct task_struct *p, int dest_cpu) 983 + static struct rq *__migrate_task(struct rq *rq, struct rq_flags *rf, 984 + struct task_struct *p, int dest_cpu) 981 985 { 982 986 if (unlikely(!cpu_active(dest_cpu))) 983 987 return rq; ··· 987 989 if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed)) 988 990 return rq; 989 991 990 - rq = move_queued_task(rq, p, dest_cpu); 992 + update_rq_clock(rq); 993 + rq = move_queued_task(rq, rf, p, dest_cpu); 991 994 992 995 return rq; 993 996 } ··· 1003 1004 struct migration_arg *arg = data; 1004 1005 struct task_struct *p = arg->task; 1005 1006 struct rq *rq = this_rq(); 1007 + struct rq_flags rf; 1006 1008 1007 1009 /* 1008 1010 * The original target CPU might have gone down and we might ··· 1018 1018 sched_ttwu_pending(); 1019 1019 1020 1020 raw_spin_lock(&p->pi_lock); 1021 - raw_spin_lock(&rq->lock); 1021 + rq_lock(rq, &rf); 1022 1022 /* 1023 1023 * If task_rq(p) != rq, it cannot be migrated here, because we're 1024 1024 * holding rq->lock, if p->on_rq == 0 it cannot get enqueued because ··· 1026 1026 */ 1027 1027 if (task_rq(p) == rq) { 1028 1028 if (task_on_rq_queued(p)) 1029 - rq = __migrate_task(rq, p, arg->dest_cpu); 1029 + rq = __migrate_task(rq, &rf, p, arg->dest_cpu); 1030 1030 else 1031 1031 p->wake_cpu = arg->dest_cpu; 1032 1032 } 1033 - raw_spin_unlock(&rq->lock); 1033 + rq_unlock(rq, &rf); 1034 1034 raw_spin_unlock(&p->pi_lock); 1035 1035 1036 1036 local_irq_enable(); ··· 1063 1063 * holding rq->lock. 1064 1064 */ 1065 1065 lockdep_assert_held(&rq->lock); 1066 - dequeue_task(rq, p, DEQUEUE_SAVE); 1066 + dequeue_task(rq, p, DEQUEUE_SAVE | DEQUEUE_NOCLOCK); 1067 1067 } 1068 1068 if (running) 1069 1069 put_prev_task(rq, p); ··· 1071 1071 p->sched_class->set_cpus_allowed(p, new_mask); 1072 1072 1073 1073 if (queued) 1074 - enqueue_task(rq, p, ENQUEUE_RESTORE); 1074 + enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK); 1075 1075 if (running) 1076 1076 set_curr_task(rq, p); 1077 1077 } ··· 1150 1150 * OK, since we're going to drop the lock immediately 1151 1151 * afterwards anyway. 1152 1152 */ 1153 - rq_unpin_lock(rq, &rf); 1154 - rq = move_queued_task(rq, p, dest_cpu); 1155 - rq_repin_lock(rq, &rf); 1153 + rq = move_queued_task(rq, &rf, p, dest_cpu); 1156 1154 } 1157 1155 out: 1158 1156 task_rq_unlock(rq, p, &rf); ··· 1215 1217 { 1216 1218 if (task_on_rq_queued(p)) { 1217 1219 struct rq *src_rq, *dst_rq; 1220 + struct rq_flags srf, drf; 1218 1221 1219 1222 src_rq = task_rq(p); 1220 1223 dst_rq = cpu_rq(cpu); 1224 + 1225 + rq_pin_lock(src_rq, &srf); 1226 + rq_pin_lock(dst_rq, &drf); 1221 1227 1222 1228 p->on_rq = TASK_ON_RQ_MIGRATING; 1223 1229 deactivate_task(src_rq, p, 0); ··· 1229 1227 activate_task(dst_rq, p, 0); 1230 1228 p->on_rq = TASK_ON_RQ_QUEUED; 1231 1229 check_preempt_curr(dst_rq, p, 0); 1230 + 1231 + rq_unpin_lock(dst_rq, &drf); 1232 + rq_unpin_lock(src_rq, &srf); 1233 + 1232 1234 } else { 1233 1235 /* 1234 1236 * Task isn't running anymore; make it appear like we migrated ··· 1686 1680 ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags, 1687 1681 struct rq_flags *rf) 1688 1682 { 1689 - int en_flags = ENQUEUE_WAKEUP; 1683 + int en_flags = ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK; 1690 1684 1691 1685 lockdep_assert_held(&rq->lock); 1692 1686 ··· 1732 1726 struct rq *rq = this_rq(); 1733 1727 struct llist_node *llist = llist_del_all(&rq->wake_list); 1734 1728 struct task_struct *p; 1735 - unsigned long flags; 1736 1729 struct rq_flags rf; 1737 1730 1738 1731 if (!llist) 1739 1732 return; 1740 1733 1741 - raw_spin_lock_irqsave(&rq->lock, flags); 1742 - rq_pin_lock(rq, &rf); 1734 + rq_lock_irqsave(rq, &rf); 1735 + update_rq_clock(rq); 1743 1736 1744 1737 while (llist) { 1745 1738 int wake_flags = 0; ··· 1752 1747 ttwu_do_activate(rq, p, wake_flags, &rf); 1753 1748 } 1754 1749 1755 - rq_unpin_lock(rq, &rf); 1756 - raw_spin_unlock_irqrestore(&rq->lock, flags); 1750 + rq_unlock_irqrestore(rq, &rf); 1757 1751 } 1758 1752 1759 1753 void scheduler_ipi(void) ··· 1810 1806 void wake_up_if_idle(int cpu) 1811 1807 { 1812 1808 struct rq *rq = cpu_rq(cpu); 1813 - unsigned long flags; 1809 + struct rq_flags rf; 1814 1810 1815 1811 rcu_read_lock(); 1816 1812 ··· 1820 1816 if (set_nr_if_polling(rq->idle)) { 1821 1817 trace_sched_wake_idle_without_ipi(cpu); 1822 1818 } else { 1823 - raw_spin_lock_irqsave(&rq->lock, flags); 1819 + rq_lock_irqsave(rq, &rf); 1824 1820 if (is_idle_task(rq->curr)) 1825 1821 smp_send_reschedule(cpu); 1826 1822 /* Else CPU is not idle, do nothing here: */ 1827 - raw_spin_unlock_irqrestore(&rq->lock, flags); 1823 + rq_unlock_irqrestore(rq, &rf); 1828 1824 } 1829 1825 1830 1826 out: ··· 1850 1846 } 1851 1847 #endif 1852 1848 1853 - raw_spin_lock(&rq->lock); 1854 - rq_pin_lock(rq, &rf); 1849 + rq_lock(rq, &rf); 1850 + update_rq_clock(rq); 1855 1851 ttwu_do_activate(rq, p, wake_flags, &rf); 1856 - rq_unpin_lock(rq, &rf); 1857 - raw_spin_unlock(&rq->lock); 1852 + rq_unlock(rq, &rf); 1858 1853 } 1859 1854 1860 1855 /* ··· 2100 2097 * disabled avoiding further scheduler activity on it and we've 2101 2098 * not yet picked a replacement task. 2102 2099 */ 2103 - rq_unpin_lock(rq, rf); 2104 - raw_spin_unlock(&rq->lock); 2100 + rq_unlock(rq, rf); 2105 2101 raw_spin_lock(&p->pi_lock); 2106 - raw_spin_lock(&rq->lock); 2107 - rq_repin_lock(rq, rf); 2102 + rq_relock(rq, rf); 2108 2103 } 2109 2104 2110 2105 if (!(p->state & TASK_NORMAL)) ··· 2115 2114 delayacct_blkio_end(); 2116 2115 atomic_dec(&rq->nr_iowait); 2117 2116 } 2118 - ttwu_activate(rq, p, ENQUEUE_WAKEUP); 2117 + ttwu_activate(rq, p, ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK); 2119 2118 } 2120 2119 2121 2120 ttwu_do_wakeup(rq, p, 0, rf); ··· 2556 2555 update_rq_clock(rq); 2557 2556 post_init_entity_util_avg(&p->se); 2558 2557 2559 - activate_task(rq, p, 0); 2558 + activate_task(rq, p, ENQUEUE_NOCLOCK); 2560 2559 p->on_rq = TASK_ON_RQ_QUEUED; 2561 2560 trace_sched_wakeup_new(p); 2562 2561 check_preempt_curr(rq, p, WF_FORK); ··· 3094 3093 int cpu = smp_processor_id(); 3095 3094 struct rq *rq = cpu_rq(cpu); 3096 3095 struct task_struct *curr = rq->curr; 3096 + struct rq_flags rf; 3097 3097 3098 3098 sched_clock_tick(); 3099 3099 3100 - raw_spin_lock(&rq->lock); 3100 + rq_lock(rq, &rf); 3101 + 3101 3102 update_rq_clock(rq); 3102 3103 curr->sched_class->task_tick(rq, curr, 0); 3103 3104 cpu_load_update_active(rq); 3104 3105 calc_global_load_tick(rq); 3105 - raw_spin_unlock(&rq->lock); 3106 + 3107 + rq_unlock(rq, &rf); 3106 3108 3107 3109 perf_event_task_tick(); 3108 3110 ··· 3390 3386 * done by the caller to avoid the race with signal_wake_up(). 3391 3387 */ 3392 3388 smp_mb__before_spinlock(); 3393 - raw_spin_lock(&rq->lock); 3394 - rq_pin_lock(rq, &rf); 3389 + rq_lock(rq, &rf); 3395 3390 3396 3391 /* Promote REQ to ACT */ 3397 3392 rq->clock_update_flags <<= 1; 3393 + update_rq_clock(rq); 3398 3394 3399 3395 switch_count = &prev->nivcsw; 3400 3396 if (!preempt && prev->state) { 3401 3397 if (unlikely(signal_pending_state(prev->state, prev))) { 3402 3398 prev->state = TASK_RUNNING; 3403 3399 } else { 3404 - deactivate_task(rq, prev, DEQUEUE_SLEEP); 3400 + deactivate_task(rq, prev, DEQUEUE_SLEEP | DEQUEUE_NOCLOCK); 3405 3401 prev->on_rq = 0; 3406 3402 3407 3403 if (prev->in_iowait) { ··· 3425 3421 switch_count = &prev->nvcsw; 3426 3422 } 3427 3423 3428 - if (task_on_rq_queued(prev)) 3429 - update_rq_clock(rq); 3430 - 3431 3424 next = pick_next_task(rq, prev, &rf); 3432 3425 clear_tsk_need_resched(prev); 3433 3426 clear_preempt_need_resched(); ··· 3440 3439 rq = context_switch(rq, prev, next, &rf); 3441 3440 } else { 3442 3441 rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); 3443 - rq_unpin_lock(rq, &rf); 3444 - raw_spin_unlock_irq(&rq->lock); 3442 + rq_unlock_irq(rq, &rf); 3445 3443 } 3446 3444 3447 3445 balance_callback(rq); ··· 3684 3684 */ 3685 3685 void rt_mutex_setprio(struct task_struct *p, int prio) 3686 3686 { 3687 - int oldprio, queued, running, queue_flag = DEQUEUE_SAVE | DEQUEUE_MOVE; 3687 + int oldprio, queued, running, queue_flag = 3688 + DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK; 3688 3689 const struct sched_class *prev_class; 3689 3690 struct rq_flags rf; 3690 3691 struct rq *rq; ··· 3806 3805 queued = task_on_rq_queued(p); 3807 3806 running = task_current(rq, p); 3808 3807 if (queued) 3809 - dequeue_task(rq, p, DEQUEUE_SAVE); 3808 + dequeue_task(rq, p, DEQUEUE_SAVE | DEQUEUE_NOCLOCK); 3810 3809 if (running) 3811 3810 put_prev_task(rq, p); 3812 3811 ··· 3817 3816 delta = p->prio - old_prio; 3818 3817 3819 3818 if (queued) { 3820 - enqueue_task(rq, p, ENQUEUE_RESTORE); 3819 + enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK); 3821 3820 /* 3822 3821 * If the task increased its priority or is running and 3823 3822 * lowered its priority, then reschedule its CPU: ··· 4127 4126 const struct sched_class *prev_class; 4128 4127 struct rq_flags rf; 4129 4128 int reset_on_fork; 4130 - int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE; 4129 + int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK; 4131 4130 struct rq *rq; 4132 4131 4133 4132 /* May grab non-irq protected spin_locks: */ ··· 4924 4923 */ 4925 4924 SYSCALL_DEFINE0(sched_yield) 4926 4925 { 4927 - struct rq *rq = this_rq_lock(); 4926 + struct rq_flags rf; 4927 + struct rq *rq; 4928 + 4929 + local_irq_disable(); 4930 + rq = this_rq(); 4931 + rq_lock(rq, &rf); 4928 4932 4929 4933 schedstat_inc(rq->yld_count); 4930 4934 current->sched_class->yield_task(rq); ··· 4938 4932 * Since we are going to call schedule() anyway, there's 4939 4933 * no need to preempt or enable interrupts: 4940 4934 */ 4941 - __release(rq->lock); 4942 - spin_release(&rq->lock.dep_map, 1, _THIS_IP_); 4943 - do_raw_spin_unlock(&rq->lock); 4935 + preempt_disable(); 4936 + rq_unlock(rq, &rf); 4944 4937 sched_preempt_enable_no_resched(); 4945 4938 4946 4939 schedule(); ··· 5519 5514 p->numa_preferred_nid = nid; 5520 5515 5521 5516 if (queued) 5522 - enqueue_task(rq, p, ENQUEUE_RESTORE); 5517 + enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK); 5523 5518 if (running) 5524 5519 set_curr_task(rq, p); 5525 5520 task_rq_unlock(rq, p, &rf); ··· 5584 5579 * there's no concurrency possible, we hold the required locks anyway 5585 5580 * because of lock validation efforts. 5586 5581 */ 5587 - static void migrate_tasks(struct rq *dead_rq) 5582 + static void migrate_tasks(struct rq *dead_rq, struct rq_flags *rf) 5588 5583 { 5589 5584 struct rq *rq = dead_rq; 5590 5585 struct task_struct *next, *stop = rq->stop; 5591 - struct rq_flags rf; 5586 + struct rq_flags orf = *rf; 5592 5587 int dest_cpu; 5593 5588 5594 5589 /* ··· 5607 5602 * class method both need to have an up-to-date 5608 5603 * value of rq->clock[_task] 5609 5604 */ 5610 - rq_pin_lock(rq, &rf); 5611 5605 update_rq_clock(rq); 5612 - rq_unpin_lock(rq, &rf); 5613 5606 5614 5607 for (;;) { 5615 5608 /* ··· 5620 5617 /* 5621 5618 * pick_next_task() assumes pinned rq->lock: 5622 5619 */ 5623 - rq_repin_lock(rq, &rf); 5624 - next = pick_next_task(rq, &fake_task, &rf); 5620 + next = pick_next_task(rq, &fake_task, rf); 5625 5621 BUG_ON(!next); 5626 5622 next->sched_class->put_prev_task(rq, next); 5627 5623 ··· 5633 5631 * because !cpu_active at this point, which means load-balance 5634 5632 * will not interfere. Also, stop-machine. 5635 5633 */ 5636 - rq_unpin_lock(rq, &rf); 5637 - raw_spin_unlock(&rq->lock); 5634 + rq_unlock(rq, rf); 5638 5635 raw_spin_lock(&next->pi_lock); 5639 - raw_spin_lock(&rq->lock); 5636 + rq_relock(rq, rf); 5640 5637 5641 5638 /* 5642 5639 * Since we're inside stop-machine, _nothing_ should have ··· 5649 5648 5650 5649 /* Find suitable destination for @next, with force if needed. */ 5651 5650 dest_cpu = select_fallback_rq(dead_rq->cpu, next); 5652 - 5653 - rq = __migrate_task(rq, next, dest_cpu); 5651 + rq = __migrate_task(rq, rf, next, dest_cpu); 5654 5652 if (rq != dead_rq) { 5655 - raw_spin_unlock(&rq->lock); 5653 + rq_unlock(rq, rf); 5656 5654 rq = dead_rq; 5657 - raw_spin_lock(&rq->lock); 5655 + *rf = orf; 5656 + rq_relock(rq, rf); 5658 5657 } 5659 5658 raw_spin_unlock(&next->pi_lock); 5660 5659 } ··· 5767 5766 int sched_cpu_activate(unsigned int cpu) 5768 5767 { 5769 5768 struct rq *rq = cpu_rq(cpu); 5770 - unsigned long flags; 5769 + struct rq_flags rf; 5771 5770 5772 5771 set_cpu_active(cpu, true); 5773 5772 ··· 5785 5784 * 2) At runtime, if cpuset_cpu_active() fails to rebuild the 5786 5785 * domains. 5787 5786 */ 5788 - raw_spin_lock_irqsave(&rq->lock, flags); 5787 + rq_lock_irqsave(rq, &rf); 5789 5788 if (rq->rd) { 5790 5789 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); 5791 5790 set_rq_online(rq); 5792 5791 } 5793 - raw_spin_unlock_irqrestore(&rq->lock, flags); 5792 + rq_unlock_irqrestore(rq, &rf); 5794 5793 5795 5794 update_max_interval(); 5796 5795 ··· 5848 5847 int sched_cpu_dying(unsigned int cpu) 5849 5848 { 5850 5849 struct rq *rq = cpu_rq(cpu); 5851 - unsigned long flags; 5850 + struct rq_flags rf; 5852 5851 5853 5852 /* Handle pending wakeups and then migrate everything off */ 5854 5853 sched_ttwu_pending(); 5855 - raw_spin_lock_irqsave(&rq->lock, flags); 5854 + 5855 + rq_lock_irqsave(rq, &rf); 5856 5856 if (rq->rd) { 5857 5857 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span)); 5858 5858 set_rq_offline(rq); 5859 5859 } 5860 - migrate_tasks(rq); 5860 + migrate_tasks(rq, &rf); 5861 5861 BUG_ON(rq->nr_running != 1); 5862 - raw_spin_unlock_irqrestore(&rq->lock, flags); 5862 + rq_unlock_irqrestore(rq, &rf); 5863 + 5863 5864 calc_load_migrate(rq); 5864 5865 update_max_interval(); 5865 5866 nohz_balance_exit_idle(cpu); ··· 6415 6412 */ 6416 6413 void sched_move_task(struct task_struct *tsk) 6417 6414 { 6418 - int queued, running; 6415 + int queued, running, queue_flags = 6416 + DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK; 6419 6417 struct rq_flags rf; 6420 6418 struct rq *rq; 6421 6419 ··· 6427 6423 queued = task_on_rq_queued(tsk); 6428 6424 6429 6425 if (queued) 6430 - dequeue_task(rq, tsk, DEQUEUE_SAVE | DEQUEUE_MOVE); 6426 + dequeue_task(rq, tsk, queue_flags); 6431 6427 if (running) 6432 6428 put_prev_task(rq, tsk); 6433 6429 6434 6430 sched_change_group(tsk, TASK_MOVE_GROUP); 6435 6431 6436 6432 if (queued) 6437 - enqueue_task(rq, tsk, ENQUEUE_RESTORE | ENQUEUE_MOVE); 6433 + enqueue_task(rq, tsk, queue_flags); 6438 6434 if (running) 6439 6435 set_curr_task(rq, tsk); 6440 6436 ··· 7012 7008 for_each_online_cpu(i) { 7013 7009 struct cfs_rq *cfs_rq = tg->cfs_rq[i]; 7014 7010 struct rq *rq = cfs_rq->rq; 7011 + struct rq_flags rf; 7015 7012 7016 - raw_spin_lock_irq(&rq->lock); 7013 + rq_lock_irq(rq, &rf); 7017 7014 cfs_rq->runtime_enabled = runtime_enabled; 7018 7015 cfs_rq->runtime_remaining = 0; 7019 7016 7020 7017 if (cfs_rq->throttled) 7021 7018 unthrottle_cfs_rq(cfs_rq); 7022 - raw_spin_unlock_irq(&rq->lock); 7019 + rq_unlock_irq(rq, &rf); 7023 7020 } 7024 7021 if (runtime_was_enabled && !runtime_enabled) 7025 7022 cfs_bandwidth_usage_dec();
+57 -6
kernel/sched/deadline.c
··· 445 445 * 446 446 * This function returns true if: 447 447 * 448 - * runtime / (deadline - t) > dl_runtime / dl_period , 448 + * runtime / (deadline - t) > dl_runtime / dl_deadline , 449 449 * 450 450 * IOW we can't recycle current parameters. 451 451 * 452 - * Notice that the bandwidth check is done against the period. For 452 + * Notice that the bandwidth check is done against the deadline. For 453 453 * task with deadline equal to period this is the same of using 454 - * dl_deadline instead of dl_period in the equation above. 454 + * dl_period instead of dl_deadline in the equation above. 455 455 */ 456 456 static bool dl_entity_overflow(struct sched_dl_entity *dl_se, 457 457 struct sched_dl_entity *pi_se, u64 t) ··· 476 476 * of anything below microseconds resolution is actually fiction 477 477 * (but still we want to give the user that illusion >;). 478 478 */ 479 - left = (pi_se->dl_period >> DL_SCALE) * (dl_se->runtime >> DL_SCALE); 479 + left = (pi_se->dl_deadline >> DL_SCALE) * (dl_se->runtime >> DL_SCALE); 480 480 right = ((dl_se->deadline - t) >> DL_SCALE) * 481 481 (pi_se->dl_runtime >> DL_SCALE); 482 482 ··· 505 505 } 506 506 } 507 507 508 + static inline u64 dl_next_period(struct sched_dl_entity *dl_se) 509 + { 510 + return dl_se->deadline - dl_se->dl_deadline + dl_se->dl_period; 511 + } 512 + 508 513 /* 509 514 * If the entity depleted all its runtime, and if we want it to sleep 510 515 * while waiting for some new execution time to become available, we 511 - * set the bandwidth enforcement timer to the replenishment instant 516 + * set the bandwidth replenishment timer to the replenishment instant 512 517 * and try to activate it. 513 518 * 514 519 * Notice that it is important for the caller to know if the timer ··· 535 530 * that it is actually coming from rq->clock and not from 536 531 * hrtimer's time base reading. 537 532 */ 538 - act = ns_to_ktime(dl_se->deadline); 533 + act = ns_to_ktime(dl_next_period(dl_se)); 539 534 now = hrtimer_cb_get_time(timer); 540 535 delta = ktime_to_ns(now) - rq_clock(rq); 541 536 act = ktime_add_ns(act, delta); ··· 643 638 lockdep_unpin_lock(&rq->lock, rf.cookie); 644 639 rq = dl_task_offline_migration(rq, p); 645 640 rf.cookie = lockdep_pin_lock(&rq->lock); 641 + update_rq_clock(rq); 646 642 647 643 /* 648 644 * Now that the task has been migrated to the new RQ and we ··· 693 687 694 688 hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 695 689 timer->function = dl_task_timer; 690 + } 691 + 692 + /* 693 + * During the activation, CBS checks if it can reuse the current task's 694 + * runtime and period. If the deadline of the task is in the past, CBS 695 + * cannot use the runtime, and so it replenishes the task. This rule 696 + * works fine for implicit deadline tasks (deadline == period), and the 697 + * CBS was designed for implicit deadline tasks. However, a task with 698 + * constrained deadline (deadine < period) might be awakened after the 699 + * deadline, but before the next period. In this case, replenishing the 700 + * task would allow it to run for runtime / deadline. As in this case 701 + * deadline < period, CBS enables a task to run for more than the 702 + * runtime / period. In a very loaded system, this can cause a domino 703 + * effect, making other tasks miss their deadlines. 704 + * 705 + * To avoid this problem, in the activation of a constrained deadline 706 + * task after the deadline but before the next period, throttle the 707 + * task and set the replenishing timer to the begin of the next period, 708 + * unless it is boosted. 709 + */ 710 + static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se) 711 + { 712 + struct task_struct *p = dl_task_of(dl_se); 713 + struct rq *rq = rq_of_dl_rq(dl_rq_of_se(dl_se)); 714 + 715 + if (dl_time_before(dl_se->deadline, rq_clock(rq)) && 716 + dl_time_before(rq_clock(rq), dl_next_period(dl_se))) { 717 + if (unlikely(dl_se->dl_boosted || !start_dl_timer(p))) 718 + return; 719 + dl_se->dl_throttled = 1; 720 + } 696 721 } 697 722 698 723 static ··· 959 922 __dequeue_dl_entity(dl_se); 960 923 } 961 924 925 + static inline bool dl_is_constrained(struct sched_dl_entity *dl_se) 926 + { 927 + return dl_se->dl_deadline < dl_se->dl_period; 928 + } 929 + 962 930 static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags) 963 931 { 964 932 struct task_struct *pi_task = rt_mutex_get_top_task(p); ··· 988 946 BUG_ON(!p->dl.dl_boosted || flags != ENQUEUE_REPLENISH); 989 947 return; 990 948 } 949 + 950 + /* 951 + * Check if a constrained deadline task was activated 952 + * after the deadline but before the next period. 953 + * If that is the case, the task will be throttled and 954 + * the replenishment timer will be set to the next period. 955 + */ 956 + if (!p->dl.dl_throttled && dl_is_constrained(&p->dl)) 957 + dl_check_constrained_dl(&p->dl); 991 958 992 959 /* 993 960 * If p is throttled, we do nothing. In fact, if it exhausted
+238 -149
kernel/sched/fair.c
··· 2767 2767 * Approximate: 2768 2768 * val * y^n, where y^32 ~= 0.5 (~1 scheduling period) 2769 2769 */ 2770 - static __always_inline u64 decay_load(u64 val, u64 n) 2770 + static u64 decay_load(u64 val, u64 n) 2771 2771 { 2772 2772 unsigned int local_n; 2773 2773 ··· 2795 2795 return val; 2796 2796 } 2797 2797 2798 - /* 2799 - * For updates fully spanning n periods, the contribution to runnable 2800 - * average will be: \Sum 1024*y^n 2801 - * 2802 - * We can compute this reasonably efficiently by combining: 2803 - * y^PERIOD = 1/2 with precomputed \Sum 1024*y^n {for n <PERIOD} 2804 - */ 2805 - static u32 __compute_runnable_contrib(u64 n) 2798 + static u32 __accumulate_sum(u64 periods, u32 period_contrib, u32 remainder) 2806 2799 { 2807 - u32 contrib = 0; 2800 + u32 c1, c2, c3 = remainder; /* y^0 == 1 */ 2808 2801 2809 - if (likely(n <= LOAD_AVG_PERIOD)) 2810 - return runnable_avg_yN_sum[n]; 2811 - else if (unlikely(n >= LOAD_AVG_MAX_N)) 2802 + if (!periods) 2803 + return remainder - period_contrib; 2804 + 2805 + if (unlikely(periods >= LOAD_AVG_MAX_N)) 2812 2806 return LOAD_AVG_MAX; 2813 2807 2814 - /* Since n < LOAD_AVG_MAX_N, n/LOAD_AVG_PERIOD < 11 */ 2815 - contrib = __accumulated_sum_N32[n/LOAD_AVG_PERIOD]; 2816 - n %= LOAD_AVG_PERIOD; 2817 - contrib = decay_load(contrib, n); 2818 - return contrib + runnable_avg_yN_sum[n]; 2808 + /* 2809 + * c1 = d1 y^(p+1) 2810 + */ 2811 + c1 = decay_load((u64)(1024 - period_contrib), periods); 2812 + 2813 + periods -= 1; 2814 + /* 2815 + * For updates fully spanning n periods, the contribution to runnable 2816 + * average will be: 2817 + * 2818 + * c2 = 1024 \Sum y^n 2819 + * 2820 + * We can compute this reasonably efficiently by combining: 2821 + * 2822 + * y^PERIOD = 1/2 with precomputed 1024 \Sum y^n {for: n < PERIOD} 2823 + */ 2824 + if (likely(periods <= LOAD_AVG_PERIOD)) { 2825 + c2 = runnable_avg_yN_sum[periods]; 2826 + } else { 2827 + c2 = __accumulated_sum_N32[periods/LOAD_AVG_PERIOD]; 2828 + periods %= LOAD_AVG_PERIOD; 2829 + c2 = decay_load(c2, periods); 2830 + c2 += runnable_avg_yN_sum[periods]; 2831 + } 2832 + 2833 + return c1 + c2 + c3; 2819 2834 } 2820 2835 2821 2836 #define cap_scale(v, s) ((v)*(s) >> SCHED_CAPACITY_SHIFT) 2837 + 2838 + /* 2839 + * Accumulate the three separate parts of the sum; d1 the remainder 2840 + * of the last (incomplete) period, d2 the span of full periods and d3 2841 + * the remainder of the (incomplete) current period. 2842 + * 2843 + * d1 d2 d3 2844 + * ^ ^ ^ 2845 + * | | | 2846 + * |<->|<----------------->|<--->| 2847 + * ... |---x---|------| ... |------|-----x (now) 2848 + * 2849 + * p 2850 + * u' = (u + d1) y^(p+1) + 1024 \Sum y^n + d3 y^0 2851 + * n=1 2852 + * 2853 + * = u y^(p+1) + (Step 1) 2854 + * 2855 + * p 2856 + * d1 y^(p+1) + 1024 \Sum y^n + d3 y^0 (Step 2) 2857 + * n=1 2858 + */ 2859 + static __always_inline u32 2860 + accumulate_sum(u64 delta, int cpu, struct sched_avg *sa, 2861 + unsigned long weight, int running, struct cfs_rq *cfs_rq) 2862 + { 2863 + unsigned long scale_freq, scale_cpu; 2864 + u64 periods; 2865 + u32 contrib; 2866 + 2867 + scale_freq = arch_scale_freq_capacity(NULL, cpu); 2868 + scale_cpu = arch_scale_cpu_capacity(NULL, cpu); 2869 + 2870 + delta += sa->period_contrib; 2871 + periods = delta / 1024; /* A period is 1024us (~1ms) */ 2872 + 2873 + /* 2874 + * Step 1: decay old *_sum if we crossed period boundaries. 2875 + */ 2876 + if (periods) { 2877 + sa->load_sum = decay_load(sa->load_sum, periods); 2878 + if (cfs_rq) { 2879 + cfs_rq->runnable_load_sum = 2880 + decay_load(cfs_rq->runnable_load_sum, periods); 2881 + } 2882 + sa->util_sum = decay_load((u64)(sa->util_sum), periods); 2883 + } 2884 + 2885 + /* 2886 + * Step 2 2887 + */ 2888 + delta %= 1024; 2889 + contrib = __accumulate_sum(periods, sa->period_contrib, delta); 2890 + sa->period_contrib = delta; 2891 + 2892 + contrib = cap_scale(contrib, scale_freq); 2893 + if (weight) { 2894 + sa->load_sum += weight * contrib; 2895 + if (cfs_rq) 2896 + cfs_rq->runnable_load_sum += weight * contrib; 2897 + } 2898 + if (running) 2899 + sa->util_sum += contrib * scale_cpu; 2900 + 2901 + return periods; 2902 + } 2822 2903 2823 2904 /* 2824 2905 * We can represent the historical contribution to runnable average as the ··· 2930 2849 * = u_0 + u_1*y + u_2*y^2 + ... [re-labeling u_i --> u_{i+1}] 2931 2850 */ 2932 2851 static __always_inline int 2933 - __update_load_avg(u64 now, int cpu, struct sched_avg *sa, 2852 + ___update_load_avg(u64 now, int cpu, struct sched_avg *sa, 2934 2853 unsigned long weight, int running, struct cfs_rq *cfs_rq) 2935 2854 { 2936 - u64 delta, scaled_delta, periods; 2937 - u32 contrib; 2938 - unsigned int delta_w, scaled_delta_w, decayed = 0; 2939 - unsigned long scale_freq, scale_cpu; 2855 + u64 delta; 2940 2856 2941 2857 delta = now - sa->last_update_time; 2942 2858 /* ··· 2954 2876 return 0; 2955 2877 sa->last_update_time = now; 2956 2878 2957 - scale_freq = arch_scale_freq_capacity(NULL, cpu); 2958 - scale_cpu = arch_scale_cpu_capacity(NULL, cpu); 2879 + /* 2880 + * Now we know we crossed measurement unit boundaries. The *_avg 2881 + * accrues by two steps: 2882 + * 2883 + * Step 1: accumulate *_sum since last_update_time. If we haven't 2884 + * crossed period boundaries, finish. 2885 + */ 2886 + if (!accumulate_sum(delta, cpu, sa, weight, running, cfs_rq)) 2887 + return 0; 2959 2888 2960 - /* delta_w is the amount already accumulated against our next period */ 2961 - delta_w = sa->period_contrib; 2962 - if (delta + delta_w >= 1024) { 2963 - decayed = 1; 2964 - 2965 - /* how much left for next period will start over, we don't know yet */ 2966 - sa->period_contrib = 0; 2967 - 2968 - /* 2969 - * Now that we know we're crossing a period boundary, figure 2970 - * out how much from delta we need to complete the current 2971 - * period and accrue it. 2972 - */ 2973 - delta_w = 1024 - delta_w; 2974 - scaled_delta_w = cap_scale(delta_w, scale_freq); 2975 - if (weight) { 2976 - sa->load_sum += weight * scaled_delta_w; 2977 - if (cfs_rq) { 2978 - cfs_rq->runnable_load_sum += 2979 - weight * scaled_delta_w; 2980 - } 2981 - } 2982 - if (running) 2983 - sa->util_sum += scaled_delta_w * scale_cpu; 2984 - 2985 - delta -= delta_w; 2986 - 2987 - /* Figure out how many additional periods this update spans */ 2988 - periods = delta / 1024; 2989 - delta %= 1024; 2990 - 2991 - sa->load_sum = decay_load(sa->load_sum, periods + 1); 2992 - if (cfs_rq) { 2993 - cfs_rq->runnable_load_sum = 2994 - decay_load(cfs_rq->runnable_load_sum, periods + 1); 2995 - } 2996 - sa->util_sum = decay_load((u64)(sa->util_sum), periods + 1); 2997 - 2998 - /* Efficiently calculate \sum (1..n_period) 1024*y^i */ 2999 - contrib = __compute_runnable_contrib(periods); 3000 - contrib = cap_scale(contrib, scale_freq); 3001 - if (weight) { 3002 - sa->load_sum += weight * contrib; 3003 - if (cfs_rq) 3004 - cfs_rq->runnable_load_sum += weight * contrib; 3005 - } 3006 - if (running) 3007 - sa->util_sum += contrib * scale_cpu; 2889 + /* 2890 + * Step 2: update *_avg. 2891 + */ 2892 + sa->load_avg = div_u64(sa->load_sum, LOAD_AVG_MAX); 2893 + if (cfs_rq) { 2894 + cfs_rq->runnable_load_avg = 2895 + div_u64(cfs_rq->runnable_load_sum, LOAD_AVG_MAX); 3008 2896 } 2897 + sa->util_avg = sa->util_sum / LOAD_AVG_MAX; 3009 2898 3010 - /* Remainder of delta accrued against u_0` */ 3011 - scaled_delta = cap_scale(delta, scale_freq); 3012 - if (weight) { 3013 - sa->load_sum += weight * scaled_delta; 3014 - if (cfs_rq) 3015 - cfs_rq->runnable_load_sum += weight * scaled_delta; 3016 - } 3017 - if (running) 3018 - sa->util_sum += scaled_delta * scale_cpu; 2899 + return 1; 2900 + } 3019 2901 3020 - sa->period_contrib += delta; 2902 + static int 2903 + __update_load_avg_blocked_se(u64 now, int cpu, struct sched_entity *se) 2904 + { 2905 + return ___update_load_avg(now, cpu, &se->avg, 0, 0, NULL); 2906 + } 3021 2907 3022 - if (decayed) { 3023 - sa->load_avg = div_u64(sa->load_sum, LOAD_AVG_MAX); 3024 - if (cfs_rq) { 3025 - cfs_rq->runnable_load_avg = 3026 - div_u64(cfs_rq->runnable_load_sum, LOAD_AVG_MAX); 3027 - } 3028 - sa->util_avg = sa->util_sum / LOAD_AVG_MAX; 3029 - } 2908 + static int 2909 + __update_load_avg_se(u64 now, int cpu, struct cfs_rq *cfs_rq, struct sched_entity *se) 2910 + { 2911 + return ___update_load_avg(now, cpu, &se->avg, 2912 + se->on_rq * scale_load_down(se->load.weight), 2913 + cfs_rq->curr == se, NULL); 2914 + } 3030 2915 3031 - return decayed; 2916 + static int 2917 + __update_load_avg_cfs_rq(u64 now, int cpu, struct cfs_rq *cfs_rq) 2918 + { 2919 + return ___update_load_avg(now, cpu, &cfs_rq->avg, 2920 + scale_load_down(cfs_rq->load.weight), 2921 + cfs_rq->curr != NULL, cfs_rq); 3032 2922 } 3033 2923 3034 2924 /* ··· 3060 3014 void set_task_rq_fair(struct sched_entity *se, 3061 3015 struct cfs_rq *prev, struct cfs_rq *next) 3062 3016 { 3017 + u64 p_last_update_time; 3018 + u64 n_last_update_time; 3019 + 3063 3020 if (!sched_feat(ATTACH_AGE_LOAD)) 3064 3021 return; 3065 3022 ··· 3073 3024 * time. This will result in the wakee task is less decayed, but giving 3074 3025 * the wakee more load sounds not bad. 3075 3026 */ 3076 - if (se->avg.last_update_time && prev) { 3077 - u64 p_last_update_time; 3078 - u64 n_last_update_time; 3027 + if (!(se->avg.last_update_time && prev)) 3028 + return; 3079 3029 3080 3030 #ifndef CONFIG_64BIT 3031 + { 3081 3032 u64 p_last_update_time_copy; 3082 3033 u64 n_last_update_time_copy; 3083 3034 ··· 3092 3043 3093 3044 } while (p_last_update_time != p_last_update_time_copy || 3094 3045 n_last_update_time != n_last_update_time_copy); 3095 - #else 3096 - p_last_update_time = prev->avg.last_update_time; 3097 - n_last_update_time = next->avg.last_update_time; 3098 - #endif 3099 - __update_load_avg(p_last_update_time, cpu_of(rq_of(prev)), 3100 - &se->avg, 0, 0, NULL); 3101 - se->avg.last_update_time = n_last_update_time; 3102 3046 } 3047 + #else 3048 + p_last_update_time = prev->avg.last_update_time; 3049 + n_last_update_time = next->avg.last_update_time; 3050 + #endif 3051 + __update_load_avg_blocked_se(p_last_update_time, cpu_of(rq_of(prev)), se); 3052 + se->avg.last_update_time = n_last_update_time; 3103 3053 } 3104 3054 3105 3055 /* Take into account change of utilization of a child task group */ ··· 3221 3173 return 1; 3222 3174 } 3223 3175 3176 + /* 3177 + * Check if we need to update the load and the utilization of a blocked 3178 + * group_entity: 3179 + */ 3180 + static inline bool skip_blocked_update(struct sched_entity *se) 3181 + { 3182 + struct cfs_rq *gcfs_rq = group_cfs_rq(se); 3183 + 3184 + /* 3185 + * If sched_entity still have not zero load or utilization, we have to 3186 + * decay it: 3187 + */ 3188 + if (se->avg.load_avg || se->avg.util_avg) 3189 + return false; 3190 + 3191 + /* 3192 + * If there is a pending propagation, we have to update the load and 3193 + * the utilization of the sched_entity: 3194 + */ 3195 + if (gcfs_rq->propagate_avg) 3196 + return false; 3197 + 3198 + /* 3199 + * Otherwise, the load and the utilization of the sched_entity is 3200 + * already zero and there is no pending propagation, so it will be a 3201 + * waste of time to try to decay it: 3202 + */ 3203 + return true; 3204 + } 3205 + 3224 3206 #else /* CONFIG_FAIR_GROUP_SCHED */ 3225 3207 3226 3208 static inline void update_tg_load_avg(struct cfs_rq *cfs_rq, int force) {} ··· 3343 3265 set_tg_cfs_propagate(cfs_rq); 3344 3266 } 3345 3267 3346 - decayed = __update_load_avg(now, cpu_of(rq_of(cfs_rq)), sa, 3347 - scale_load_down(cfs_rq->load.weight), cfs_rq->curr != NULL, cfs_rq); 3268 + decayed = __update_load_avg_cfs_rq(now, cpu_of(rq_of(cfs_rq)), cfs_rq); 3348 3269 3349 3270 #ifndef CONFIG_64BIT 3350 3271 smp_wmb(); ··· 3375 3298 * Track task load average for carrying it to new CPU after migrated, and 3376 3299 * track group sched_entity load average for task_h_load calc in migration 3377 3300 */ 3378 - if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD)) { 3379 - __update_load_avg(now, cpu, &se->avg, 3380 - se->on_rq * scale_load_down(se->load.weight), 3381 - cfs_rq->curr == se, NULL); 3382 - } 3301 + if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD)) 3302 + __update_load_avg_se(now, cpu, cfs_rq, se); 3383 3303 3384 3304 decayed = update_cfs_rq_load_avg(now, cfs_rq, true); 3385 3305 decayed |= propagate_entity_load_avg(se); ··· 3481 3407 u64 last_update_time; 3482 3408 3483 3409 last_update_time = cfs_rq_last_update_time(cfs_rq); 3484 - __update_load_avg(last_update_time, cpu_of(rq_of(cfs_rq)), &se->avg, 0, 0, NULL); 3410 + __update_load_avg_blocked_se(last_update_time, cpu_of(rq_of(cfs_rq)), se); 3485 3411 } 3486 3412 3487 3413 /* ··· 4345 4271 list_for_each_entry_rcu(cfs_rq, &cfs_b->throttled_cfs_rq, 4346 4272 throttled_list) { 4347 4273 struct rq *rq = rq_of(cfs_rq); 4274 + struct rq_flags rf; 4348 4275 4349 - raw_spin_lock(&rq->lock); 4276 + rq_lock(rq, &rf); 4350 4277 if (!cfs_rq_throttled(cfs_rq)) 4351 4278 goto next; 4352 4279 ··· 4364 4289 unthrottle_cfs_rq(cfs_rq); 4365 4290 4366 4291 next: 4367 - raw_spin_unlock(&rq->lock); 4292 + rq_unlock(rq, &rf); 4368 4293 4369 4294 if (!remaining) 4370 4295 break; ··· 5172 5097 unsigned long curr_jiffies = READ_ONCE(jiffies); 5173 5098 struct rq *this_rq = this_rq(); 5174 5099 unsigned long load; 5100 + struct rq_flags rf; 5175 5101 5176 5102 if (curr_jiffies == this_rq->last_load_update_tick) 5177 5103 return; 5178 5104 5179 5105 load = weighted_cpuload(cpu_of(this_rq)); 5180 - raw_spin_lock(&this_rq->lock); 5106 + rq_lock(this_rq, &rf); 5181 5107 update_rq_clock(this_rq); 5182 5108 cpu_load_update_nohz(this_rq, curr_jiffies, load); 5183 - raw_spin_unlock(&this_rq->lock); 5109 + rq_unlock(this_rq, &rf); 5184 5110 } 5185 5111 #else /* !CONFIG_NO_HZ_COMMON */ 5186 5112 static inline void cpu_load_update_nohz(struct rq *this_rq, ··· 6845 6769 lockdep_assert_held(&env->src_rq->lock); 6846 6770 6847 6771 p->on_rq = TASK_ON_RQ_MIGRATING; 6848 - deactivate_task(env->src_rq, p, 0); 6772 + deactivate_task(env->src_rq, p, DEQUEUE_NOCLOCK); 6849 6773 set_task_cpu(p, env->dst_cpu); 6850 6774 } 6851 6775 ··· 6978 6902 lockdep_assert_held(&rq->lock); 6979 6903 6980 6904 BUG_ON(task_rq(p) != rq); 6981 - activate_task(rq, p, 0); 6905 + activate_task(rq, p, ENQUEUE_NOCLOCK); 6982 6906 p->on_rq = TASK_ON_RQ_QUEUED; 6983 6907 check_preempt_curr(rq, p, 0); 6984 6908 } ··· 6989 6913 */ 6990 6914 static void attach_one_task(struct rq *rq, struct task_struct *p) 6991 6915 { 6992 - raw_spin_lock(&rq->lock); 6916 + struct rq_flags rf; 6917 + 6918 + rq_lock(rq, &rf); 6919 + update_rq_clock(rq); 6993 6920 attach_task(rq, p); 6994 - raw_spin_unlock(&rq->lock); 6921 + rq_unlock(rq, &rf); 6995 6922 } 6996 6923 6997 6924 /* ··· 7005 6926 { 7006 6927 struct list_head *tasks = &env->tasks; 7007 6928 struct task_struct *p; 6929 + struct rq_flags rf; 7008 6930 7009 - raw_spin_lock(&env->dst_rq->lock); 6931 + rq_lock(env->dst_rq, &rf); 6932 + update_rq_clock(env->dst_rq); 7010 6933 7011 6934 while (!list_empty(tasks)) { 7012 6935 p = list_first_entry(tasks, struct task_struct, se.group_node); ··· 7017 6936 attach_task(env->dst_rq, p); 7018 6937 } 7019 6938 7020 - raw_spin_unlock(&env->dst_rq->lock); 6939 + rq_unlock(env->dst_rq, &rf); 7021 6940 } 7022 6941 7023 6942 #ifdef CONFIG_FAIR_GROUP_SCHED ··· 7025 6944 { 7026 6945 struct rq *rq = cpu_rq(cpu); 7027 6946 struct cfs_rq *cfs_rq; 7028 - unsigned long flags; 6947 + struct rq_flags rf; 7029 6948 7030 - raw_spin_lock_irqsave(&rq->lock, flags); 6949 + rq_lock_irqsave(rq, &rf); 7031 6950 update_rq_clock(rq); 7032 6951 7033 6952 /* ··· 7035 6954 * list_add_leaf_cfs_rq() for details. 7036 6955 */ 7037 6956 for_each_leaf_cfs_rq(rq, cfs_rq) { 6957 + struct sched_entity *se; 6958 + 7038 6959 /* throttled entities do not contribute to load */ 7039 6960 if (throttled_hierarchy(cfs_rq)) 7040 6961 continue; ··· 7044 6961 if (update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq, true)) 7045 6962 update_tg_load_avg(cfs_rq, 0); 7046 6963 7047 - /* Propagate pending load changes to the parent */ 7048 - if (cfs_rq->tg->se[cpu]) 7049 - update_load_avg(cfs_rq->tg->se[cpu], 0); 6964 + /* Propagate pending load changes to the parent, if any: */ 6965 + se = cfs_rq->tg->se[cpu]; 6966 + if (se && !skip_blocked_update(se)) 6967 + update_load_avg(se, 0); 7050 6968 } 7051 - raw_spin_unlock_irqrestore(&rq->lock, flags); 6969 + rq_unlock_irqrestore(rq, &rf); 7052 6970 } 7053 6971 7054 6972 /* ··· 7103 7019 { 7104 7020 struct rq *rq = cpu_rq(cpu); 7105 7021 struct cfs_rq *cfs_rq = &rq->cfs; 7106 - unsigned long flags; 7022 + struct rq_flags rf; 7107 7023 7108 - raw_spin_lock_irqsave(&rq->lock, flags); 7024 + rq_lock_irqsave(rq, &rf); 7109 7025 update_rq_clock(rq); 7110 7026 update_cfs_rq_load_avg(cfs_rq_clock_task(cfs_rq), cfs_rq, true); 7111 - raw_spin_unlock_irqrestore(&rq->lock, flags); 7027 + rq_unlock_irqrestore(rq, &rf); 7112 7028 } 7113 7029 7114 7030 static unsigned long task_h_load(struct task_struct *p) ··· 7609 7525 { 7610 7526 struct sched_domain *child = env->sd->child; 7611 7527 struct sched_group *sg = env->sd->groups; 7528 + struct sg_lb_stats *local = &sds->local_stat; 7612 7529 struct sg_lb_stats tmp_sgs; 7613 7530 int load_idx, prefer_sibling = 0; 7614 7531 bool overload = false; ··· 7626 7541 local_group = cpumask_test_cpu(env->dst_cpu, sched_group_cpus(sg)); 7627 7542 if (local_group) { 7628 7543 sds->local = sg; 7629 - sgs = &sds->local_stat; 7544 + sgs = local; 7630 7545 7631 7546 if (env->idle != CPU_NEWLY_IDLE || 7632 7547 time_after_eq(jiffies, sg->sgc->next_update)) ··· 7650 7565 * the tasks on the system). 7651 7566 */ 7652 7567 if (prefer_sibling && sds->local && 7653 - group_has_capacity(env, &sds->local_stat) && 7654 - (sgs->sum_nr_running > 1)) { 7568 + group_has_capacity(env, local) && 7569 + (sgs->sum_nr_running > local->sum_nr_running + 1)) { 7655 7570 sgs->group_no_capacity = 1; 7656 7571 sgs->group_type = group_classify(sg, sgs); 7657 7572 } ··· 8127 8042 struct sched_domain *sd_parent = sd->parent; 8128 8043 struct sched_group *group; 8129 8044 struct rq *busiest; 8130 - unsigned long flags; 8045 + struct rq_flags rf; 8131 8046 struct cpumask *cpus = this_cpu_cpumask_var_ptr(load_balance_mask); 8132 8047 8133 8048 struct lb_env env = { ··· 8190 8105 env.loop_max = min(sysctl_sched_nr_migrate, busiest->nr_running); 8191 8106 8192 8107 more_balance: 8193 - raw_spin_lock_irqsave(&busiest->lock, flags); 8108 + rq_lock_irqsave(busiest, &rf); 8194 8109 update_rq_clock(busiest); 8195 8110 8196 8111 /* ··· 8207 8122 * See task_rq_lock() family for the details. 8208 8123 */ 8209 8124 8210 - raw_spin_unlock(&busiest->lock); 8125 + rq_unlock(busiest, &rf); 8211 8126 8212 8127 if (cur_ld_moved) { 8213 8128 attach_tasks(&env); 8214 8129 ld_moved += cur_ld_moved; 8215 8130 } 8216 8131 8217 - local_irq_restore(flags); 8132 + local_irq_restore(rf.flags); 8218 8133 8219 8134 if (env.flags & LBF_NEED_BREAK) { 8220 8135 env.flags &= ~LBF_NEED_BREAK; ··· 8292 8207 sd->nr_balance_failed++; 8293 8208 8294 8209 if (need_active_balance(&env)) { 8210 + unsigned long flags; 8211 + 8295 8212 raw_spin_lock_irqsave(&busiest->lock, flags); 8296 8213 8297 8214 /* don't kick the active_load_balance_cpu_stop, ··· 8531 8444 struct rq *target_rq = cpu_rq(target_cpu); 8532 8445 struct sched_domain *sd; 8533 8446 struct task_struct *p = NULL; 8447 + struct rq_flags rf; 8534 8448 8535 - raw_spin_lock_irq(&busiest_rq->lock); 8449 + rq_lock_irq(busiest_rq, &rf); 8536 8450 8537 8451 /* make sure the requested cpu hasn't gone down in the meantime */ 8538 8452 if (unlikely(busiest_cpu != smp_processor_id() || ··· 8584 8496 rcu_read_unlock(); 8585 8497 out_unlock: 8586 8498 busiest_rq->active_balance = 0; 8587 - raw_spin_unlock(&busiest_rq->lock); 8499 + rq_unlock(busiest_rq, &rf); 8588 8500 8589 8501 if (p) 8590 8502 attach_one_task(target_rq, p); ··· 8882 8794 * do the balance. 8883 8795 */ 8884 8796 if (time_after_eq(jiffies, rq->next_balance)) { 8885 - raw_spin_lock_irq(&rq->lock); 8797 + struct rq_flags rf; 8798 + 8799 + rq_lock_irq(rq, &rf); 8886 8800 update_rq_clock(rq); 8887 8801 cpu_load_update_idle(rq); 8888 - raw_spin_unlock_irq(&rq->lock); 8802 + rq_unlock_irq(rq, &rf); 8803 + 8889 8804 rebalance_domains(rq, CPU_IDLE); 8890 8805 } 8891 8806 ··· 9079 8988 struct cfs_rq *cfs_rq; 9080 8989 struct sched_entity *se = &p->se, *curr; 9081 8990 struct rq *rq = this_rq(); 8991 + struct rq_flags rf; 9082 8992 9083 - raw_spin_lock(&rq->lock); 8993 + rq_lock(rq, &rf); 9084 8994 update_rq_clock(rq); 9085 8995 9086 8996 cfs_rq = task_cfs_rq(current); ··· 9102 9010 } 9103 9011 9104 9012 se->vruntime -= cfs_rq->min_vruntime; 9105 - raw_spin_unlock(&rq->lock); 9013 + rq_unlock(rq, &rf); 9106 9014 } 9107 9015 9108 9016 /* ··· 9464 9372 int sched_group_set_shares(struct task_group *tg, unsigned long shares) 9465 9373 { 9466 9374 int i; 9467 - unsigned long flags; 9468 9375 9469 9376 /* 9470 9377 * We can't change the weight of the root cgroup. ··· 9480 9389 tg->shares = shares; 9481 9390 for_each_possible_cpu(i) { 9482 9391 struct rq *rq = cpu_rq(i); 9483 - struct sched_entity *se; 9392 + struct sched_entity *se = tg->se[i]; 9393 + struct rq_flags rf; 9484 9394 9485 - se = tg->se[i]; 9486 9395 /* Propagate contribution to hierarchy */ 9487 - raw_spin_lock_irqsave(&rq->lock, flags); 9488 - 9489 - /* Possible calls to update_curr() need rq clock */ 9396 + rq_lock_irqsave(rq, &rf); 9490 9397 update_rq_clock(rq); 9491 9398 for_each_sched_entity(se) { 9492 9399 update_load_avg(se, UPDATE_TG); 9493 9400 update_cfs_shares(se); 9494 9401 } 9495 - raw_spin_unlock_irqrestore(&rq->lock, flags); 9402 + rq_unlock_irqrestore(rq, &rf); 9496 9403 } 9497 9404 9498 9405 done:
+7
kernel/sched/features.h
··· 56 56 */ 57 57 SCHED_FEAT(SIS_AVG_CPU, false) 58 58 59 + /* 60 + * Issue a WARN when we do multiple update_rq_clock() calls 61 + * in a single rq->lock section. Default disabled because the 62 + * annotations are not complete. 63 + */ 64 + SCHED_FEAT(WARN_DOUBLE_CLOCK, false) 65 + 59 66 #ifdef HAVE_RT_PUSH_IPI 60 67 /* 61 68 * In order to avoid a thundering herd attack of CPUs that are
+12 -8
kernel/sched/loadavg.c
··· 169 169 * If the folding window started, make sure we start writing in the 170 170 * next idle-delta. 171 171 */ 172 - if (!time_before(jiffies, calc_load_update)) 172 + if (!time_before(jiffies, READ_ONCE(calc_load_update))) 173 173 idx++; 174 174 175 175 return idx & 1; ··· 202 202 struct rq *this_rq = this_rq(); 203 203 204 204 /* 205 - * If we're still before the sample window, we're done. 205 + * If we're still before the pending sample window, we're done. 206 206 */ 207 + this_rq->calc_load_update = READ_ONCE(calc_load_update); 207 208 if (time_before(jiffies, this_rq->calc_load_update)) 208 209 return; 209 210 ··· 213 212 * accounted through the nohz accounting, so skip the entire deal and 214 213 * sync up for the next window. 215 214 */ 216 - this_rq->calc_load_update = calc_load_update; 217 215 if (time_before(jiffies, this_rq->calc_load_update + 10)) 218 216 this_rq->calc_load_update += LOAD_FREQ; 219 217 } ··· 308 308 */ 309 309 static void calc_global_nohz(void) 310 310 { 311 + unsigned long sample_window; 311 312 long delta, active, n; 312 313 313 - if (!time_before(jiffies, calc_load_update + 10)) { 314 + sample_window = READ_ONCE(calc_load_update); 315 + if (!time_before(jiffies, sample_window + 10)) { 314 316 /* 315 317 * Catch-up, fold however many we are behind still 316 318 */ 317 - delta = jiffies - calc_load_update - 10; 319 + delta = jiffies - sample_window - 10; 318 320 n = 1 + (delta / LOAD_FREQ); 319 321 320 322 active = atomic_long_read(&calc_load_tasks); ··· 326 324 avenrun[1] = calc_load_n(avenrun[1], EXP_5, active, n); 327 325 avenrun[2] = calc_load_n(avenrun[2], EXP_15, active, n); 328 326 329 - calc_load_update += n * LOAD_FREQ; 327 + WRITE_ONCE(calc_load_update, sample_window + n * LOAD_FREQ); 330 328 } 331 329 332 330 /* ··· 354 352 */ 355 353 void calc_global_load(unsigned long ticks) 356 354 { 355 + unsigned long sample_window; 357 356 long active, delta; 358 357 359 - if (time_before(jiffies, calc_load_update + 10)) 358 + sample_window = READ_ONCE(calc_load_update); 359 + if (time_before(jiffies, sample_window + 10)) 360 360 return; 361 361 362 362 /* ··· 375 371 avenrun[1] = calc_load(avenrun[1], EXP_5, active); 376 372 avenrun[2] = calc_load(avenrun[2], EXP_15, active); 377 373 378 - calc_load_update += LOAD_FREQ; 374 + WRITE_ONCE(calc_load_update, sample_window + LOAD_FREQ); 379 375 380 376 /* 381 377 * In case we idled for multiple LOAD_FREQ intervals, catch up in bulk.
+81
kernel/sched/rt.c
··· 1927 1927 #define RT_PUSH_IPI_EXECUTING 1 1928 1928 #define RT_PUSH_IPI_RESTART 2 1929 1929 1930 + /* 1931 + * When a high priority task schedules out from a CPU and a lower priority 1932 + * task is scheduled in, a check is made to see if there's any RT tasks 1933 + * on other CPUs that are waiting to run because a higher priority RT task 1934 + * is currently running on its CPU. In this case, the CPU with multiple RT 1935 + * tasks queued on it (overloaded) needs to be notified that a CPU has opened 1936 + * up that may be able to run one of its non-running queued RT tasks. 1937 + * 1938 + * On large CPU boxes, there's the case that several CPUs could schedule 1939 + * a lower priority task at the same time, in which case it will look for 1940 + * any overloaded CPUs that it could pull a task from. To do this, the runqueue 1941 + * lock must be taken from that overloaded CPU. Having 10s of CPUs all fighting 1942 + * for a single overloaded CPU's runqueue lock can produce a large latency. 1943 + * (This has actually been observed on large boxes running cyclictest). 1944 + * Instead of taking the runqueue lock of the overloaded CPU, each of the 1945 + * CPUs that scheduled a lower priority task simply sends an IPI to the 1946 + * overloaded CPU. An IPI is much cheaper than taking an runqueue lock with 1947 + * lots of contention. The overloaded CPU will look to push its non-running 1948 + * RT task off, and if it does, it can then ignore the other IPIs coming 1949 + * in, and just pass those IPIs off to any other overloaded CPU. 1950 + * 1951 + * When a CPU schedules a lower priority task, it only sends an IPI to 1952 + * the "next" CPU that has overloaded RT tasks. This prevents IPI storms, 1953 + * as having 10 CPUs scheduling lower priority tasks and 10 CPUs with 1954 + * RT overloaded tasks, would cause 100 IPIs to go out at once. 1955 + * 1956 + * The overloaded RT CPU, when receiving an IPI, will try to push off its 1957 + * overloaded RT tasks and then send an IPI to the next CPU that has 1958 + * overloaded RT tasks. This stops when all CPUs with overloaded RT tasks 1959 + * have completed. Just because a CPU may have pushed off its own overloaded 1960 + * RT task does not mean it should stop sending the IPI around to other 1961 + * overloaded CPUs. There may be another RT task waiting to run on one of 1962 + * those CPUs that are of higher priority than the one that was just 1963 + * pushed. 1964 + * 1965 + * An optimization that could possibly be made is to make a CPU array similar 1966 + * to the cpupri array mask of all running RT tasks, but for the overloaded 1967 + * case, then the IPI could be sent to only the CPU with the highest priority 1968 + * RT task waiting, and that CPU could send off further IPIs to the CPU with 1969 + * the next highest waiting task. Since the overloaded case is much less likely 1970 + * to happen, the complexity of this implementation may not be worth it. 1971 + * Instead, just send an IPI around to all overloaded CPUs. 1972 + * 1973 + * The rq->rt.push_flags holds the status of the IPI that is going around. 1974 + * A run queue can only send out a single IPI at a time. The possible flags 1975 + * for rq->rt.push_flags are: 1976 + * 1977 + * (None or zero): No IPI is going around for the current rq 1978 + * RT_PUSH_IPI_EXECUTING: An IPI for the rq is being passed around 1979 + * RT_PUSH_IPI_RESTART: The priority of the running task for the rq 1980 + * has changed, and the IPI should restart 1981 + * circulating the overloaded CPUs again. 1982 + * 1983 + * rq->rt.push_cpu contains the CPU that is being sent the IPI. It is updated 1984 + * before sending to the next CPU. 1985 + * 1986 + * Instead of having all CPUs that schedule a lower priority task send 1987 + * an IPI to the same "first" CPU in the RT overload mask, they send it 1988 + * to the next overloaded CPU after their own CPU. This helps distribute 1989 + * the work when there's more than one overloaded CPU and multiple CPUs 1990 + * scheduling in lower priority tasks. 1991 + * 1992 + * When a rq schedules a lower priority task than what was currently 1993 + * running, the next CPU with overloaded RT tasks is examined first. 1994 + * That is, if CPU 1 and 5 are overloaded, and CPU 3 schedules a lower 1995 + * priority task, it will send an IPI first to CPU 5, then CPU 5 will 1996 + * send to CPU 1 if it is still overloaded. CPU 1 will clear the 1997 + * rq->rt.push_flags if RT_PUSH_IPI_RESTART is not set. 1998 + * 1999 + * The first CPU to notice IPI_RESTART is set, will clear that flag and then 2000 + * send an IPI to the next overloaded CPU after the rq->cpu and not the next 2001 + * CPU after push_cpu. That is, if CPU 1, 4 and 5 are overloaded when CPU 3 2002 + * schedules a lower priority task, and the IPI_RESTART gets set while the 2003 + * handling is being done on CPU 5, it will clear the flag and send it back to 2004 + * CPU 4 instead of CPU 1. 2005 + * 2006 + * Note, the above logic can be disabled by turning off the sched_feature 2007 + * RT_PUSH_IPI. Then the rq lock of the overloaded CPU will simply be 2008 + * taken by the CPU requesting a pull and the waiting RT task will be pulled 2009 + * by that CPU. This may be fine for machines with few CPUs. 2010 + */ 1930 2011 static void tell_cpu_to_push(struct rq *rq) 1931 2012 { 1932 2013 int cpu;
+62 -3
kernel/sched/sched.h
··· 1331 1331 #define DEQUEUE_SLEEP 0x01 1332 1332 #define DEQUEUE_SAVE 0x02 /* matches ENQUEUE_RESTORE */ 1333 1333 #define DEQUEUE_MOVE 0x04 /* matches ENQUEUE_MOVE */ 1334 + #define DEQUEUE_NOCLOCK 0x08 /* matches ENQUEUE_NOCLOCK */ 1334 1335 1335 1336 #define ENQUEUE_WAKEUP 0x01 1336 1337 #define ENQUEUE_RESTORE 0x02 1337 1338 #define ENQUEUE_MOVE 0x04 1339 + #define ENQUEUE_NOCLOCK 0x08 1338 1340 1339 - #define ENQUEUE_HEAD 0x08 1340 - #define ENQUEUE_REPLENISH 0x10 1341 + #define ENQUEUE_HEAD 0x10 1342 + #define ENQUEUE_REPLENISH 0x20 1341 1343 #ifdef CONFIG_SMP 1342 - #define ENQUEUE_MIGRATED 0x20 1344 + #define ENQUEUE_MIGRATED 0x40 1343 1345 #else 1344 1346 #define ENQUEUE_MIGRATED 0x00 1345 1347 #endif ··· 1626 1624 1627 1625 struct rq *__task_rq_lock(struct task_struct *p, struct rq_flags *rf) 1628 1626 __acquires(rq->lock); 1627 + 1629 1628 struct rq *task_rq_lock(struct task_struct *p, struct rq_flags *rf) 1630 1629 __acquires(p->pi_lock) 1631 1630 __acquires(rq->lock); ··· 1646 1643 rq_unpin_lock(rq, rf); 1647 1644 raw_spin_unlock(&rq->lock); 1648 1645 raw_spin_unlock_irqrestore(&p->pi_lock, rf->flags); 1646 + } 1647 + 1648 + static inline void 1649 + rq_lock_irqsave(struct rq *rq, struct rq_flags *rf) 1650 + __acquires(rq->lock) 1651 + { 1652 + raw_spin_lock_irqsave(&rq->lock, rf->flags); 1653 + rq_pin_lock(rq, rf); 1654 + } 1655 + 1656 + static inline void 1657 + rq_lock_irq(struct rq *rq, struct rq_flags *rf) 1658 + __acquires(rq->lock) 1659 + { 1660 + raw_spin_lock_irq(&rq->lock); 1661 + rq_pin_lock(rq, rf); 1662 + } 1663 + 1664 + static inline void 1665 + rq_lock(struct rq *rq, struct rq_flags *rf) 1666 + __acquires(rq->lock) 1667 + { 1668 + raw_spin_lock(&rq->lock); 1669 + rq_pin_lock(rq, rf); 1670 + } 1671 + 1672 + static inline void 1673 + rq_relock(struct rq *rq, struct rq_flags *rf) 1674 + __acquires(rq->lock) 1675 + { 1676 + raw_spin_lock(&rq->lock); 1677 + rq_repin_lock(rq, rf); 1678 + } 1679 + 1680 + static inline void 1681 + rq_unlock_irqrestore(struct rq *rq, struct rq_flags *rf) 1682 + __releases(rq->lock) 1683 + { 1684 + rq_unpin_lock(rq, rf); 1685 + raw_spin_unlock_irqrestore(&rq->lock, rf->flags); 1686 + } 1687 + 1688 + static inline void 1689 + rq_unlock_irq(struct rq *rq, struct rq_flags *rf) 1690 + __releases(rq->lock) 1691 + { 1692 + rq_unpin_lock(rq, rf); 1693 + raw_spin_unlock_irq(&rq->lock); 1694 + } 1695 + 1696 + static inline void 1697 + rq_unlock(struct rq *rq, struct rq_flags *rf) 1698 + __releases(rq->lock) 1699 + { 1700 + rq_unpin_lock(rq, rf); 1701 + raw_spin_unlock(&rq->lock); 1649 1702 } 1650 1703 1651 1704 #ifdef CONFIG_SMP
+1
kernel/workqueue.c
··· 1507 1507 struct timer_list *timer = &dwork->timer; 1508 1508 struct work_struct *work = &dwork->work; 1509 1509 1510 + WARN_ON_ONCE(!wq); 1510 1511 WARN_ON_ONCE(timer->function != delayed_work_timer_fn || 1511 1512 timer->data != (unsigned long)dwork); 1512 1513 WARN_ON_ONCE(timer_pending(timer));
+1 -1
mm/gup.c
··· 1455 1455 if (!gup_huge_pd(__hugepd(p4d_val(p4d)), addr, 1456 1456 P4D_SHIFT, next, write, pages, nr)) 1457 1457 return 0; 1458 - } else if (!gup_p4d_range(p4d, addr, next, write, pages, nr)) 1458 + } else if (!gup_pud_range(p4d, addr, next, write, pages, nr)) 1459 1459 return 0; 1460 1460 } while (p4dp++, addr = next, addr != end); 1461 1461
+3 -4
mm/percpu-vm.c
··· 21 21 22 22 /** 23 23 * pcpu_get_pages - get temp pages array 24 - * @chunk: chunk of interest 25 24 * 26 25 * Returns pointer to array of pointers to struct page which can be indexed 27 26 * with pcpu_page_idx(). Note that there is only one array and accesses ··· 29 30 * RETURNS: 30 31 * Pointer to temp pages array on success. 31 32 */ 32 - static struct page **pcpu_get_pages(struct pcpu_chunk *chunk_alloc) 33 + static struct page **pcpu_get_pages(void) 33 34 { 34 35 static struct page **pages; 35 36 size_t pages_size = pcpu_nr_units * pcpu_unit_pages * sizeof(pages[0]); ··· 274 275 { 275 276 struct page **pages; 276 277 277 - pages = pcpu_get_pages(chunk); 278 + pages = pcpu_get_pages(); 278 279 if (!pages) 279 280 return -ENOMEM; 280 281 ··· 312 313 * successful population attempt so the temp pages array must 313 314 * be available now. 314 315 */ 315 - pages = pcpu_get_pages(chunk); 316 + pages = pcpu_get_pages(); 316 317 BUG_ON(!pages); 317 318 318 319 /* unmap and free */
+4 -1
mm/percpu.c
··· 1011 1011 mutex_unlock(&pcpu_alloc_mutex); 1012 1012 } 1013 1013 1014 - if (chunk != pcpu_reserved_chunk) 1014 + if (chunk != pcpu_reserved_chunk) { 1015 + spin_lock_irqsave(&pcpu_lock, flags); 1015 1016 pcpu_nr_empty_pop_pages -= occ_pages; 1017 + spin_unlock_irqrestore(&pcpu_lock, flags); 1018 + } 1016 1019 1017 1020 if (pcpu_nr_empty_pop_pages < PCPU_EMPTY_POP_PAGES_LOW) 1018 1021 pcpu_schedule_balance_work();
+3 -2
net/atm/svc.c
··· 318 318 return error; 319 319 } 320 320 321 - static int svc_accept(struct socket *sock, struct socket *newsock, int flags) 321 + static int svc_accept(struct socket *sock, struct socket *newsock, int flags, 322 + bool kern) 322 323 { 323 324 struct sock *sk = sock->sk; 324 325 struct sk_buff *skb; ··· 330 329 331 330 lock_sock(sk); 332 331 333 - error = svc_create(sock_net(sk), newsock, 0, 0); 332 + error = svc_create(sock_net(sk), newsock, 0, kern); 334 333 if (error) 335 334 goto out; 336 335
+2 -1
net/ax25/af_ax25.c
··· 1320 1320 return err; 1321 1321 } 1322 1322 1323 - static int ax25_accept(struct socket *sock, struct socket *newsock, int flags) 1323 + static int ax25_accept(struct socket *sock, struct socket *newsock, int flags, 1324 + bool kern) 1324 1325 { 1325 1326 struct sk_buff *skb; 1326 1327 struct sock *newsk;
+1 -1
net/bluetooth/l2cap_sock.c
··· 301 301 } 302 302 303 303 static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, 304 - int flags) 304 + int flags, bool kern) 305 305 { 306 306 DEFINE_WAIT_FUNC(wait, woken_wake_function); 307 307 struct sock *sk = sock->sk, *nsk;
+2 -1
net/bluetooth/rfcomm/sock.c
··· 471 471 return err; 472 472 } 473 473 474 - static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags) 474 + static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags, 475 + bool kern) 475 476 { 476 477 DEFINE_WAIT_FUNC(wait, woken_wake_function); 477 478 struct sock *sk = sock->sk, *nsk;
+1 -1
net/bluetooth/sco.c
··· 627 627 } 628 628 629 629 static int sco_sock_accept(struct socket *sock, struct socket *newsock, 630 - int flags) 630 + int flags, bool kern) 631 631 { 632 632 DEFINE_WAIT_FUNC(wait, woken_wake_function); 633 633 struct sock *sk = sock->sk, *ch;
+1
net/bridge/br_input.c
··· 30 30 static int 31 31 br_netif_receive_skb(struct net *net, struct sock *sk, struct sk_buff *skb) 32 32 { 33 + br_drop_fake_rtable(skb); 33 34 return netif_receive_skb(skb); 34 35 } 35 36
-21
net/bridge/br_netfilter_hooks.c
··· 521 521 } 522 522 523 523 524 - /* PF_BRIDGE/LOCAL_IN ************************************************/ 525 - /* The packet is locally destined, which requires a real 526 - * dst_entry, so detach the fake one. On the way up, the 527 - * packet would pass through PRE_ROUTING again (which already 528 - * took place when the packet entered the bridge), but we 529 - * register an IPv4 PRE_ROUTING 'sabotage' hook that will 530 - * prevent this from happening. */ 531 - static unsigned int br_nf_local_in(void *priv, 532 - struct sk_buff *skb, 533 - const struct nf_hook_state *state) 534 - { 535 - br_drop_fake_rtable(skb); 536 - return NF_ACCEPT; 537 - } 538 - 539 524 /* PF_BRIDGE/FORWARD *************************************************/ 540 525 static int br_nf_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb) 541 526 { ··· 890 905 .hook = br_nf_pre_routing, 891 906 .pf = NFPROTO_BRIDGE, 892 907 .hooknum = NF_BR_PRE_ROUTING, 893 - .priority = NF_BR_PRI_BRNF, 894 - }, 895 - { 896 - .hook = br_nf_local_in, 897 - .pf = NFPROTO_BRIDGE, 898 - .hooknum = NF_BR_LOCAL_IN, 899 908 .priority = NF_BR_PRI_BRNF, 900 909 }, 901 910 {
+1
net/core/dev.c
··· 1304 1304 { 1305 1305 rtnl_lock(); 1306 1306 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, dev); 1307 + call_netdevice_notifiers(NETDEV_RESEND_IGMP, dev); 1307 1308 rtnl_unlock(); 1308 1309 } 1309 1310 EXPORT_SYMBOL(netdev_notify_peers);
+3 -3
net/core/net-sysfs.c
··· 953 953 while (--i >= new_num) { 954 954 struct kobject *kobj = &dev->_rx[i].kobj; 955 955 956 - if (!list_empty(&dev_net(dev)->exit_list)) 956 + if (!atomic_read(&dev_net(dev)->count)) 957 957 kobj->uevent_suppress = 1; 958 958 if (dev->sysfs_rx_queue_group) 959 959 sysfs_remove_group(kobj, dev->sysfs_rx_queue_group); ··· 1371 1371 while (--i >= new_num) { 1372 1372 struct netdev_queue *queue = dev->_tx + i; 1373 1373 1374 - if (!list_empty(&dev_net(dev)->exit_list)) 1374 + if (!atomic_read(&dev_net(dev)->count)) 1375 1375 queue->kobj.uevent_suppress = 1; 1376 1376 #ifdef CONFIG_BQL 1377 1377 sysfs_remove_group(&queue->kobj, &dql_group); ··· 1558 1558 { 1559 1559 struct device *dev = &(ndev->dev); 1560 1560 1561 - if (!list_empty(&dev_net(ndev)->exit_list)) 1561 + if (!atomic_read(&dev_net(ndev)->count)) 1562 1562 dev_set_uevent_suppress(dev, 1); 1563 1563 1564 1564 kobject_get(&dev->kobj);
+16 -14
net/core/skbuff.c
··· 3828 3828 if (!skb_may_tx_timestamp(sk, false)) 3829 3829 return; 3830 3830 3831 - /* take a reference to prevent skb_orphan() from freeing the socket */ 3832 - sock_hold(sk); 3833 - 3834 - *skb_hwtstamps(skb) = *hwtstamps; 3835 - __skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND); 3836 - 3837 - sock_put(sk); 3831 + /* Take a reference to prevent skb_orphan() from freeing the socket, 3832 + * but only if the socket refcount is not zero. 3833 + */ 3834 + if (likely(atomic_inc_not_zero(&sk->sk_refcnt))) { 3835 + *skb_hwtstamps(skb) = *hwtstamps; 3836 + __skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND); 3837 + sock_put(sk); 3838 + } 3838 3839 } 3839 3840 EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp); 3840 3841 ··· 3894 3893 { 3895 3894 struct sock *sk = skb->sk; 3896 3895 struct sock_exterr_skb *serr; 3897 - int err; 3896 + int err = 1; 3898 3897 3899 3898 skb->wifi_acked_valid = 1; 3900 3899 skb->wifi_acked = acked; ··· 3904 3903 serr->ee.ee_errno = ENOMSG; 3905 3904 serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS; 3906 3905 3907 - /* take a reference to prevent skb_orphan() from freeing the socket */ 3908 - sock_hold(sk); 3909 - 3910 - err = sock_queue_err_skb(sk, skb); 3906 + /* Take a reference to prevent skb_orphan() from freeing the socket, 3907 + * but only if the socket refcount is not zero. 3908 + */ 3909 + if (likely(atomic_inc_not_zero(&sk->sk_refcnt))) { 3910 + err = sock_queue_err_skb(sk, skb); 3911 + sock_put(sk); 3912 + } 3911 3913 if (err) 3912 3914 kfree_skb(skb); 3913 - 3914 - sock_put(sk); 3915 3915 } 3916 3916 EXPORT_SYMBOL_GPL(skb_complete_wifi_ack); 3917 3917
+57 -49
net/core/sock.c
··· 197 197 198 198 /* 199 199 * Each address family might have different locking rules, so we have 200 - * one slock key per address family: 200 + * one slock key per address family and separate keys for internal and 201 + * userspace sockets. 201 202 */ 202 203 static struct lock_class_key af_family_keys[AF_MAX]; 204 + static struct lock_class_key af_family_kern_keys[AF_MAX]; 203 205 static struct lock_class_key af_family_slock_keys[AF_MAX]; 206 + static struct lock_class_key af_family_kern_slock_keys[AF_MAX]; 204 207 205 208 /* 206 209 * Make lock validator output more readable. (we pre-construct these 207 210 * strings build-time, so that runtime initialization of socket 208 211 * locks is fast): 209 212 */ 213 + 214 + #define _sock_locks(x) \ 215 + x "AF_UNSPEC", x "AF_UNIX" , x "AF_INET" , \ 216 + x "AF_AX25" , x "AF_IPX" , x "AF_APPLETALK", \ 217 + x "AF_NETROM", x "AF_BRIDGE" , x "AF_ATMPVC" , \ 218 + x "AF_X25" , x "AF_INET6" , x "AF_ROSE" , \ 219 + x "AF_DECnet", x "AF_NETBEUI" , x "AF_SECURITY" , \ 220 + x "AF_KEY" , x "AF_NETLINK" , x "AF_PACKET" , \ 221 + x "AF_ASH" , x "AF_ECONET" , x "AF_ATMSVC" , \ 222 + x "AF_RDS" , x "AF_SNA" , x "AF_IRDA" , \ 223 + x "AF_PPPOX" , x "AF_WANPIPE" , x "AF_LLC" , \ 224 + x "27" , x "28" , x "AF_CAN" , \ 225 + x "AF_TIPC" , x "AF_BLUETOOTH", x "IUCV" , \ 226 + x "AF_RXRPC" , x "AF_ISDN" , x "AF_PHONET" , \ 227 + x "AF_IEEE802154", x "AF_CAIF" , x "AF_ALG" , \ 228 + x "AF_NFC" , x "AF_VSOCK" , x "AF_KCM" , \ 229 + x "AF_QIPCRTR", x "AF_SMC" , x "AF_MAX" 230 + 210 231 static const char *const af_family_key_strings[AF_MAX+1] = { 211 - "sk_lock-AF_UNSPEC", "sk_lock-AF_UNIX" , "sk_lock-AF_INET" , 212 - "sk_lock-AF_AX25" , "sk_lock-AF_IPX" , "sk_lock-AF_APPLETALK", 213 - "sk_lock-AF_NETROM", "sk_lock-AF_BRIDGE" , "sk_lock-AF_ATMPVC" , 214 - "sk_lock-AF_X25" , "sk_lock-AF_INET6" , "sk_lock-AF_ROSE" , 215 - "sk_lock-AF_DECnet", "sk_lock-AF_NETBEUI" , "sk_lock-AF_SECURITY" , 216 - "sk_lock-AF_KEY" , "sk_lock-AF_NETLINK" , "sk_lock-AF_PACKET" , 217 - "sk_lock-AF_ASH" , "sk_lock-AF_ECONET" , "sk_lock-AF_ATMSVC" , 218 - "sk_lock-AF_RDS" , "sk_lock-AF_SNA" , "sk_lock-AF_IRDA" , 219 - "sk_lock-AF_PPPOX" , "sk_lock-AF_WANPIPE" , "sk_lock-AF_LLC" , 220 - "sk_lock-27" , "sk_lock-28" , "sk_lock-AF_CAN" , 221 - "sk_lock-AF_TIPC" , "sk_lock-AF_BLUETOOTH", "sk_lock-IUCV" , 222 - "sk_lock-AF_RXRPC" , "sk_lock-AF_ISDN" , "sk_lock-AF_PHONET" , 223 - "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" , "sk_lock-AF_ALG" , 224 - "sk_lock-AF_NFC" , "sk_lock-AF_VSOCK" , "sk_lock-AF_KCM" , 225 - "sk_lock-AF_QIPCRTR", "sk_lock-AF_SMC" , "sk_lock-AF_MAX" 232 + _sock_locks("sk_lock-") 226 233 }; 227 234 static const char *const af_family_slock_key_strings[AF_MAX+1] = { 228 - "slock-AF_UNSPEC", "slock-AF_UNIX" , "slock-AF_INET" , 229 - "slock-AF_AX25" , "slock-AF_IPX" , "slock-AF_APPLETALK", 230 - "slock-AF_NETROM", "slock-AF_BRIDGE" , "slock-AF_ATMPVC" , 231 - "slock-AF_X25" , "slock-AF_INET6" , "slock-AF_ROSE" , 232 - "slock-AF_DECnet", "slock-AF_NETBEUI" , "slock-AF_SECURITY" , 233 - "slock-AF_KEY" , "slock-AF_NETLINK" , "slock-AF_PACKET" , 234 - "slock-AF_ASH" , "slock-AF_ECONET" , "slock-AF_ATMSVC" , 235 - "slock-AF_RDS" , "slock-AF_SNA" , "slock-AF_IRDA" , 236 - "slock-AF_PPPOX" , "slock-AF_WANPIPE" , "slock-AF_LLC" , 237 - "slock-27" , "slock-28" , "slock-AF_CAN" , 238 - "slock-AF_TIPC" , "slock-AF_BLUETOOTH", "slock-AF_IUCV" , 239 - "slock-AF_RXRPC" , "slock-AF_ISDN" , "slock-AF_PHONET" , 240 - "slock-AF_IEEE802154", "slock-AF_CAIF" , "slock-AF_ALG" , 241 - "slock-AF_NFC" , "slock-AF_VSOCK" ,"slock-AF_KCM" , 242 - "slock-AF_QIPCRTR", "slock-AF_SMC" , "slock-AF_MAX" 235 + _sock_locks("slock-") 243 236 }; 244 237 static const char *const af_family_clock_key_strings[AF_MAX+1] = { 245 - "clock-AF_UNSPEC", "clock-AF_UNIX" , "clock-AF_INET" , 246 - "clock-AF_AX25" , "clock-AF_IPX" , "clock-AF_APPLETALK", 247 - "clock-AF_NETROM", "clock-AF_BRIDGE" , "clock-AF_ATMPVC" , 248 - "clock-AF_X25" , "clock-AF_INET6" , "clock-AF_ROSE" , 249 - "clock-AF_DECnet", "clock-AF_NETBEUI" , "clock-AF_SECURITY" , 250 - "clock-AF_KEY" , "clock-AF_NETLINK" , "clock-AF_PACKET" , 251 - "clock-AF_ASH" , "clock-AF_ECONET" , "clock-AF_ATMSVC" , 252 - "clock-AF_RDS" , "clock-AF_SNA" , "clock-AF_IRDA" , 253 - "clock-AF_PPPOX" , "clock-AF_WANPIPE" , "clock-AF_LLC" , 254 - "clock-27" , "clock-28" , "clock-AF_CAN" , 255 - "clock-AF_TIPC" , "clock-AF_BLUETOOTH", "clock-AF_IUCV" , 256 - "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , 257 - "clock-AF_IEEE802154", "clock-AF_CAIF" , "clock-AF_ALG" , 258 - "clock-AF_NFC" , "clock-AF_VSOCK" , "clock-AF_KCM" , 259 - "clock-AF_QIPCRTR", "clock-AF_SMC" , "clock-AF_MAX" 238 + _sock_locks("clock-") 239 + }; 240 + 241 + static const char *const af_family_kern_key_strings[AF_MAX+1] = { 242 + _sock_locks("k-sk_lock-") 243 + }; 244 + static const char *const af_family_kern_slock_key_strings[AF_MAX+1] = { 245 + _sock_locks("k-slock-") 246 + }; 247 + static const char *const af_family_kern_clock_key_strings[AF_MAX+1] = { 248 + _sock_locks("k-clock-") 260 249 }; 261 250 262 251 /* ··· 253 264 * so split the lock classes by using a per-AF key: 254 265 */ 255 266 static struct lock_class_key af_callback_keys[AF_MAX]; 267 + static struct lock_class_key af_kern_callback_keys[AF_MAX]; 256 268 257 269 /* Take into consideration the size of the struct sk_buff overhead in the 258 270 * determination of these values, since that is non-constant across ··· 1283 1293 */ 1284 1294 static inline void sock_lock_init(struct sock *sk) 1285 1295 { 1286 - sock_lock_init_class_and_name(sk, 1296 + if (sk->sk_kern_sock) 1297 + sock_lock_init_class_and_name( 1298 + sk, 1299 + af_family_kern_slock_key_strings[sk->sk_family], 1300 + af_family_kern_slock_keys + sk->sk_family, 1301 + af_family_kern_key_strings[sk->sk_family], 1302 + af_family_kern_keys + sk->sk_family); 1303 + else 1304 + sock_lock_init_class_and_name( 1305 + sk, 1287 1306 af_family_slock_key_strings[sk->sk_family], 1288 1307 af_family_slock_keys + sk->sk_family, 1289 1308 af_family_key_strings[sk->sk_family], ··· 1398 1399 * why we need sk_prot_creator -acme 1399 1400 */ 1400 1401 sk->sk_prot = sk->sk_prot_creator = prot; 1402 + sk->sk_kern_sock = kern; 1401 1403 sock_lock_init(sk); 1402 1404 sk->sk_net_refcnt = kern ? 0 : 1; 1403 1405 if (likely(sk->sk_net_refcnt)) ··· 2277 2277 } 2278 2278 EXPORT_SYMBOL(sock_no_socketpair); 2279 2279 2280 - int sock_no_accept(struct socket *sock, struct socket *newsock, int flags) 2280 + int sock_no_accept(struct socket *sock, struct socket *newsock, int flags, 2281 + bool kern) 2281 2282 { 2282 2283 return -EOPNOTSUPP; 2283 2284 } ··· 2482 2481 } 2483 2482 2484 2483 rwlock_init(&sk->sk_callback_lock); 2485 - lockdep_set_class_and_name(&sk->sk_callback_lock, 2484 + if (sk->sk_kern_sock) 2485 + lockdep_set_class_and_name( 2486 + &sk->sk_callback_lock, 2487 + af_kern_callback_keys + sk->sk_family, 2488 + af_family_kern_clock_key_strings[sk->sk_family]); 2489 + else 2490 + lockdep_set_class_and_name( 2491 + &sk->sk_callback_lock, 2486 2492 af_callback_keys + sk->sk_family, 2487 2493 af_family_clock_key_strings[sk->sk_family]); 2488 2494
+1
net/dccp/ccids/ccid2.c
··· 749 749 for (i = 0; i < hc->tx_seqbufc; i++) 750 750 kfree(hc->tx_seqbuf[i]); 751 751 hc->tx_seqbufc = 0; 752 + dccp_ackvec_parsed_cleanup(&hc->tx_av_chunks); 752 753 } 753 754 754 755 static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
+2 -1
net/dccp/ipv4.c
··· 289 289 290 290 switch (type) { 291 291 case ICMP_REDIRECT: 292 - dccp_do_redirect(skb, sk); 292 + if (!sock_owned_by_user(sk)) 293 + dccp_do_redirect(skb, sk); 293 294 goto out; 294 295 case ICMP_SOURCE_QUENCH: 295 296 /* Just silently ignore these. */
+5 -3
net/dccp/ipv6.c
··· 122 122 np = inet6_sk(sk); 123 123 124 124 if (type == NDISC_REDIRECT) { 125 - struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie); 125 + if (!sock_owned_by_user(sk)) { 126 + struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie); 126 127 127 - if (dst) 128 - dst->ops->redirect(dst, sk, skb); 128 + if (dst) 129 + dst->ops->redirect(dst, sk, skb); 130 + } 129 131 goto out; 130 132 } 131 133
+16 -8
net/dccp/minisocks.c
··· 142 142 struct dccp_request_sock *dreq = dccp_rsk(req); 143 143 bool own_req; 144 144 145 + /* TCP/DCCP listeners became lockless. 146 + * DCCP stores complex state in its request_sock, so we need 147 + * a protection for them, now this code runs without being protected 148 + * by the parent (listener) lock. 149 + */ 150 + spin_lock_bh(&dreq->dreq_lock); 151 + 145 152 /* Check for retransmitted REQUEST */ 146 153 if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) { 147 154 ··· 163 156 inet_rtx_syn_ack(sk, req); 164 157 } 165 158 /* Network Duplicate, discard packet */ 166 - return NULL; 159 + goto out; 167 160 } 168 161 169 162 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_PACKET_ERROR; ··· 189 182 190 183 child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL, 191 184 req, &own_req); 192 - if (!child) 193 - goto listen_overflow; 185 + if (child) { 186 + child = inet_csk_complete_hashdance(sk, child, req, own_req); 187 + goto out; 188 + } 194 189 195 - return inet_csk_complete_hashdance(sk, child, req, own_req); 196 - 197 - listen_overflow: 198 - dccp_pr_debug("listen_overflow!\n"); 199 190 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY; 200 191 drop: 201 192 if (dccp_hdr(skb)->dccph_type != DCCP_PKT_RESET) 202 193 req->rsk_ops->send_reset(sk, skb); 203 194 204 195 inet_csk_reqsk_queue_drop(sk, req); 205 - return NULL; 196 + out: 197 + spin_unlock_bh(&dreq->dreq_lock); 198 + return child; 206 199 } 207 200 208 201 EXPORT_SYMBOL_GPL(dccp_check_req); ··· 253 246 { 254 247 struct dccp_request_sock *dreq = dccp_rsk(req); 255 248 249 + spin_lock_init(&dreq->dreq_lock); 256 250 inet_rsk(req)->ir_rmt_port = dccp_hdr(skb)->dccph_sport; 257 251 inet_rsk(req)->ir_num = ntohs(dccp_hdr(skb)->dccph_dport); 258 252 inet_rsk(req)->acked = 0;
+3 -2
net/decnet/af_decnet.c
··· 1070 1070 return skb == NULL ? ERR_PTR(err) : skb; 1071 1071 } 1072 1072 1073 - static int dn_accept(struct socket *sock, struct socket *newsock, int flags) 1073 + static int dn_accept(struct socket *sock, struct socket *newsock, int flags, 1074 + bool kern) 1074 1075 { 1075 1076 struct sock *sk = sock->sk, *newsk; 1076 1077 struct sk_buff *skb = NULL; ··· 1100 1099 1101 1100 cb = DN_SKB_CB(skb); 1102 1101 sk->sk_ack_backlog--; 1103 - newsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, 0); 1102 + newsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, kern); 1104 1103 if (newsk == NULL) { 1105 1104 release_sock(sk); 1106 1105 kfree_skb(skb);
+6 -3
net/ipv4/af_inet.c
··· 689 689 * Accept a pending connection. The TCP layer now gives BSD semantics. 690 690 */ 691 691 692 - int inet_accept(struct socket *sock, struct socket *newsock, int flags) 692 + int inet_accept(struct socket *sock, struct socket *newsock, int flags, 693 + bool kern) 693 694 { 694 695 struct sock *sk1 = sock->sk; 695 696 int err = -EINVAL; 696 - struct sock *sk2 = sk1->sk_prot->accept(sk1, flags, &err); 697 + struct sock *sk2 = sk1->sk_prot->accept(sk1, flags, &err, kern); 697 698 698 699 if (!sk2) 699 700 goto do_err; ··· 1488 1487 int proto = iph->protocol; 1489 1488 int err = -ENOSYS; 1490 1489 1491 - if (skb->encapsulation) 1490 + if (skb->encapsulation) { 1491 + skb_set_inner_protocol(skb, cpu_to_be16(ETH_P_IP)); 1492 1492 skb_set_inner_network_header(skb, nhoff); 1493 + } 1493 1494 1494 1495 csum_replace2(&iph->check, iph->tot_len, newlen); 1495 1496 iph->tot_len = newlen;
+1 -1
net/ipv4/inet_connection_sock.c
··· 424 424 /* 425 425 * This will accept the next outstanding connection. 426 426 */ 427 - struct sock *inet_csk_accept(struct sock *sk, int flags, int *err) 427 + struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern) 428 428 { 429 429 struct inet_connection_sock *icsk = inet_csk(sk); 430 430 struct request_sock_queue *queue = &icsk->icsk_accept_queue;
+1 -1
net/ipv4/ip_output.c
··· 966 966 cork->length += length; 967 967 if ((((length + fragheaderlen) > mtu) || (skb && skb_is_gso(skb))) && 968 968 (sk->sk_protocol == IPPROTO_UDP) && 969 - (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len && 969 + (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) && 970 970 (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx) { 971 971 err = ip_ufo_append_data(sk, queue, getfrag, from, length, 972 972 hh_len, fragheaderlen, transhdrlen,
+7 -3
net/ipv4/tcp_ipv4.c
··· 279 279 */ 280 280 void tcp_v4_mtu_reduced(struct sock *sk) 281 281 { 282 - struct dst_entry *dst; 283 282 struct inet_sock *inet = inet_sk(sk); 284 - u32 mtu = tcp_sk(sk)->mtu_info; 283 + struct dst_entry *dst; 284 + u32 mtu; 285 285 286 + if ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) 287 + return; 288 + mtu = tcp_sk(sk)->mtu_info; 286 289 dst = inet_csk_update_pmtu(sk, mtu); 287 290 if (!dst) 288 291 return; ··· 431 428 432 429 switch (type) { 433 430 case ICMP_REDIRECT: 434 - do_redirect(icmp_skb, sk); 431 + if (!sock_owned_by_user(sk)) 432 + do_redirect(icmp_skb, sk); 435 433 goto out; 436 434 case ICMP_SOURCE_QUENCH: 437 435 /* Just silently ignore these. */
+4 -2
net/ipv4/tcp_timer.c
··· 249 249 250 250 sk_mem_reclaim_partial(sk); 251 251 252 - if (sk->sk_state == TCP_CLOSE || !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) 252 + if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) || 253 + !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) 253 254 goto out; 254 255 255 256 if (time_after(icsk->icsk_ack.timeout, jiffies)) { ··· 553 552 struct inet_connection_sock *icsk = inet_csk(sk); 554 553 int event; 555 554 556 - if (sk->sk_state == TCP_CLOSE || !icsk->icsk_pending) 555 + if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) || 556 + !icsk->icsk_pending) 557 557 goto out; 558 558 559 559 if (time_after(icsk->icsk_timeout, jiffies)) {
+5 -5
net/ipv6/af_inet6.c
··· 920 920 err = register_pernet_subsys(&inet6_net_ops); 921 921 if (err) 922 922 goto register_pernet_fail; 923 - err = icmpv6_init(); 924 - if (err) 925 - goto icmp_fail; 926 923 err = ip6_mr_init(); 927 924 if (err) 928 925 goto ipmr_fail; 926 + err = icmpv6_init(); 927 + if (err) 928 + goto icmp_fail; 929 929 err = ndisc_init(); 930 930 if (err) 931 931 goto ndisc_fail; ··· 1061 1061 ndisc_cleanup(); 1062 1062 ndisc_fail: 1063 1063 ip6_mr_cleanup(); 1064 - ipmr_fail: 1065 - icmpv6_cleanup(); 1066 1064 icmp_fail: 1067 1065 unregister_pernet_subsys(&inet6_net_ops); 1066 + ipmr_fail: 1067 + icmpv6_cleanup(); 1068 1068 register_pernet_fail: 1069 1069 sock_unregister(PF_INET6); 1070 1070 rtnl_unregister_all(PF_INET6);
+2
net/ipv6/ip6_fib.c
··· 923 923 ins = &rt->dst.rt6_next; 924 924 iter = *ins; 925 925 while (iter) { 926 + if (iter->rt6i_metric > rt->rt6i_metric) 927 + break; 926 928 if (rt6_qualify_for_ecmp(iter)) { 927 929 *ins = iter->dst.rt6_next; 928 930 fib6_purge_rt(iter, fn, info->nl_net);
+3 -1
net/ipv6/ip6_offload.c
··· 294 294 struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + nhoff); 295 295 int err = -ENOSYS; 296 296 297 - if (skb->encapsulation) 297 + if (skb->encapsulation) { 298 + skb_set_inner_protocol(skb, cpu_to_be16(ETH_P_IPV6)); 298 299 skb_set_inner_network_header(skb, nhoff); 300 + } 299 301 300 302 iph->payload_len = htons(skb->len - nhoff - sizeof(*iph)); 301 303
+7 -2
net/ipv6/ip6_output.c
··· 768 768 * Fragment the datagram. 769 769 */ 770 770 771 - *prevhdr = NEXTHDR_FRAGMENT; 772 771 troom = rt->dst.dev->needed_tailroom; 773 772 774 773 /* 775 774 * Keep copying data until we run out. 776 775 */ 777 776 while (left > 0) { 777 + u8 *fragnexthdr_offset; 778 + 778 779 len = left; 779 780 /* IF: it doesn't fit, use 'mtu' - the data space left */ 780 781 if (len > mtu) ··· 819 818 * Copy the packet header into the new buffer. 820 819 */ 821 820 skb_copy_from_linear_data(skb, skb_network_header(frag), hlen); 821 + 822 + fragnexthdr_offset = skb_network_header(frag); 823 + fragnexthdr_offset += prevhdr - skb_network_header(skb); 824 + *fragnexthdr_offset = NEXTHDR_FRAGMENT; 822 825 823 826 /* 824 827 * Build fragment header. ··· 1390 1385 if ((((length + fragheaderlen) > mtu) || 1391 1386 (skb && skb_is_gso(skb))) && 1392 1387 (sk->sk_protocol == IPPROTO_UDP) && 1393 - (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len && 1388 + (rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) && 1394 1389 (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) { 1395 1390 err = ip6_ufo_append_data(sk, queue, getfrag, from, length, 1396 1391 hh_len, fragheaderlen, exthdrlen,
+6 -2
net/ipv6/ip6_vti.c
··· 485 485 if (!skb->ignore_df && skb->len > mtu) { 486 486 skb_dst(skb)->ops->update_pmtu(dst, NULL, skb, mtu); 487 487 488 - if (skb->protocol == htons(ETH_P_IPV6)) 488 + if (skb->protocol == htons(ETH_P_IPV6)) { 489 + if (mtu < IPV6_MIN_MTU) 490 + mtu = IPV6_MIN_MTU; 491 + 489 492 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); 490 - else 493 + } else { 491 494 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 492 495 htonl(mtu)); 496 + } 493 497 494 498 return -EMSGSIZE; 495 499 }
+6 -5
net/ipv6/route.c
··· 3299 3299 nexthop_len = nla_total_size(0) /* RTA_MULTIPATH */ 3300 3300 + NLA_ALIGN(sizeof(struct rtnexthop)) 3301 3301 + nla_total_size(16) /* RTA_GATEWAY */ 3302 - + nla_total_size(4) /* RTA_OIF */ 3303 3302 + lwtunnel_get_encap_size(rt->dst.lwtstate); 3304 3303 3305 3304 nexthop_len *= rt->rt6i_nsiblings; ··· 3322 3323 } 3323 3324 3324 3325 static int rt6_nexthop_info(struct sk_buff *skb, struct rt6_info *rt, 3325 - unsigned int *flags) 3326 + unsigned int *flags, bool skip_oif) 3326 3327 { 3327 3328 if (!netif_running(rt->dst.dev) || !netif_carrier_ok(rt->dst.dev)) { 3328 3329 *flags |= RTNH_F_LINKDOWN; ··· 3335 3336 goto nla_put_failure; 3336 3337 } 3337 3338 3338 - if (rt->dst.dev && 3339 + /* not needed for multipath encoding b/c it has a rtnexthop struct */ 3340 + if (!skip_oif && rt->dst.dev && 3339 3341 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) 3340 3342 goto nla_put_failure; 3341 3343 ··· 3350 3350 return -EMSGSIZE; 3351 3351 } 3352 3352 3353 + /* add multipath next hop */ 3353 3354 static int rt6_add_nexthop(struct sk_buff *skb, struct rt6_info *rt) 3354 3355 { 3355 3356 struct rtnexthop *rtnh; ··· 3363 3362 rtnh->rtnh_hops = 0; 3364 3363 rtnh->rtnh_ifindex = rt->dst.dev ? rt->dst.dev->ifindex : 0; 3365 3364 3366 - if (rt6_nexthop_info(skb, rt, &flags) < 0) 3365 + if (rt6_nexthop_info(skb, rt, &flags, true) < 0) 3367 3366 goto nla_put_failure; 3368 3367 3369 3368 rtnh->rtnh_flags = flags; ··· 3516 3515 3517 3516 nla_nest_end(skb, mp); 3518 3517 } else { 3519 - if (rt6_nexthop_info(skb, rt, &rtm->rtm_flags) < 0) 3518 + if (rt6_nexthop_info(skb, rt, &rtm->rtm_flags, false) < 0) 3520 3519 goto nla_put_failure; 3521 3520 } 3522 3521
+5 -3
net/ipv6/tcp_ipv6.c
··· 391 391 np = inet6_sk(sk); 392 392 393 393 if (type == NDISC_REDIRECT) { 394 - struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie); 394 + if (!sock_owned_by_user(sk)) { 395 + struct dst_entry *dst = __sk_dst_check(sk, np->dst_cookie); 395 396 396 - if (dst) 397 - dst->ops->redirect(dst, sk, skb); 397 + if (dst) 398 + dst->ops->redirect(dst, sk, skb); 399 + } 398 400 goto out; 399 401 } 400 402
+3 -2
net/irda/af_irda.c
··· 828 828 * Wait for incoming connection 829 829 * 830 830 */ 831 - static int irda_accept(struct socket *sock, struct socket *newsock, int flags) 831 + static int irda_accept(struct socket *sock, struct socket *newsock, int flags, 832 + bool kern) 832 833 { 833 834 struct sock *sk = sock->sk; 834 835 struct irda_sock *new, *self = irda_sk(sk); ··· 837 836 struct sk_buff *skb = NULL; 838 837 int err; 839 838 840 - err = irda_create(sock_net(sk), newsock, sk->sk_protocol, 0); 839 + err = irda_create(sock_net(sk), newsock, sk->sk_protocol, kern); 841 840 if (err) 842 841 return err; 843 842
+1 -1
net/iucv/af_iucv.c
··· 938 938 939 939 /* Accept a pending connection */ 940 940 static int iucv_sock_accept(struct socket *sock, struct socket *newsock, 941 - int flags) 941 + int flags, bool kern) 942 942 { 943 943 DECLARE_WAITQUEUE(wait, current); 944 944 struct sock *sk = sock->sk, *nsk;
+3 -1
net/llc/af_llc.c
··· 641 641 * @sock: Socket which connections arrive on. 642 642 * @newsock: Socket to move incoming connection to. 643 643 * @flags: User specified operational flags. 644 + * @kern: If the socket is kernel internal 644 645 * 645 646 * Accept a new incoming connection. 646 647 * Returns 0 upon success, negative otherwise. 647 648 */ 648 - static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags) 649 + static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags, 650 + bool kern) 649 651 { 650 652 struct sock *sk = sock->sk, *newsk; 651 653 struct llc_sock *llc, *newllc;
+3 -1
net/mpls/af_mpls.c
··· 1288 1288 /* fall through */ 1289 1289 case NETDEV_CHANGE: 1290 1290 nh->nh_flags |= RTNH_F_LINKDOWN; 1291 - ACCESS_ONCE(rt->rt_nhn_alive) = rt->rt_nhn_alive - 1; 1291 + if (event != NETDEV_UNREGISTER) 1292 + ACCESS_ONCE(rt->rt_nhn_alive) = rt->rt_nhn_alive - 1; 1292 1293 break; 1293 1294 } 1294 1295 if (event == NETDEV_UNREGISTER) ··· 2029 2028 for (index = 0; index < platform_labels; index++) { 2030 2029 struct mpls_route *rt = rtnl_dereference(platform_label[index]); 2031 2030 RCU_INIT_POINTER(platform_label[index], NULL); 2031 + mpls_notify_route(net, index, rt, NULL, NULL); 2032 2032 mpls_rt_free(rt); 2033 2033 } 2034 2034 rtnl_unlock();
+2 -1
net/netrom/af_netrom.c
··· 765 765 return err; 766 766 } 767 767 768 - static int nr_accept(struct socket *sock, struct socket *newsock, int flags) 768 + static int nr_accept(struct socket *sock, struct socket *newsock, int flags, 769 + bool kern) 769 770 { 770 771 struct sk_buff *skb; 771 772 struct sock *newsk;
+1 -1
net/nfc/llcp_sock.c
··· 441 441 } 442 442 443 443 static int llcp_sock_accept(struct socket *sock, struct socket *newsock, 444 - int flags) 444 + int flags, bool kern) 445 445 { 446 446 DECLARE_WAITQUEUE(wait, current); 447 447 struct sock *sk = sock->sk, *new_sk;
+4 -2
net/phonet/pep.c
··· 772 772 sock_put(sk); 773 773 } 774 774 775 - static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp) 775 + static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp, 776 + bool kern) 776 777 { 777 778 struct pep_sock *pn = pep_sk(sk), *newpn; 778 779 struct sock *newsk = NULL; ··· 847 846 } 848 847 849 848 /* Create a new to-be-accepted sock */ 850 - newsk = sk_alloc(sock_net(sk), PF_PHONET, GFP_KERNEL, sk->sk_prot, 0); 849 + newsk = sk_alloc(sock_net(sk), PF_PHONET, GFP_KERNEL, sk->sk_prot, 850 + kern); 851 851 if (!newsk) { 852 852 pep_reject_conn(sk, skb, PN_PIPE_ERR_OVERLOAD, GFP_KERNEL); 853 853 err = -ENOBUFS;
+2 -2
net/phonet/socket.c
··· 305 305 } 306 306 307 307 static int pn_socket_accept(struct socket *sock, struct socket *newsock, 308 - int flags) 308 + int flags, bool kern) 309 309 { 310 310 struct sock *sk = sock->sk; 311 311 struct sock *newsk; ··· 314 314 if (unlikely(sk->sk_state != TCP_LISTEN)) 315 315 return -EINVAL; 316 316 317 - newsk = sk->sk_prot->accept(sk, flags, &err); 317 + newsk = sk->sk_prot->accept(sk, flags, &err, kern); 318 318 if (!newsk) 319 319 return err; 320 320
+1
net/rds/connection.c
··· 429 429 */ 430 430 rds_cong_remove_conn(conn); 431 431 432 + put_net(conn->c_net); 432 433 kmem_cache_free(rds_conn_slab, conn); 433 434 434 435 spin_lock_irqsave(&rds_conn_lock, flags);
+36 -11
net/rds/ib_cm.c
··· 442 442 ic->i_send_cq = NULL; 443 443 ibdev_put_vector(rds_ibdev, ic->i_scq_vector); 444 444 rdsdebug("ib_create_cq send failed: %d\n", ret); 445 - goto out; 445 + goto rds_ibdev_out; 446 446 } 447 447 448 448 ic->i_rcq_vector = ibdev_get_unused_vector(rds_ibdev); ··· 456 456 ic->i_recv_cq = NULL; 457 457 ibdev_put_vector(rds_ibdev, ic->i_rcq_vector); 458 458 rdsdebug("ib_create_cq recv failed: %d\n", ret); 459 - goto out; 459 + goto send_cq_out; 460 460 } 461 461 462 462 ret = ib_req_notify_cq(ic->i_send_cq, IB_CQ_NEXT_COMP); 463 463 if (ret) { 464 464 rdsdebug("ib_req_notify_cq send failed: %d\n", ret); 465 - goto out; 465 + goto recv_cq_out; 466 466 } 467 467 468 468 ret = ib_req_notify_cq(ic->i_recv_cq, IB_CQ_SOLICITED); 469 469 if (ret) { 470 470 rdsdebug("ib_req_notify_cq recv failed: %d\n", ret); 471 - goto out; 471 + goto recv_cq_out; 472 472 } 473 473 474 474 /* XXX negotiate max send/recv with remote? */ ··· 494 494 ret = rdma_create_qp(ic->i_cm_id, ic->i_pd, &attr); 495 495 if (ret) { 496 496 rdsdebug("rdma_create_qp failed: %d\n", ret); 497 - goto out; 497 + goto recv_cq_out; 498 498 } 499 499 500 500 ic->i_send_hdrs = ib_dma_alloc_coherent(dev, ··· 504 504 if (!ic->i_send_hdrs) { 505 505 ret = -ENOMEM; 506 506 rdsdebug("ib_dma_alloc_coherent send failed\n"); 507 - goto out; 507 + goto qp_out; 508 508 } 509 509 510 510 ic->i_recv_hdrs = ib_dma_alloc_coherent(dev, ··· 514 514 if (!ic->i_recv_hdrs) { 515 515 ret = -ENOMEM; 516 516 rdsdebug("ib_dma_alloc_coherent recv failed\n"); 517 - goto out; 517 + goto send_hdrs_dma_out; 518 518 } 519 519 520 520 ic->i_ack = ib_dma_alloc_coherent(dev, sizeof(struct rds_header), ··· 522 522 if (!ic->i_ack) { 523 523 ret = -ENOMEM; 524 524 rdsdebug("ib_dma_alloc_coherent ack failed\n"); 525 - goto out; 525 + goto recv_hdrs_dma_out; 526 526 } 527 527 528 528 ic->i_sends = vzalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work), ··· 530 530 if (!ic->i_sends) { 531 531 ret = -ENOMEM; 532 532 rdsdebug("send allocation failed\n"); 533 - goto out; 533 + goto ack_dma_out; 534 534 } 535 535 536 536 ic->i_recvs = vzalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work), ··· 538 538 if (!ic->i_recvs) { 539 539 ret = -ENOMEM; 540 540 rdsdebug("recv allocation failed\n"); 541 - goto out; 541 + goto sends_out; 542 542 } 543 543 544 544 rds_ib_recv_init_ack(ic); ··· 546 546 rdsdebug("conn %p pd %p cq %p %p\n", conn, ic->i_pd, 547 547 ic->i_send_cq, ic->i_recv_cq); 548 548 549 - out: 549 + return ret; 550 + 551 + sends_out: 552 + vfree(ic->i_sends); 553 + ack_dma_out: 554 + ib_dma_free_coherent(dev, sizeof(struct rds_header), 555 + ic->i_ack, ic->i_ack_dma); 556 + recv_hdrs_dma_out: 557 + ib_dma_free_coherent(dev, ic->i_recv_ring.w_nr * 558 + sizeof(struct rds_header), 559 + ic->i_recv_hdrs, ic->i_recv_hdrs_dma); 560 + send_hdrs_dma_out: 561 + ib_dma_free_coherent(dev, ic->i_send_ring.w_nr * 562 + sizeof(struct rds_header), 563 + ic->i_send_hdrs, ic->i_send_hdrs_dma); 564 + qp_out: 565 + rdma_destroy_qp(ic->i_cm_id); 566 + recv_cq_out: 567 + if (!ib_destroy_cq(ic->i_recv_cq)) 568 + ic->i_recv_cq = NULL; 569 + send_cq_out: 570 + if (!ib_destroy_cq(ic->i_send_cq)) 571 + ic->i_send_cq = NULL; 572 + rds_ibdev_out: 573 + rds_ib_remove_conn(rds_ibdev, conn); 550 574 rds_ib_dev_put(rds_ibdev); 575 + 551 576 return ret; 552 577 } 553 578
+3 -3
net/rds/rds.h
··· 147 147 148 148 /* Protocol version */ 149 149 unsigned int c_version; 150 - possible_net_t c_net; 150 + struct net *c_net; 151 151 152 152 struct list_head c_map_item; 153 153 unsigned long c_map_queued; ··· 162 162 static inline 163 163 struct net *rds_conn_net(struct rds_connection *conn) 164 164 { 165 - return read_pnet(&conn->c_net); 165 + return conn->c_net; 166 166 } 167 167 168 168 static inline 169 169 void rds_conn_net_set(struct rds_connection *conn, struct net *net) 170 170 { 171 - write_pnet(&conn->c_net, net); 171 + conn->c_net = get_net(net); 172 172 } 173 173 174 174 #define RDS_FLAG_CONG_BITMAP 0x01
+21 -17
net/rds/tcp.c
··· 484 484 * we do need to clean up the listen socket here. 485 485 */ 486 486 if (rtn->rds_tcp_listen_sock) { 487 - rds_tcp_listen_stop(rtn->rds_tcp_listen_sock); 487 + struct socket *lsock = rtn->rds_tcp_listen_sock; 488 + 488 489 rtn->rds_tcp_listen_sock = NULL; 489 - flush_work(&rtn->rds_tcp_accept_w); 490 + rds_tcp_listen_stop(lsock, &rtn->rds_tcp_accept_w); 490 491 } 491 492 } 492 493 ··· 524 523 struct rds_tcp_connection *tc, *_tc; 525 524 LIST_HEAD(tmp_list); 526 525 struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid); 526 + struct socket *lsock = rtn->rds_tcp_listen_sock; 527 527 528 - rds_tcp_listen_stop(rtn->rds_tcp_listen_sock); 529 528 rtn->rds_tcp_listen_sock = NULL; 530 - flush_work(&rtn->rds_tcp_accept_w); 529 + rds_tcp_listen_stop(lsock, &rtn->rds_tcp_accept_w); 531 530 spin_lock_irq(&rds_tcp_conn_lock); 532 531 list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) { 533 - struct net *c_net = read_pnet(&tc->t_cpath->cp_conn->c_net); 532 + struct net *c_net = tc->t_cpath->cp_conn->c_net; 534 533 535 534 if (net != c_net || !tc->t_sock) 536 535 continue; ··· 547 546 void *rds_tcp_listen_sock_def_readable(struct net *net) 548 547 { 549 548 struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid); 549 + struct socket *lsock = rtn->rds_tcp_listen_sock; 550 550 551 - return rtn->rds_tcp_listen_sock->sk->sk_user_data; 551 + if (!lsock) 552 + return NULL; 553 + 554 + return lsock->sk->sk_user_data; 552 555 } 553 556 554 557 static int rds_tcp_dev_event(struct notifier_block *this, ··· 589 584 590 585 spin_lock_irq(&rds_tcp_conn_lock); 591 586 list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) { 592 - struct net *c_net = read_pnet(&tc->t_cpath->cp_conn->c_net); 587 + struct net *c_net = tc->t_cpath->cp_conn->c_net; 593 588 594 589 if (net != c_net || !tc->t_sock) 595 590 continue; ··· 643 638 goto out; 644 639 } 645 640 646 - ret = register_netdevice_notifier(&rds_tcp_dev_notifier); 647 - if (ret) { 648 - pr_warn("could not register rds_tcp_dev_notifier\n"); 641 + ret = rds_tcp_recv_init(); 642 + if (ret) 649 643 goto out_slab; 650 - } 651 644 652 645 ret = register_pernet_subsys(&rds_tcp_net_ops); 653 646 if (ret) 654 - goto out_notifier; 647 + goto out_recv; 655 648 656 - ret = rds_tcp_recv_init(); 657 - if (ret) 649 + ret = register_netdevice_notifier(&rds_tcp_dev_notifier); 650 + if (ret) { 651 + pr_warn("could not register rds_tcp_dev_notifier\n"); 658 652 goto out_pernet; 653 + } 659 654 660 655 rds_trans_register(&rds_tcp_transport); 661 656 ··· 665 660 666 661 out_pernet: 667 662 unregister_pernet_subsys(&rds_tcp_net_ops); 668 - out_notifier: 669 - if (unregister_netdevice_notifier(&rds_tcp_dev_notifier)) 670 - pr_warn("could not unregister rds_tcp_dev_notifier\n"); 663 + out_recv: 664 + rds_tcp_recv_exit(); 671 665 out_slab: 672 666 kmem_cache_destroy(rds_tcp_conn_slab); 673 667 out:
+1 -1
net/rds/tcp.h
··· 66 66 67 67 /* tcp_listen.c */ 68 68 struct socket *rds_tcp_listen_init(struct net *); 69 - void rds_tcp_listen_stop(struct socket *); 69 + void rds_tcp_listen_stop(struct socket *sock, struct work_struct *acceptor); 70 70 void rds_tcp_listen_data_ready(struct sock *sk); 71 71 int rds_tcp_accept_one(struct socket *sock); 72 72 int rds_tcp_keepalive(struct socket *sock);
+8 -3
net/rds/tcp_listen.c
··· 133 133 134 134 new_sock->type = sock->type; 135 135 new_sock->ops = sock->ops; 136 - ret = sock->ops->accept(sock, new_sock, O_NONBLOCK); 136 + ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, true); 137 137 if (ret < 0) 138 138 goto out; 139 139 ··· 223 223 * before it has been accepted and the accepter has set up their 224 224 * data_ready.. we only want to queue listen work for our listening 225 225 * socket 226 + * 227 + * (*ready)() may be null if we are racing with netns delete, and 228 + * the listen socket is being torn down. 226 229 */ 227 230 if (sk->sk_state == TCP_LISTEN) 228 231 rds_tcp_accept_work(sk); ··· 234 231 235 232 out: 236 233 read_unlock_bh(&sk->sk_callback_lock); 237 - ready(sk); 234 + if (ready) 235 + ready(sk); 238 236 } 239 237 240 238 struct socket *rds_tcp_listen_init(struct net *net) ··· 275 271 return NULL; 276 272 } 277 273 278 - void rds_tcp_listen_stop(struct socket *sock) 274 + void rds_tcp_listen_stop(struct socket *sock, struct work_struct *acceptor) 279 275 { 280 276 struct sock *sk; 281 277 ··· 296 292 297 293 /* wait for accepts to stop and close the socket */ 298 294 flush_workqueue(rds_wq); 295 + flush_work(acceptor); 299 296 sock_release(sock); 300 297 }
+2 -1
net/rose/af_rose.c
··· 871 871 return err; 872 872 } 873 873 874 - static int rose_accept(struct socket *sock, struct socket *newsock, int flags) 874 + static int rose_accept(struct socket *sock, struct socket *newsock, int flags, 875 + bool kern) 875 876 { 876 877 struct sk_buff *skb; 877 878 struct sock *newsk;
+19 -8
net/rxrpc/input.c
··· 420 420 u16 skew) 421 421 { 422 422 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 423 + enum rxrpc_call_state state; 423 424 unsigned int offset = sizeof(struct rxrpc_wire_header); 424 425 unsigned int ix; 425 426 rxrpc_serial_t serial = sp->hdr.serial, ack_serial = 0; ··· 435 434 _proto("Rx DATA %%%u { #%u f=%02x }", 436 435 sp->hdr.serial, seq, sp->hdr.flags); 437 436 438 - if (call->state >= RXRPC_CALL_COMPLETE) 437 + state = READ_ONCE(call->state); 438 + if (state >= RXRPC_CALL_COMPLETE) 439 439 return; 440 440 441 441 /* Received data implicitly ACKs all of the request packets we sent 442 442 * when we're acting as a client. 443 443 */ 444 - if ((call->state == RXRPC_CALL_CLIENT_SEND_REQUEST || 445 - call->state == RXRPC_CALL_CLIENT_AWAIT_REPLY) && 444 + if ((state == RXRPC_CALL_CLIENT_SEND_REQUEST || 445 + state == RXRPC_CALL_CLIENT_AWAIT_REPLY) && 446 446 !rxrpc_receiving_reply(call)) 447 447 return; 448 448 ··· 652 650 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 653 651 struct rxrpc_peer *peer; 654 652 unsigned int mtu; 653 + bool wake = false; 655 654 u32 rwind = ntohl(ackinfo->rwind); 656 655 657 656 _proto("Rx ACK %%%u Info { rx=%u max=%u rwin=%u jm=%u }", ··· 660 657 ntohl(ackinfo->rxMTU), ntohl(ackinfo->maxMTU), 661 658 rwind, ntohl(ackinfo->jumbo_max)); 662 659 663 - if (rwind > RXRPC_RXTX_BUFF_SIZE - 1) 664 - rwind = RXRPC_RXTX_BUFF_SIZE - 1; 665 - call->tx_winsize = rwind; 660 + if (call->tx_winsize != rwind) { 661 + if (rwind > RXRPC_RXTX_BUFF_SIZE - 1) 662 + rwind = RXRPC_RXTX_BUFF_SIZE - 1; 663 + if (rwind > call->tx_winsize) 664 + wake = true; 665 + call->tx_winsize = rwind; 666 + } 667 + 666 668 if (call->cong_ssthresh > rwind) 667 669 call->cong_ssthresh = rwind; 668 670 ··· 681 673 spin_unlock_bh(&peer->lock); 682 674 _net("Net MTU %u (maxdata %u)", peer->mtu, peer->maxdata); 683 675 } 676 + 677 + if (wake) 678 + wake_up(&call->waitq); 684 679 } 685 680 686 681 /* ··· 810 799 return rxrpc_proto_abort("AK0", call, 0); 811 800 812 801 /* Ignore ACKs unless we are or have just been transmitting. */ 813 - switch (call->state) { 802 + switch (READ_ONCE(call->state)) { 814 803 case RXRPC_CALL_CLIENT_SEND_REQUEST: 815 804 case RXRPC_CALL_CLIENT_AWAIT_REPLY: 816 805 case RXRPC_CALL_SERVER_SEND_REPLY: ··· 951 940 static void rxrpc_input_implicit_end_call(struct rxrpc_connection *conn, 952 941 struct rxrpc_call *call) 953 942 { 954 - switch (call->state) { 943 + switch (READ_ONCE(call->state)) { 955 944 case RXRPC_CALL_SERVER_AWAIT_ACK: 956 945 rxrpc_call_completed(call); 957 946 break;
+2 -2
net/rxrpc/recvmsg.c
··· 527 527 msg->msg_namelen = len; 528 528 } 529 529 530 - switch (call->state) { 530 + switch (READ_ONCE(call->state)) { 531 531 case RXRPC_CALL_SERVER_ACCEPTING: 532 532 ret = rxrpc_recvmsg_new_call(rx, call, msg, flags); 533 533 break; ··· 640 640 641 641 mutex_lock(&call->user_mutex); 642 642 643 - switch (call->state) { 643 + switch (READ_ONCE(call->state)) { 644 644 case RXRPC_CALL_CLIENT_RECV_REPLY: 645 645 case RXRPC_CALL_SERVER_RECV_REQUEST: 646 646 case RXRPC_CALL_SERVER_ACK_REQUEST:
+31 -18
net/rxrpc/sendmsg.c
··· 488 488 int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) 489 489 __releases(&rx->sk.sk_lock.slock) 490 490 { 491 + enum rxrpc_call_state state; 491 492 enum rxrpc_command cmd; 492 493 struct rxrpc_call *call; 493 494 unsigned long user_call_ID = 0; ··· 527 526 return PTR_ERR(call); 528 527 /* ... and we have the call lock. */ 529 528 } else { 530 - ret = -EBUSY; 531 - if (call->state == RXRPC_CALL_UNINITIALISED || 532 - call->state == RXRPC_CALL_CLIENT_AWAIT_CONN || 533 - call->state == RXRPC_CALL_SERVER_PREALLOC || 534 - call->state == RXRPC_CALL_SERVER_SECURING || 535 - call->state == RXRPC_CALL_SERVER_ACCEPTING) 529 + switch (READ_ONCE(call->state)) { 530 + case RXRPC_CALL_UNINITIALISED: 531 + case RXRPC_CALL_CLIENT_AWAIT_CONN: 532 + case RXRPC_CALL_SERVER_PREALLOC: 533 + case RXRPC_CALL_SERVER_SECURING: 534 + case RXRPC_CALL_SERVER_ACCEPTING: 535 + ret = -EBUSY; 536 536 goto error_release_sock; 537 + default: 538 + break; 539 + } 537 540 538 541 ret = mutex_lock_interruptible(&call->user_mutex); 539 542 release_sock(&rx->sk); ··· 547 542 } 548 543 } 549 544 545 + state = READ_ONCE(call->state); 550 546 _debug("CALL %d USR %lx ST %d on CONN %p", 551 - call->debug_id, call->user_call_ID, call->state, call->conn); 547 + call->debug_id, call->user_call_ID, state, call->conn); 552 548 553 - if (call->state >= RXRPC_CALL_COMPLETE) { 549 + if (state >= RXRPC_CALL_COMPLETE) { 554 550 /* it's too late for this call */ 555 551 ret = -ESHUTDOWN; 556 552 } else if (cmd == RXRPC_CMD_SEND_ABORT) { ··· 561 555 } else if (cmd != RXRPC_CMD_SEND_DATA) { 562 556 ret = -EINVAL; 563 557 } else if (rxrpc_is_client_call(call) && 564 - call->state != RXRPC_CALL_CLIENT_SEND_REQUEST) { 558 + state != RXRPC_CALL_CLIENT_SEND_REQUEST) { 565 559 /* request phase complete for this client call */ 566 560 ret = -EPROTO; 567 561 } else if (rxrpc_is_service_call(call) && 568 - call->state != RXRPC_CALL_SERVER_ACK_REQUEST && 569 - call->state != RXRPC_CALL_SERVER_SEND_REPLY) { 562 + state != RXRPC_CALL_SERVER_ACK_REQUEST && 563 + state != RXRPC_CALL_SERVER_SEND_REPLY) { 570 564 /* Reply phase not begun or not complete for service call. */ 571 565 ret = -EPROTO; 572 566 } else { ··· 611 605 _debug("CALL %d USR %lx ST %d on CONN %p", 612 606 call->debug_id, call->user_call_ID, call->state, call->conn); 613 607 614 - if (call->state >= RXRPC_CALL_COMPLETE) { 615 - ret = -ESHUTDOWN; /* it's too late for this call */ 616 - } else if (call->state != RXRPC_CALL_CLIENT_SEND_REQUEST && 617 - call->state != RXRPC_CALL_SERVER_ACK_REQUEST && 618 - call->state != RXRPC_CALL_SERVER_SEND_REPLY) { 619 - ret = -EPROTO; /* request phase complete for this client call */ 620 - } else { 608 + switch (READ_ONCE(call->state)) { 609 + case RXRPC_CALL_CLIENT_SEND_REQUEST: 610 + case RXRPC_CALL_SERVER_ACK_REQUEST: 611 + case RXRPC_CALL_SERVER_SEND_REPLY: 621 612 ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len); 613 + break; 614 + case RXRPC_CALL_COMPLETE: 615 + read_lock_bh(&call->state_lock); 616 + ret = -call->error; 617 + read_unlock_bh(&call->state_lock); 618 + break; 619 + default: 620 + /* Request phase complete for this client call */ 621 + ret = -EPROTO; 622 + break; 622 623 } 623 624 624 625 mutex_unlock(&call->user_mutex);
+3
net/sched/act_connmark.c
··· 113 113 if (ret < 0) 114 114 return ret; 115 115 116 + if (!tb[TCA_CONNMARK_PARMS]) 117 + return -EINVAL; 118 + 116 119 parm = nla_data(tb[TCA_CONNMARK_PARMS]); 117 120 118 121 if (!tcf_hash_check(tn, parm->index, a, bind)) {
-1
net/sched/act_skbmod.c
··· 228 228 229 229 return skb->len; 230 230 nla_put_failure: 231 - rcu_read_unlock(); 232 231 nlmsg_trim(skb, b); 233 232 return -1; 234 233 }
+3 -2
net/sctp/ipv6.c
··· 640 640 641 641 /* Create and initialize a new sk for the socket to be returned by accept(). */ 642 642 static struct sock *sctp_v6_create_accept_sk(struct sock *sk, 643 - struct sctp_association *asoc) 643 + struct sctp_association *asoc, 644 + bool kern) 644 645 { 645 646 struct sock *newsk; 646 647 struct ipv6_pinfo *newnp, *np = inet6_sk(sk); 647 648 struct sctp6_sock *newsctp6sk; 648 649 struct ipv6_txoptions *opt; 649 650 650 - newsk = sk_alloc(sock_net(sk), PF_INET6, GFP_KERNEL, sk->sk_prot, 0); 651 + newsk = sk_alloc(sock_net(sk), PF_INET6, GFP_KERNEL, sk->sk_prot, kern); 651 652 if (!newsk) 652 653 goto out; 653 654
+3 -2
net/sctp/protocol.c
··· 575 575 576 576 /* Create and initialize a new sk for the socket returned by accept(). */ 577 577 static struct sock *sctp_v4_create_accept_sk(struct sock *sk, 578 - struct sctp_association *asoc) 578 + struct sctp_association *asoc, 579 + bool kern) 579 580 { 580 581 struct sock *newsk = sk_alloc(sock_net(sk), PF_INET, GFP_KERNEL, 581 - sk->sk_prot, 0); 582 + sk->sk_prot, kern); 582 583 struct inet_sock *newinet; 583 584 584 585 if (!newsk)
+2 -2
net/sctp/socket.c
··· 4116 4116 * descriptor will be returned from accept() to represent the newly 4117 4117 * formed association. 4118 4118 */ 4119 - static struct sock *sctp_accept(struct sock *sk, int flags, int *err) 4119 + static struct sock *sctp_accept(struct sock *sk, int flags, int *err, bool kern) 4120 4120 { 4121 4121 struct sctp_sock *sp; 4122 4122 struct sctp_endpoint *ep; ··· 4151 4151 */ 4152 4152 asoc = list_entry(ep->asocs.next, struct sctp_association, asocs); 4153 4153 4154 - newsk = sp->pf->create_accept_sk(sk, asoc); 4154 + newsk = sp->pf->create_accept_sk(sk, asoc, kern); 4155 4155 if (!newsk) { 4156 4156 error = -ENOMEM; 4157 4157 goto out;
+1 -1
net/smc/af_smc.c
··· 944 944 } 945 945 946 946 static int smc_accept(struct socket *sock, struct socket *new_sock, 947 - int flags) 947 + int flags, bool kern) 948 948 { 949 949 struct sock *sk = sock->sk, *nsk; 950 950 DECLARE_WAITQUEUE(wait, current);
+3 -2
net/socket.c
··· 1506 1506 if (err) 1507 1507 goto out_fd; 1508 1508 1509 - err = sock->ops->accept(sock, newsock, sock->file->f_flags); 1509 + err = sock->ops->accept(sock, newsock, sock->file->f_flags, false); 1510 1510 if (err < 0) 1511 1511 goto out_fd; 1512 1512 ··· 1731 1731 /* We assume all kernel code knows the size of sockaddr_storage */ 1732 1732 msg.msg_namelen = 0; 1733 1733 msg.msg_iocb = NULL; 1734 + msg.msg_flags = 0; 1734 1735 if (sock->file->f_flags & O_NONBLOCK) 1735 1736 flags |= MSG_DONTWAIT; 1736 1737 err = sock_recvmsg(sock, &msg, flags); ··· 3239 3238 if (err < 0) 3240 3239 goto done; 3241 3240 3242 - err = sock->ops->accept(sock, *newsock, flags); 3241 + err = sock->ops->accept(sock, *newsock, flags, true); 3243 3242 if (err < 0) { 3244 3243 sock_release(*newsock); 3245 3244 *newsock = NULL;
+5 -3
net/tipc/socket.c
··· 115 115 static void tipc_write_space(struct sock *sk); 116 116 static void tipc_sock_destruct(struct sock *sk); 117 117 static int tipc_release(struct socket *sock); 118 - static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags); 118 + static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, 119 + bool kern); 119 120 static void tipc_sk_timeout(unsigned long data); 120 121 static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, 121 122 struct tipc_name_seq const *seq); ··· 2030 2029 * 2031 2030 * Returns 0 on success, errno otherwise 2032 2031 */ 2033 - static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) 2032 + static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, 2033 + bool kern) 2034 2034 { 2035 2035 struct sock *new_sk, *sk = sock->sk; 2036 2036 struct sk_buff *buf; ··· 2053 2051 2054 2052 buf = skb_peek(&sk->sk_receive_queue); 2055 2053 2056 - res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, 0); 2054 + res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, kern); 2057 2055 if (res) 2058 2056 goto exit; 2059 2057 security_sk_clone(sock->sk, new_sock->sk);
+3 -2
net/unix/af_unix.c
··· 636 636 static int unix_stream_connect(struct socket *, struct sockaddr *, 637 637 int addr_len, int flags); 638 638 static int unix_socketpair(struct socket *, struct socket *); 639 - static int unix_accept(struct socket *, struct socket *, int); 639 + static int unix_accept(struct socket *, struct socket *, int, bool); 640 640 static int unix_getname(struct socket *, struct sockaddr *, int *, int); 641 641 static unsigned int unix_poll(struct file *, struct socket *, poll_table *); 642 642 static unsigned int unix_dgram_poll(struct file *, struct socket *, ··· 1402 1402 set_bit(SOCK_PASSSEC, &new->flags); 1403 1403 } 1404 1404 1405 - static int unix_accept(struct socket *sock, struct socket *newsock, int flags) 1405 + static int unix_accept(struct socket *sock, struct socket *newsock, int flags, 1406 + bool kern) 1406 1407 { 1407 1408 struct sock *sk = sock->sk; 1408 1409 struct sock *tsk;
+2 -1
net/vmw_vsock/af_vsock.c
··· 1250 1250 return err; 1251 1251 } 1252 1252 1253 - static int vsock_accept(struct socket *sock, struct socket *newsock, int flags) 1253 + static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, 1254 + bool kern) 1254 1255 { 1255 1256 struct sock *listener; 1256 1257 int err;
+2 -1
net/x25/af_x25.c
··· 852 852 return rc; 853 853 } 854 854 855 - static int x25_accept(struct socket *sock, struct socket *newsock, int flags) 855 + static int x25_accept(struct socket *sock, struct socket *newsock, int flags, 856 + bool kern) 856 857 { 857 858 struct sock *sk = sock->sk; 858 859 struct sock *newsk;
+9 -10
net/xfrm/xfrm_policy.c
··· 1243 1243 } 1244 1244 1245 1245 static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir, 1246 - const struct flowi *fl) 1246 + const struct flowi *fl, u16 family) 1247 1247 { 1248 1248 struct xfrm_policy *pol; 1249 1249 ··· 1251 1251 again: 1252 1252 pol = rcu_dereference(sk->sk_policy[dir]); 1253 1253 if (pol != NULL) { 1254 - bool match = xfrm_selector_match(&pol->selector, fl, 1255 - sk->sk_family); 1254 + bool match = xfrm_selector_match(&pol->selector, fl, family); 1256 1255 int err = 0; 1257 1256 1258 1257 if (match) { ··· 2238 2239 sk = sk_const_to_full_sk(sk); 2239 2240 if (sk && sk->sk_policy[XFRM_POLICY_OUT]) { 2240 2241 num_pols = 1; 2241 - pols[0] = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl); 2242 + pols[0] = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl, family); 2242 2243 err = xfrm_expand_policies(fl, family, pols, 2243 2244 &num_pols, &num_xfrms); 2244 2245 if (err < 0) ··· 2517 2518 pol = NULL; 2518 2519 sk = sk_to_full_sk(sk); 2519 2520 if (sk && sk->sk_policy[dir]) { 2520 - pol = xfrm_sk_policy_lookup(sk, dir, &fl); 2521 + pol = xfrm_sk_policy_lookup(sk, dir, &fl, family); 2521 2522 if (IS_ERR(pol)) { 2522 2523 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); 2523 2524 return 0; ··· 3068 3069 { 3069 3070 int rv; 3070 3071 3072 + /* Initialize the per-net locks here */ 3073 + spin_lock_init(&net->xfrm.xfrm_state_lock); 3074 + spin_lock_init(&net->xfrm.xfrm_policy_lock); 3075 + mutex_init(&net->xfrm.xfrm_cfg_mutex); 3076 + 3071 3077 rv = xfrm_statistics_init(net); 3072 3078 if (rv < 0) 3073 3079 goto out_statistics; ··· 3088 3084 rv = flow_cache_init(net); 3089 3085 if (rv < 0) 3090 3086 goto out; 3091 - 3092 - /* Initialize the per-net locks here */ 3093 - spin_lock_init(&net->xfrm.xfrm_state_lock); 3094 - spin_lock_init(&net->xfrm.xfrm_policy_lock); 3095 - mutex_init(&net->xfrm.xfrm_cfg_mutex); 3096 3087 3097 3088 return 0; 3098 3089
+18
tools/include/uapi/linux/bpf_perf_event.h
··· 1 + /* Copyright (c) 2016 Facebook 2 + * 3 + * This program is free software; you can redistribute it and/or 4 + * modify it under the terms of version 2 of the GNU General Public 5 + * License as published by the Free Software Foundation. 6 + */ 7 + #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__ 8 + #define _UAPI__LINUX_BPF_PERF_EVENT_H__ 9 + 10 + #include <linux/types.h> 11 + #include <linux/ptrace.h> 12 + 13 + struct bpf_perf_event_data { 14 + struct pt_regs regs; 15 + __u64 sample_period; 16 + }; 17 + 18 + #endif /* _UAPI__LINUX_BPF_PERF_EVENT_H__ */
+3 -1
tools/testing/selftests/bpf/Makefile
··· 1 1 LIBDIR := ../../../lib 2 2 BPFOBJ := $(LIBDIR)/bpf/bpf.o 3 3 4 - CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) 4 + CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) $(BPFOBJ) 5 5 6 6 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map 7 7 8 8 TEST_PROGS := test_kmod.sh 9 + 10 + all: $(TEST_GEN_PROGS) 9 11 10 12 .PHONY: all clean force 11 13
+4
tools/testing/selftests/bpf/test_verifier.c
··· 8 8 * License as published by the Free Software Foundation. 9 9 */ 10 10 11 + #include <asm/types.h> 12 + #include <linux/types.h> 11 13 #include <stdint.h> 12 14 #include <stdio.h> 13 15 #include <stdlib.h> ··· 4585 4583 cap_flag_value_t sysadmin = CAP_CLEAR; 4586 4584 const cap_value_t cap_val = CAP_SYS_ADMIN; 4587 4585 4586 + #ifdef CAP_IS_SUPPORTED 4588 4587 if (!CAP_IS_SUPPORTED(CAP_SETFCAP)) { 4589 4588 perror("cap_get_flag"); 4590 4589 return false; 4591 4590 } 4591 + #endif 4592 4592 caps = cap_get_proc(); 4593 4593 if (!caps) { 4594 4594 perror("cap_get_proc");
+24 -24
tools/testing/selftests/powerpc/include/vsx_asm.h
··· 16 16 */ 17 17 FUNC_START(load_vsx) 18 18 li r5,0 19 - lxvx vs20,r5,r3 19 + lxvd2x vs20,r5,r3 20 20 addi r5,r5,16 21 - lxvx vs21,r5,r3 21 + lxvd2x vs21,r5,r3 22 22 addi r5,r5,16 23 - lxvx vs22,r5,r3 23 + lxvd2x vs22,r5,r3 24 24 addi r5,r5,16 25 - lxvx vs23,r5,r3 25 + lxvd2x vs23,r5,r3 26 26 addi r5,r5,16 27 - lxvx vs24,r5,r3 27 + lxvd2x vs24,r5,r3 28 28 addi r5,r5,16 29 - lxvx vs25,r5,r3 29 + lxvd2x vs25,r5,r3 30 30 addi r5,r5,16 31 - lxvx vs26,r5,r3 31 + lxvd2x vs26,r5,r3 32 32 addi r5,r5,16 33 - lxvx vs27,r5,r3 33 + lxvd2x vs27,r5,r3 34 34 addi r5,r5,16 35 - lxvx vs28,r5,r3 35 + lxvd2x vs28,r5,r3 36 36 addi r5,r5,16 37 - lxvx vs29,r5,r3 37 + lxvd2x vs29,r5,r3 38 38 addi r5,r5,16 39 - lxvx vs30,r5,r3 39 + lxvd2x vs30,r5,r3 40 40 addi r5,r5,16 41 - lxvx vs31,r5,r3 41 + lxvd2x vs31,r5,r3 42 42 blr 43 43 FUNC_END(load_vsx) 44 44 45 45 FUNC_START(store_vsx) 46 46 li r5,0 47 - stxvx vs20,r5,r3 47 + stxvd2x vs20,r5,r3 48 48 addi r5,r5,16 49 - stxvx vs21,r5,r3 49 + stxvd2x vs21,r5,r3 50 50 addi r5,r5,16 51 - stxvx vs22,r5,r3 51 + stxvd2x vs22,r5,r3 52 52 addi r5,r5,16 53 - stxvx vs23,r5,r3 53 + stxvd2x vs23,r5,r3 54 54 addi r5,r5,16 55 - stxvx vs24,r5,r3 55 + stxvd2x vs24,r5,r3 56 56 addi r5,r5,16 57 - stxvx vs25,r5,r3 57 + stxvd2x vs25,r5,r3 58 58 addi r5,r5,16 59 - stxvx vs26,r5,r3 59 + stxvd2x vs26,r5,r3 60 60 addi r5,r5,16 61 - stxvx vs27,r5,r3 61 + stxvd2x vs27,r5,r3 62 62 addi r5,r5,16 63 - stxvx vs28,r5,r3 63 + stxvd2x vs28,r5,r3 64 64 addi r5,r5,16 65 - stxvx vs29,r5,r3 65 + stxvd2x vs29,r5,r3 66 66 addi r5,r5,16 67 - stxvx vs30,r5,r3 67 + stxvd2x vs30,r5,r3 68 68 addi r5,r5,16 69 - stxvx vs31,r5,r3 69 + stxvd2x vs31,r5,r3 70 70 blr 71 71 FUNC_END(store_vsx)