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

Merge back earlier ACPI thermal material.

+2971 -1271
+6 -6
Documentation/DocBook/drm.tmpl
··· 79 79 <partintro> 80 80 <para> 81 81 This first part of the DRM Developer's Guide documents core DRM code, 82 - helper libraries for writting drivers and generic userspace interfaces 82 + helper libraries for writing drivers and generic userspace interfaces 83 83 exposed by DRM drivers. 84 84 </para> 85 85 </partintro> ··· 459 459 providing a solution to every graphics memory-related problems, GEM 460 460 identified common code between drivers and created a support library to 461 461 share it. GEM has simpler initialization and execution requirements than 462 - TTM, but has no video RAM management capabitilies and is thus limited to 462 + TTM, but has no video RAM management capabilities and is thus limited to 463 463 UMA devices. 464 464 </para> 465 465 <sect2> ··· 889 889 vice versa. Drivers must use the kernel dma-buf buffer sharing framework 890 890 to manage the PRIME file descriptors. Similar to the mode setting 891 891 API PRIME is agnostic to the underlying buffer object manager, as 892 - long as handles are 32bit unsinged integers. 892 + long as handles are 32bit unsigned integers. 893 893 </para> 894 894 <para> 895 895 While non-GEM drivers must implement the operations themselves, GEM ··· 2356 2356 first create properties and then create and associate individual instances 2357 2357 of those properties to objects. A property can be instantiated multiple 2358 2358 times and associated with different objects. Values are stored in property 2359 - instances, and all other property information are stored in the propery 2359 + instances, and all other property information are stored in the property 2360 2360 and shared between all instances of the property. 2361 2361 </para> 2362 2362 <para> ··· 2697 2697 <sect1> 2698 2698 <title>Legacy Support Code</title> 2699 2699 <para> 2700 - The section very brievely covers some of the old legacy support code which 2700 + The section very briefly covers some of the old legacy support code which 2701 2701 is only used by old DRM drivers which have done a so-called shadow-attach 2702 2702 to the underlying device instead of registering as a real driver. This 2703 - also includes some of the old generic buffer mangement and command 2703 + also includes some of the old generic buffer management and command 2704 2704 submission code. Do not use any of this in new and modern drivers. 2705 2705 </para> 2706 2706
+1 -1
Documentation/DocBook/media/Makefile
··· 195 195 # 196 196 197 197 install_media_images = \ 198 - $(Q)cp $(OBJIMGFILES) $(MEDIA_SRC_DIR)/v4l/*.svg $(MEDIA_OBJ_DIR)/media_api 198 + $(Q)-cp $(OBJIMGFILES) $(MEDIA_SRC_DIR)/v4l/*.svg $(MEDIA_OBJ_DIR)/media_api 199 199 200 200 $(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64 201 201 $(Q)base64 -d $< >$@
+1 -1
Documentation/devicetree/bindings/net/mdio-gpio.txt
··· 14 14 Example: 15 15 16 16 aliases { 17 - mdio-gpio0 = <&mdio0>; 17 + mdio-gpio0 = &mdio0; 18 18 }; 19 19 20 20 mdio0: mdio {
+5 -10
Documentation/email-clients.txt
··· 201 201 202 202 - Edit your Thunderbird config settings so that it won't use format=flowed. 203 203 Go to "edit->preferences->advanced->config editor" to bring up the 204 - thunderbird's registry editor, and set "mailnews.send_plaintext_flowed" to 205 - "false". 204 + thunderbird's registry editor. 206 205 207 - - Disable HTML Format: Set "mail.identity.id1.compose_html" to "false". 206 + - Set "mailnews.send_plaintext_flowed" to "false" 208 207 209 - - Enable "preformat" mode: Set "editor.quotesPreformatted" to "true". 208 + - Set "mailnews.wraplength" from "72" to "0" 210 209 211 - - Enable UTF8: Set "prefs.converted-to-utf8" to "true". 210 + - "View" > "Message Body As" > "Plain Text" 212 211 213 - - Install the "toggle wordwrap" extension. Download the file from: 214 - https://addons.mozilla.org/thunderbird/addon/2351/ 215 - Then go to "tools->add ons", select "install" at the bottom of the screen, 216 - and browse to where you saved the .xul file. This adds an "Enable 217 - Wordwrap" entry under the Options menu of the message composer. 212 + - "View" > "Character Encoding" > "Unicode (UTF-8)" 218 213 219 214 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 220 215 TkRat (GUI)
+3 -2
Documentation/filesystems/proc.txt
··· 1245 1245 1246 1246 The "intr" line gives counts of interrupts serviced since boot time, for each 1247 1247 of the possible system interrupts. The first column is the total of all 1248 - interrupts serviced; each subsequent column is the total for that particular 1249 - interrupt. 1248 + interrupts serviced including unnumbered architecture specific interrupts; 1249 + each subsequent column is the total for that particular numbered interrupt. 1250 + Unnumbered interrupts are not shown, only summed into the total. 1250 1251 1251 1252 The "ctxt" line gives the total number of context switches across all CPUs. 1252 1253
+14
Documentation/hwmon/sysfs-interface
··· 327 327 from the max value. 328 328 RW 329 329 330 + temp[1-*]_min_hyst 331 + Temperature hysteresis value for min limit. 332 + Unit: millidegree Celsius 333 + Must be reported as an absolute temperature, NOT a delta 334 + from the min value. 335 + RW 336 + 330 337 temp[1-*]_input Temperature input value. 331 338 Unit: millidegree Celsius 332 339 RO ··· 367 360 temp[1-*]_lcrit Temperature critical min value, typically lower than 368 361 corresponding temp_min values. 369 362 Unit: millidegree Celsius 363 + RW 364 + 365 + temp[1-*]_lcrit_hyst 366 + Temperature hysteresis value for critical min limit. 367 + Unit: millidegree Celsius 368 + Must be reported as an absolute temperature, NOT a delta 369 + from the critical min value. 370 370 RW 371 371 372 372 temp[1-*]_offset
+8
Documentation/java.txt
··· 188 188 #define CP_METHODREF 10 189 189 #define CP_INTERFACEMETHODREF 11 190 190 #define CP_NAMEANDTYPE 12 191 + #define CP_METHODHANDLE 15 192 + #define CP_METHODTYPE 16 193 + #define CP_INVOKEDYNAMIC 18 191 194 192 195 /* Define some commonly used error messages */ 193 196 ··· 245 242 break; 246 243 case CP_CLASS: 247 244 case CP_STRING: 245 + case CP_METHODTYPE: 248 246 seekerr = fseek(classfile, 2, SEEK_CUR); 247 + break; 248 + case CP_METHODHANDLE: 249 + seekerr = fseek(classfile, 3, SEEK_CUR); 249 250 break; 250 251 case CP_INTEGER: 251 252 case CP_FLOAT: ··· 257 250 case CP_METHODREF: 258 251 case CP_INTERFACEMETHODREF: 259 252 case CP_NAMEANDTYPE: 253 + case CP_INVOKEDYNAMIC: 260 254 seekerr = fseek(classfile, 4, SEEK_CUR); 261 255 break; 262 256 case CP_LONG:
+1 -1
Documentation/networking/filter.txt
··· 277 277 mark skb->mark 278 278 queue skb->queue_mapping 279 279 hatype skb->dev->type 280 - rxhash skb->rxhash 280 + rxhash skb->hash 281 281 cpu raw_smp_processor_id() 282 282 vlan_tci vlan_tx_tag_get(skb) 283 283 vlan_pr vlan_tx_tag_present(skb)
+1 -1
Documentation/networking/packet_mmap.txt
··· 578 578 579 579 Currently implemented fanout policies are: 580 580 581 - - PACKET_FANOUT_HASH: schedule to socket by skb's rxhash 581 + - PACKET_FANOUT_HASH: schedule to socket by skb's packet hash 582 582 - PACKET_FANOUT_LB: schedule to socket by round-robin 583 583 - PACKET_FANOUT_CPU: schedule to socket by CPU packet arrives on 584 584 - PACKET_FANOUT_RND: schedule to socket by random selection
+3 -3
MAINTAINERS
··· 537 537 F: arch/alpha/ 538 538 539 539 ALTERA TRIPLE SPEED ETHERNET DRIVER 540 - M: Vince Bridgers <vbridgers2013@gmail.com 540 + M: Vince Bridgers <vbridgers2013@gmail.com> 541 541 L: netdev@vger.kernel.org 542 542 L: nios2-dev@lists.rocketboards.org (moderated for non-subscribers) 543 543 S: Maintained ··· 6514 6514 F: arch/openrisc/ 6515 6515 6516 6516 OPENVSWITCH 6517 - M: Jesse Gross <jesse@nicira.com> 6517 + M: Pravin Shelar <pshelar@nicira.com> 6518 6518 L: dev@openvswitch.org 6519 6519 W: http://openvswitch.org 6520 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch.git 6520 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/pshelar/openvswitch.git 6521 6521 S: Maintained 6522 6522 F: net/openvswitch/ 6523 6523
+1 -1
Makefile
··· 1 1 VERSION = 3 2 2 PATCHLEVEL = 15 3 3 SUBLEVEL = 0 4 - EXTRAVERSION = -rc6 4 + EXTRAVERSION = -rc7 5 5 NAME = Shuffling Zombie Juror 6 6 7 7 # *DOCUMENTATION*
+1 -1
arch/parisc/kernel/syscall_table.S
··· 432 432 ENTRY_SAME(sched_setattr) 433 433 ENTRY_SAME(sched_getattr) /* 335 */ 434 434 ENTRY_COMP(utimes) 435 - ENTRY_COMP(renameat2) 435 + ENTRY_SAME(renameat2) 436 436 437 437 /* Nothing yet */ 438 438
+1 -1
arch/s390/net/bpf_jit_comp.c
··· 811 811 return NULL; 812 812 memset(header, 0, sz); 813 813 header->pages = sz / PAGE_SIZE; 814 - hole = sz - (bpfsize + sizeof(*header)); 814 + hole = min(sz - (bpfsize + sizeof(*header)), PAGE_SIZE - sizeof(*header)); 815 815 /* Insert random number of illegal instructions before BPF code 816 816 * and make sure the first instruction starts at an even address. 817 817 */
+4 -2
arch/sparc/include/asm/pgtable_64.h
··· 24 24 25 25 /* The kernel image occupies 0x4000000 to 0x6000000 (4MB --> 96MB). 26 26 * The page copy blockops can use 0x6000000 to 0x8000000. 27 - * The TSB is mapped in the 0x8000000 to 0xa000000 range. 27 + * The 8K TSB is mapped in the 0x8000000 to 0x8400000 range. 28 + * The 4M TSB is mapped in the 0x8400000 to 0x8800000 range. 28 29 * The PROM resides in an area spanning 0xf0000000 to 0x100000000. 29 30 * The vmalloc area spans 0x100000000 to 0x200000000. 30 31 * Since modules need to be in the lowest 32-bits of the address space, ··· 34 33 * 0x400000000. 35 34 */ 36 35 #define TLBTEMP_BASE _AC(0x0000000006000000,UL) 37 - #define TSBMAP_BASE _AC(0x0000000008000000,UL) 36 + #define TSBMAP_8K_BASE _AC(0x0000000008000000,UL) 37 + #define TSBMAP_4M_BASE _AC(0x0000000008400000,UL) 38 38 #define MODULES_VADDR _AC(0x0000000010000000,UL) 39 39 #define MODULES_LEN _AC(0x00000000e0000000,UL) 40 40 #define MODULES_END _AC(0x00000000f0000000,UL)
+1 -1
arch/sparc/kernel/sysfs.c
··· 151 151 size_t count) 152 152 { 153 153 unsigned long val, err; 154 - int ret = sscanf(buf, "%ld", &val); 154 + int ret = sscanf(buf, "%lu", &val); 155 155 156 156 if (ret != 1) 157 157 return -EINVAL;
+1
arch/sparc/lib/NG2memcpy.S
··· 236 236 */ 237 237 VISEntryHalf 238 238 239 + membar #Sync 239 240 alignaddr %o1, %g0, %g0 240 241 241 242 add %o1, (64 - 1), %o4
+1 -15
arch/sparc/mm/fault_64.c
··· 281 281 show_regs(regs); 282 282 } 283 283 284 - static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs, 285 - unsigned long addr) 286 - { 287 - static int times; 288 - 289 - if (times++ < 10) 290 - printk(KERN_ERR "FAULT[%s:%d]: 32-bit process " 291 - "reports 64-bit fault address [%lx]\n", 292 - current->comm, current->pid, addr); 293 - show_regs(regs); 294 - } 295 - 296 284 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) 297 285 { 298 286 enum ctx_state prev_state = exception_enter(); ··· 310 322 goto intr_or_no_mm; 311 323 } 312 324 } 313 - if (unlikely((address >> 32) != 0)) { 314 - bogus_32bit_fault_address(regs, address); 325 + if (unlikely((address >> 32) != 0)) 315 326 goto intr_or_no_mm; 316 - } 317 327 } 318 328 319 329 if (regs->tstate & TSTATE_PRIV) {
+13 -1
arch/sparc/mm/tsb.c
··· 133 133 mm->context.tsb_block[tsb_idx].tsb_nentries = 134 134 tsb_bytes / sizeof(struct tsb); 135 135 136 - base = TSBMAP_BASE; 136 + switch (tsb_idx) { 137 + case MM_TSB_BASE: 138 + base = TSBMAP_8K_BASE; 139 + break; 140 + #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) 141 + case MM_TSB_HUGE: 142 + base = TSBMAP_4M_BASE; 143 + break; 144 + #endif 145 + default: 146 + BUG(); 147 + } 148 + 137 149 tte = pgprot_val(PAGE_KERNEL_LOCKED); 138 150 tsb_paddr = __pa(mm->context.tsb_block[tsb_idx].tsb); 139 151 BUG_ON(tsb_paddr & (tsb_bytes - 1UL));
-1
arch/x86/kernel/cpu/perf_event_intel.c
··· 169 169 { 170 170 FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */ 171 171 FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */ 172 - FIXED_EVENT_CONSTRAINT(0x013c, 2), /* CPU_CLK_UNHALTED.REF */ 173 172 FIXED_EVENT_CONSTRAINT(0x0300, 2), /* pseudo CPU_CLK_UNHALTED.REF */ 174 173 EVENT_CONSTRAINT_END 175 174 };
+1 -1
arch/x86/net/bpf_jit_comp.c
··· 171 171 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */ 172 172 173 173 header->pages = sz / PAGE_SIZE; 174 - hole = sz - (proglen + sizeof(*header)); 174 + hole = min(sz - (proglen + sizeof(*header)), PAGE_SIZE - sizeof(*header)); 175 175 176 176 /* insert a random number of int3 instructions before BPF code */ 177 177 *image_ptr = &header->image[prandom_u32() % hole];
+24 -4
drivers/acpi/bus.c
··· 132 132 } 133 133 EXPORT_SYMBOL(acpi_bus_private_data_handler); 134 134 135 + int acpi_bus_attach_private_data(acpi_handle handle, void *data) 136 + { 137 + acpi_status status; 138 + 139 + status = acpi_attach_data(handle, 140 + acpi_bus_private_data_handler, data); 141 + if (ACPI_FAILURE(status)) { 142 + acpi_handle_debug(handle, "Error attaching device data\n"); 143 + return -ENODEV; 144 + } 145 + 146 + return 0; 147 + } 148 + EXPORT_SYMBOL_GPL(acpi_bus_attach_private_data); 149 + 135 150 int acpi_bus_get_private_data(acpi_handle handle, void **data) 136 151 { 137 152 acpi_status status; ··· 155 140 return -EINVAL; 156 141 157 142 status = acpi_get_data(handle, acpi_bus_private_data_handler, data); 158 - if (ACPI_FAILURE(status) || !*data) { 159 - ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", 160 - handle)); 143 + if (ACPI_FAILURE(status)) { 144 + acpi_handle_debug(handle, "No context for object\n"); 161 145 return -ENODEV; 162 146 } 163 147 164 148 return 0; 165 149 } 166 - EXPORT_SYMBOL(acpi_bus_get_private_data); 150 + EXPORT_SYMBOL_GPL(acpi_bus_get_private_data); 151 + 152 + void acpi_bus_detach_private_data(acpi_handle handle) 153 + { 154 + acpi_detach_data(handle, acpi_bus_private_data_handler); 155 + } 156 + EXPORT_SYMBOL_GPL(acpi_bus_detach_private_data); 167 157 168 158 void acpi_bus_no_hotplug(acpi_handle handle) 169 159 {
+4 -7
drivers/acpi/thermal.c
··· 925 925 if (result) 926 926 return result; 927 927 928 - status = acpi_attach_data(tz->device->handle, 929 - acpi_bus_private_data_handler, 930 - tz->thermal_zone); 931 - if (ACPI_FAILURE(status)) { 932 - pr_err(PREFIX "Error attaching device data\n"); 928 + status = acpi_bus_attach_private_data(tz->device->handle, 929 + tz->thermal_zone); 930 + if (ACPI_FAILURE(status)) 933 931 return -ENODEV; 934 - } 935 932 936 933 tz->tz_enabled = 1; 937 934 ··· 943 946 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); 944 947 thermal_zone_device_unregister(tz->thermal_zone); 945 948 tz->thermal_zone = NULL; 946 - acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler); 949 + acpi_bus_detach_private_data(tz->device->handle); 947 950 } 948 951 949 952
+2
drivers/dma/dmaengine.c
··· 1009 1009 dma_unmap_page(dev, unmap->addr[i], unmap->len, 1010 1010 DMA_BIDIRECTIONAL); 1011 1011 } 1012 + cnt = unmap->map_cnt; 1012 1013 mempool_free(unmap, __get_unmap_pool(cnt)->pool); 1013 1014 } 1014 1015 ··· 1075 1074 memset(unmap, 0, sizeof(*unmap)); 1076 1075 kref_init(&unmap->kref); 1077 1076 unmap->dev = dev; 1077 + unmap->map_cnt = nr; 1078 1078 1079 1079 return unmap; 1080 1080 }
+3 -5
drivers/dma/mv_xor.c
··· 191 191 192 192 static void mv_chan_activate(struct mv_xor_chan *chan) 193 193 { 194 - u32 activation; 195 - 196 194 dev_dbg(mv_chan_to_devp(chan), " activate chan.\n"); 197 - activation = readl_relaxed(XOR_ACTIVATION(chan)); 198 - activation |= 0x1; 199 - writel_relaxed(activation, XOR_ACTIVATION(chan)); 195 + 196 + /* writel ensures all descriptors are flushed before activation */ 197 + writel(BIT(0), XOR_ACTIVATION(chan)); 200 198 } 201 199 202 200 static char mv_chan_is_busy(struct mv_xor_chan *chan)
+1 -1
drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
··· 1009 1009 } 1010 1010 1011 1011 if (outp == 8) 1012 - return false; 1012 + return conf; 1013 1013 1014 1014 data = exec_lookup(priv, head, outp, ctrl, dcb, &ver, &hdr, &cnt, &len, &info1); 1015 1015 if (data == 0x0000)
+1
drivers/gpu/drm/nouveau/core/subdev/therm/nvd0.c
··· 40 40 case 0x00: return 2; 41 41 case 0x19: return 1; 42 42 case 0x1c: return 0; 43 + case 0x1e: return 2; 43 44 default: 44 45 break; 45 46 }
+4 -2
drivers/gpu/drm/radeon/radeon.h
··· 1642 1642 unsigned fb_version; 1643 1643 atomic_t handles[RADEON_MAX_VCE_HANDLES]; 1644 1644 struct drm_file *filp[RADEON_MAX_VCE_HANDLES]; 1645 + unsigned img_size[RADEON_MAX_VCE_HANDLES]; 1645 1646 struct delayed_work idle_work; 1646 1647 }; 1647 1648 ··· 1656 1655 uint32_t handle, struct radeon_fence **fence); 1657 1656 void radeon_vce_free_handles(struct radeon_device *rdev, struct drm_file *filp); 1658 1657 void radeon_vce_note_usage(struct radeon_device *rdev); 1659 - int radeon_vce_cs_reloc(struct radeon_cs_parser *p, int lo, int hi); 1658 + int radeon_vce_cs_reloc(struct radeon_cs_parser *p, int lo, int hi, unsigned size); 1660 1659 int radeon_vce_cs_parse(struct radeon_cs_parser *p); 1661 1660 bool radeon_vce_semaphore_emit(struct radeon_device *rdev, 1662 1661 struct radeon_ring *ring, ··· 2641 2640 #define ASIC_IS_DCE8(rdev) ((rdev->family >= CHIP_BONAIRE)) 2642 2641 #define ASIC_IS_DCE81(rdev) ((rdev->family == CHIP_KAVERI)) 2643 2642 #define ASIC_IS_DCE82(rdev) ((rdev->family == CHIP_BONAIRE)) 2644 - #define ASIC_IS_DCE83(rdev) ((rdev->family == CHIP_KABINI)) 2643 + #define ASIC_IS_DCE83(rdev) ((rdev->family == CHIP_KABINI) || \ 2644 + (rdev->family == CHIP_MULLINS)) 2645 2645 2646 2646 #define ASIC_IS_LOMBOK(rdev) ((rdev->ddev->pdev->device == 0x6849) || \ 2647 2647 (rdev->ddev->pdev->device == 0x6850) || \
+14
drivers/gpu/drm/radeon/radeon_bios.c
··· 196 196 } 197 197 } 198 198 199 + if (!found) { 200 + while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { 201 + dhandle = ACPI_HANDLE(&pdev->dev); 202 + if (!dhandle) 203 + continue; 204 + 205 + status = acpi_get_handle(dhandle, "ATRM", &atrm_handle); 206 + if (!ACPI_FAILURE(status)) { 207 + found = true; 208 + break; 209 + } 210 + } 211 + } 212 + 199 213 if (!found) 200 214 return false; 201 215
+1 -1
drivers/gpu/drm/radeon/radeon_display.c
··· 999 999 1000 1000 /* avoid high jitter with small fractional dividers */ 1001 1001 if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV && (fb_div % 10)) { 1002 - fb_div_min = max(fb_div_min, (9 - (fb_div % 10)) * 20 + 60); 1002 + fb_div_min = max(fb_div_min, (9 - (fb_div % 10)) * 20 + 50); 1003 1003 if (fb_div < fb_div_min) { 1004 1004 unsigned tmp = DIV_ROUND_UP(fb_div_min, fb_div); 1005 1005 fb_div *= tmp;
+31 -28
drivers/gpu/drm/radeon/radeon_kms.c
··· 577 577 return r; 578 578 } 579 579 580 - r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); 581 - if (r) { 582 - radeon_vm_fini(rdev, &fpriv->vm); 583 - kfree(fpriv); 584 - return r; 580 + if (rdev->accel_working) { 581 + r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); 582 + if (r) { 583 + radeon_vm_fini(rdev, &fpriv->vm); 584 + kfree(fpriv); 585 + return r; 586 + } 587 + 588 + /* map the ib pool buffer read only into 589 + * virtual address space */ 590 + bo_va = radeon_vm_bo_add(rdev, &fpriv->vm, 591 + rdev->ring_tmp_bo.bo); 592 + r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET, 593 + RADEON_VM_PAGE_READABLE | 594 + RADEON_VM_PAGE_SNOOPED); 595 + 596 + radeon_bo_unreserve(rdev->ring_tmp_bo.bo); 597 + if (r) { 598 + radeon_vm_fini(rdev, &fpriv->vm); 599 + kfree(fpriv); 600 + return r; 601 + } 585 602 } 586 - 587 - /* map the ib pool buffer read only into 588 - * virtual address space */ 589 - bo_va = radeon_vm_bo_add(rdev, &fpriv->vm, 590 - rdev->ring_tmp_bo.bo); 591 - r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET, 592 - RADEON_VM_PAGE_READABLE | 593 - RADEON_VM_PAGE_SNOOPED); 594 - 595 - radeon_bo_unreserve(rdev->ring_tmp_bo.bo); 596 - if (r) { 597 - radeon_vm_fini(rdev, &fpriv->vm); 598 - kfree(fpriv); 599 - return r; 600 - } 601 - 602 603 file_priv->driver_priv = fpriv; 603 604 } 604 605 ··· 627 626 struct radeon_bo_va *bo_va; 628 627 int r; 629 628 630 - r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); 631 - if (!r) { 632 - bo_va = radeon_vm_bo_find(&fpriv->vm, 633 - rdev->ring_tmp_bo.bo); 634 - if (bo_va) 635 - radeon_vm_bo_rmv(rdev, bo_va); 636 - radeon_bo_unreserve(rdev->ring_tmp_bo.bo); 629 + if (rdev->accel_working) { 630 + r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); 631 + if (!r) { 632 + bo_va = radeon_vm_bo_find(&fpriv->vm, 633 + rdev->ring_tmp_bo.bo); 634 + if (bo_va) 635 + radeon_vm_bo_rmv(rdev, bo_va); 636 + radeon_bo_unreserve(rdev->ring_tmp_bo.bo); 637 + } 637 638 } 638 639 639 640 radeon_vm_fini(rdev, &fpriv->vm);
+24 -16
drivers/gpu/drm/radeon/radeon_object.c
··· 458 458 * into account. We don't want to disallow buffer moves 459 459 * completely. 460 460 */ 461 - if (current_domain != RADEON_GEM_DOMAIN_CPU && 461 + if ((lobj->alt_domain & current_domain) != 0 && 462 462 (domain & current_domain) == 0 && /* will be moved */ 463 463 bytes_moved > bytes_moved_threshold) { 464 464 /* don't move it */ ··· 699 699 rbo = container_of(bo, struct radeon_bo, tbo); 700 700 radeon_bo_check_tiling(rbo, 0, 0); 701 701 rdev = rbo->rdev; 702 - if (bo->mem.mem_type == TTM_PL_VRAM) { 703 - size = bo->mem.num_pages << PAGE_SHIFT; 704 - offset = bo->mem.start << PAGE_SHIFT; 705 - if ((offset + size) > rdev->mc.visible_vram_size) { 706 - /* hurrah the memory is not visible ! */ 707 - radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_VRAM); 708 - rbo->placement.lpfn = rdev->mc.visible_vram_size >> PAGE_SHIFT; 709 - r = ttm_bo_validate(bo, &rbo->placement, false, false); 710 - if (unlikely(r != 0)) 711 - return r; 712 - offset = bo->mem.start << PAGE_SHIFT; 713 - /* this should not happen */ 714 - if ((offset + size) > rdev->mc.visible_vram_size) 715 - return -EINVAL; 716 - } 702 + if (bo->mem.mem_type != TTM_PL_VRAM) 703 + return 0; 704 + 705 + size = bo->mem.num_pages << PAGE_SHIFT; 706 + offset = bo->mem.start << PAGE_SHIFT; 707 + if ((offset + size) <= rdev->mc.visible_vram_size) 708 + return 0; 709 + 710 + /* hurrah the memory is not visible ! */ 711 + radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_VRAM); 712 + rbo->placement.lpfn = rdev->mc.visible_vram_size >> PAGE_SHIFT; 713 + r = ttm_bo_validate(bo, &rbo->placement, false, false); 714 + if (unlikely(r == -ENOMEM)) { 715 + radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_GTT); 716 + return ttm_bo_validate(bo, &rbo->placement, false, false); 717 + } else if (unlikely(r != 0)) { 718 + return r; 717 719 } 720 + 721 + offset = bo->mem.start << PAGE_SHIFT; 722 + /* this should never happen */ 723 + if ((offset + size) > rdev->mc.visible_vram_size) 724 + return -EINVAL; 725 + 718 726 return 0; 719 727 } 720 728
+41 -1
drivers/gpu/drm/radeon/radeon_pm.c
··· 361 361 struct drm_device *ddev = dev_get_drvdata(dev); 362 362 struct radeon_device *rdev = ddev->dev_private; 363 363 364 + /* Can't set profile when the card is off */ 365 + if ((rdev->flags & RADEON_IS_PX) && 366 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 367 + return -EINVAL; 368 + 364 369 mutex_lock(&rdev->pm.mutex); 365 370 if (rdev->pm.pm_method == PM_METHOD_PROFILE) { 366 371 if (strncmp("default", buf, strlen("default")) == 0) ··· 414 409 struct drm_device *ddev = dev_get_drvdata(dev); 415 410 struct radeon_device *rdev = ddev->dev_private; 416 411 412 + /* Can't set method when the card is off */ 413 + if ((rdev->flags & RADEON_IS_PX) && 414 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) { 415 + count = -EINVAL; 416 + goto fail; 417 + } 418 + 417 419 /* we don't support the legacy modes with dpm */ 418 420 if (rdev->pm.pm_method == PM_METHOD_DPM) { 419 421 count = -EINVAL; ··· 458 446 struct radeon_device *rdev = ddev->dev_private; 459 447 enum radeon_pm_state_type pm = rdev->pm.dpm.user_state; 460 448 449 + if ((rdev->flags & RADEON_IS_PX) && 450 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 451 + return snprintf(buf, PAGE_SIZE, "off\n"); 452 + 461 453 return snprintf(buf, PAGE_SIZE, "%s\n", 462 454 (pm == POWER_STATE_TYPE_BATTERY) ? "battery" : 463 455 (pm == POWER_STATE_TYPE_BALANCED) ? "balanced" : "performance"); ··· 474 458 { 475 459 struct drm_device *ddev = dev_get_drvdata(dev); 476 460 struct radeon_device *rdev = ddev->dev_private; 461 + 462 + /* Can't set dpm state when the card is off */ 463 + if ((rdev->flags & RADEON_IS_PX) && 464 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 465 + return -EINVAL; 477 466 478 467 mutex_lock(&rdev->pm.mutex); 479 468 if (strncmp("battery", buf, strlen("battery")) == 0) ··· 506 485 struct radeon_device *rdev = ddev->dev_private; 507 486 enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level; 508 487 488 + if ((rdev->flags & RADEON_IS_PX) && 489 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 490 + return snprintf(buf, PAGE_SIZE, "off\n"); 491 + 509 492 return snprintf(buf, PAGE_SIZE, "%s\n", 510 493 (level == RADEON_DPM_FORCED_LEVEL_AUTO) ? "auto" : 511 494 (level == RADEON_DPM_FORCED_LEVEL_LOW) ? "low" : "high"); ··· 524 499 struct radeon_device *rdev = ddev->dev_private; 525 500 enum radeon_dpm_forced_level level; 526 501 int ret = 0; 502 + 503 + /* Can't force performance level when the card is off */ 504 + if ((rdev->flags & RADEON_IS_PX) && 505 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 506 + return -EINVAL; 527 507 528 508 mutex_lock(&rdev->pm.mutex); 529 509 if (strncmp("low", buf, strlen("low")) == 0) { ··· 568 538 char *buf) 569 539 { 570 540 struct radeon_device *rdev = dev_get_drvdata(dev); 541 + struct drm_device *ddev = rdev->ddev; 571 542 int temp; 543 + 544 + /* Can't get temperature when the card is off */ 545 + if ((rdev->flags & RADEON_IS_PX) && 546 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 547 + return -EINVAL; 572 548 573 549 if (rdev->asic->pm.get_temperature) 574 550 temp = radeon_get_temperature(rdev); ··· 1650 1614 struct drm_info_node *node = (struct drm_info_node *) m->private; 1651 1615 struct drm_device *dev = node->minor->dev; 1652 1616 struct radeon_device *rdev = dev->dev_private; 1617 + struct drm_device *ddev = rdev->ddev; 1653 1618 1654 - if (rdev->pm.dpm_enabled) { 1619 + if ((rdev->flags & RADEON_IS_PX) && 1620 + (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) { 1621 + seq_printf(m, "PX asic powered off\n"); 1622 + } else if (rdev->pm.dpm_enabled) { 1655 1623 mutex_lock(&rdev->pm.mutex); 1656 1624 if (rdev->asic->dpm.debugfs_print_current_performance_level) 1657 1625 radeon_dpm_debugfs_print_current_performance_level(rdev, m);
+100 -30
drivers/gpu/drm/radeon/radeon_vce.c
··· 443 443 * @p: parser context 444 444 * @lo: address of lower dword 445 445 * @hi: address of higher dword 446 + * @size: size of checker for relocation buffer 446 447 * 447 448 * Patch relocation inside command stream with real buffer address 448 449 */ 449 - int radeon_vce_cs_reloc(struct radeon_cs_parser *p, int lo, int hi) 450 + int radeon_vce_cs_reloc(struct radeon_cs_parser *p, int lo, int hi, 451 + unsigned size) 450 452 { 451 453 struct radeon_cs_chunk *relocs_chunk; 452 - uint64_t offset; 454 + struct radeon_cs_reloc *reloc; 455 + uint64_t start, end, offset; 453 456 unsigned idx; 454 457 455 458 relocs_chunk = &p->chunks[p->chunk_relocs_idx]; ··· 465 462 return -EINVAL; 466 463 } 467 464 468 - offset += p->relocs_ptr[(idx / 4)]->gpu_offset; 465 + reloc = p->relocs_ptr[(idx / 4)]; 466 + start = reloc->gpu_offset; 467 + end = start + radeon_bo_size(reloc->robj); 468 + start += offset; 469 469 470 - p->ib.ptr[lo] = offset & 0xFFFFFFFF; 471 - p->ib.ptr[hi] = offset >> 32; 470 + p->ib.ptr[lo] = start & 0xFFFFFFFF; 471 + p->ib.ptr[hi] = start >> 32; 472 + 473 + if (end <= start) { 474 + DRM_ERROR("invalid reloc offset %llX!\n", offset); 475 + return -EINVAL; 476 + } 477 + if ((end - start) < size) { 478 + DRM_ERROR("buffer to small (%d / %d)!\n", 479 + (unsigned)(end - start), size); 480 + return -EINVAL; 481 + } 472 482 473 483 return 0; 484 + } 485 + 486 + /** 487 + * radeon_vce_validate_handle - validate stream handle 488 + * 489 + * @p: parser context 490 + * @handle: handle to validate 491 + * 492 + * Validates the handle and return the found session index or -EINVAL 493 + * we we don't have another free session index. 494 + */ 495 + int radeon_vce_validate_handle(struct radeon_cs_parser *p, uint32_t handle) 496 + { 497 + unsigned i; 498 + 499 + /* validate the handle */ 500 + for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) { 501 + if (atomic_read(&p->rdev->vce.handles[i]) == handle) 502 + return i; 503 + } 504 + 505 + /* handle not found try to alloc a new one */ 506 + for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) { 507 + if (!atomic_cmpxchg(&p->rdev->vce.handles[i], 0, handle)) { 508 + p->rdev->vce.filp[i] = p->filp; 509 + p->rdev->vce.img_size[i] = 0; 510 + return i; 511 + } 512 + } 513 + 514 + DRM_ERROR("No more free VCE handles!\n"); 515 + return -EINVAL; 474 516 } 475 517 476 518 /** ··· 526 478 */ 527 479 int radeon_vce_cs_parse(struct radeon_cs_parser *p) 528 480 { 529 - uint32_t handle = 0; 530 - bool destroy = false; 481 + int session_idx = -1; 482 + bool destroyed = false; 483 + uint32_t tmp, handle = 0; 484 + uint32_t *size = &tmp; 531 485 int i, r; 532 486 533 487 while (p->idx < p->chunks[p->chunk_ib_idx].length_dw) { ··· 541 491 return -EINVAL; 542 492 } 543 493 494 + if (destroyed) { 495 + DRM_ERROR("No other command allowed after destroy!\n"); 496 + return -EINVAL; 497 + } 498 + 544 499 switch (cmd) { 545 500 case 0x00000001: // session 546 501 handle = radeon_get_ib_value(p, p->idx + 2); 502 + session_idx = radeon_vce_validate_handle(p, handle); 503 + if (session_idx < 0) 504 + return session_idx; 505 + size = &p->rdev->vce.img_size[session_idx]; 547 506 break; 548 507 549 508 case 0x00000002: // task info 509 + break; 510 + 550 511 case 0x01000001: // create 512 + *size = radeon_get_ib_value(p, p->idx + 8) * 513 + radeon_get_ib_value(p, p->idx + 10) * 514 + 8 * 3 / 2; 515 + break; 516 + 551 517 case 0x04000001: // config extension 552 518 case 0x04000002: // pic control 553 519 case 0x04000005: // rate control ··· 572 506 break; 573 507 574 508 case 0x03000001: // encode 575 - r = radeon_vce_cs_reloc(p, p->idx + 10, p->idx + 9); 509 + r = radeon_vce_cs_reloc(p, p->idx + 10, p->idx + 9, 510 + *size); 576 511 if (r) 577 512 return r; 578 513 579 - r = radeon_vce_cs_reloc(p, p->idx + 12, p->idx + 11); 514 + r = radeon_vce_cs_reloc(p, p->idx + 12, p->idx + 11, 515 + *size / 3); 580 516 if (r) 581 517 return r; 582 518 break; 583 519 584 520 case 0x02000001: // destroy 585 - destroy = true; 521 + destroyed = true; 586 522 break; 587 523 588 524 case 0x05000001: // context buffer 525 + r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2, 526 + *size * 2); 527 + if (r) 528 + return r; 529 + break; 530 + 589 531 case 0x05000004: // video bitstream buffer 532 + tmp = radeon_get_ib_value(p, p->idx + 4); 533 + r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2, 534 + tmp); 535 + if (r) 536 + return r; 537 + break; 538 + 590 539 case 0x05000005: // feedback buffer 591 - r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2); 540 + r = radeon_vce_cs_reloc(p, p->idx + 3, p->idx + 2, 541 + 4096); 592 542 if (r) 593 543 return r; 594 544 break; ··· 614 532 return -EINVAL; 615 533 } 616 534 535 + if (session_idx == -1) { 536 + DRM_ERROR("no session command at start of IB\n"); 537 + return -EINVAL; 538 + } 539 + 617 540 p->idx += len / 4; 618 541 } 619 542 620 - if (destroy) { 543 + if (destroyed) { 621 544 /* IB contains a destroy msg, free the handle */ 622 545 for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) 623 546 atomic_cmpxchg(&p->rdev->vce.handles[i], handle, 0); 624 - 625 - return 0; 626 - } 627 - 628 - /* create or encode, validate the handle */ 629 - for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) { 630 - if (atomic_read(&p->rdev->vce.handles[i]) == handle) 631 - return 0; 632 547 } 633 548 634 - /* handle not found try to alloc a new one */ 635 - for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) { 636 - if (!atomic_cmpxchg(&p->rdev->vce.handles[i], 0, handle)) { 637 - p->rdev->vce.filp[i] = p->filp; 638 - return 0; 639 - } 640 - } 641 - 642 - DRM_ERROR("No more free VCE handles!\n"); 643 - return -EINVAL; 549 + return 0; 644 550 } 645 551 646 552 /**
+1 -1
drivers/gpu/drm/radeon/radeon_vm.c
··· 595 595 ndw = 64; 596 596 597 597 /* assume the worst case */ 598 - ndw += vm->max_pde_used * 12; 598 + ndw += vm->max_pde_used * 16; 599 599 600 600 /* update too big for an IB */ 601 601 if (ndw > 0xfffff)
+2 -2
drivers/gpu/drm/radeon/sid.h
··· 107 107 #define SPLL_CHG_STATUS (1 << 1) 108 108 #define SPLL_CNTL_MODE 0x618 109 109 #define SPLL_SW_DIR_CONTROL (1 << 0) 110 - # define SPLL_REFCLK_SEL(x) ((x) << 8) 111 - # define SPLL_REFCLK_SEL_MASK 0xFF00 110 + # define SPLL_REFCLK_SEL(x) ((x) << 26) 111 + # define SPLL_REFCLK_SEL_MASK (3 << 26) 112 112 113 113 #define CG_SPLL_SPREAD_SPECTRUM 0x620 114 114 #define SSEN (1 << 0)
+1 -1
drivers/hwmon/Kconfig
··· 1053 1053 1054 1054 config SENSORS_NTC_THERMISTOR 1055 1055 tristate "NTC thermistor support" 1056 - depends on (!OF && !IIO) || (OF && IIO) 1056 + depends on !OF || IIO=n || IIO 1057 1057 help 1058 1058 This driver supports NTC thermistors sensor reading and its 1059 1059 interpretation. The driver can also monitor the temperature and
+9 -6
drivers/hwmon/ntc_thermistor.c
··· 44 44 unsigned int ohm; 45 45 }; 46 46 47 + /* Order matters, ntc_match references the entries by index */ 47 48 static const struct platform_device_id ntc_thermistor_id[] = { 48 49 { "ncp15wb473", TYPE_NCPXXWB473 }, 49 50 { "ncp18wb473", TYPE_NCPXXWB473 }, ··· 142 141 char name[PLATFORM_NAME_SIZE]; 143 142 }; 144 143 145 - #ifdef CONFIG_OF 144 + #if defined(CONFIG_OF) && IS_ENABLED(CONFIG_IIO) 146 145 static int ntc_adc_iio_read(struct ntc_thermistor_platform_data *pdata) 147 146 { 148 147 struct iio_channel *channel = pdata->chan; ··· 164 163 165 164 static const struct of_device_id ntc_match[] = { 166 165 { .compatible = "ntc,ncp15wb473", 167 - .data = &ntc_thermistor_id[TYPE_NCPXXWB473] }, 166 + .data = &ntc_thermistor_id[0] }, 168 167 { .compatible = "ntc,ncp18wb473", 169 - .data = &ntc_thermistor_id[TYPE_NCPXXWB473] }, 168 + .data = &ntc_thermistor_id[1] }, 170 169 { .compatible = "ntc,ncp21wb473", 171 - .data = &ntc_thermistor_id[TYPE_NCPXXWB473] }, 170 + .data = &ntc_thermistor_id[2] }, 172 171 { .compatible = "ntc,ncp03wb473", 173 - .data = &ntc_thermistor_id[TYPE_NCPXXWB473] }, 172 + .data = &ntc_thermistor_id[3] }, 174 173 { .compatible = "ntc,ncp15wl333", 175 - .data = &ntc_thermistor_id[TYPE_NCPXXWL333] }, 174 + .data = &ntc_thermistor_id[4] }, 176 175 { }, 177 176 }; 178 177 MODULE_DEVICE_TABLE(of, ntc_match); ··· 223 222 { 224 223 return NULL; 225 224 } 225 + 226 + #define ntc_match NULL 226 227 227 228 static void ntc_iio_channel_release(struct ntc_thermistor_platform_data *pdata) 228 229 { }
+64 -3
drivers/infiniband/hw/mlx4/main.c
··· 48 48 49 49 #include <linux/mlx4/driver.h> 50 50 #include <linux/mlx4/cmd.h> 51 + #include <linux/mlx4/qp.h> 51 52 52 53 #include "mlx4_ib.h" 53 54 #include "user.h" ··· 1615 1614 } 1616 1615 #endif 1617 1616 1617 + #define MLX4_IB_INVALID_MAC ((u64)-1) 1618 + static void mlx4_ib_update_qps(struct mlx4_ib_dev *ibdev, 1619 + struct net_device *dev, 1620 + int port) 1621 + { 1622 + u64 new_smac = 0; 1623 + u64 release_mac = MLX4_IB_INVALID_MAC; 1624 + struct mlx4_ib_qp *qp; 1625 + 1626 + read_lock(&dev_base_lock); 1627 + new_smac = mlx4_mac_to_u64(dev->dev_addr); 1628 + read_unlock(&dev_base_lock); 1629 + 1630 + mutex_lock(&ibdev->qp1_proxy_lock[port - 1]); 1631 + qp = ibdev->qp1_proxy[port - 1]; 1632 + if (qp) { 1633 + int new_smac_index; 1634 + u64 old_smac = qp->pri.smac; 1635 + struct mlx4_update_qp_params update_params; 1636 + 1637 + if (new_smac == old_smac) 1638 + goto unlock; 1639 + 1640 + new_smac_index = mlx4_register_mac(ibdev->dev, port, new_smac); 1641 + 1642 + if (new_smac_index < 0) 1643 + goto unlock; 1644 + 1645 + update_params.smac_index = new_smac_index; 1646 + if (mlx4_update_qp(ibdev->dev, &qp->mqp, MLX4_UPDATE_QP_SMAC, 1647 + &update_params)) { 1648 + release_mac = new_smac; 1649 + goto unlock; 1650 + } 1651 + 1652 + qp->pri.smac = new_smac; 1653 + qp->pri.smac_index = new_smac_index; 1654 + 1655 + release_mac = old_smac; 1656 + } 1657 + 1658 + unlock: 1659 + mutex_unlock(&ibdev->qp1_proxy_lock[port - 1]); 1660 + if (release_mac != MLX4_IB_INVALID_MAC) 1661 + mlx4_unregister_mac(ibdev->dev, port, release_mac); 1662 + } 1663 + 1618 1664 static void mlx4_ib_get_dev_addr(struct net_device *dev, 1619 1665 struct mlx4_ib_dev *ibdev, u8 port) 1620 1666 { ··· 1737 1689 return 0; 1738 1690 } 1739 1691 1740 - static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev) 1692 + static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev, 1693 + struct net_device *dev, 1694 + unsigned long event) 1695 + 1741 1696 { 1742 1697 struct mlx4_ib_iboe *iboe; 1698 + int update_qps_port = -1; 1743 1699 int port; 1744 1700 1745 1701 iboe = &ibdev->iboe; ··· 1770 1718 iboe->masters[port - 1] = NULL; 1771 1719 } 1772 1720 curr_master = iboe->masters[port - 1]; 1721 + 1722 + if (dev == iboe->netdevs[port - 1] && 1723 + (event == NETDEV_CHANGEADDR || event == NETDEV_REGISTER || 1724 + event == NETDEV_UP || event == NETDEV_CHANGE)) 1725 + update_qps_port = port; 1773 1726 1774 1727 if (curr_netdev) { 1775 1728 port_state = (netif_running(curr_netdev) && netif_carrier_ok(curr_netdev)) ? ··· 1809 1752 } 1810 1753 1811 1754 spin_unlock(&iboe->lock); 1755 + 1756 + if (update_qps_port > 0) 1757 + mlx4_ib_update_qps(ibdev, dev, update_qps_port); 1812 1758 } 1813 1759 1814 1760 static int mlx4_ib_netdev_event(struct notifier_block *this, ··· 1824 1764 return NOTIFY_DONE; 1825 1765 1826 1766 ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb); 1827 - mlx4_ib_scan_netdevs(ibdev); 1767 + mlx4_ib_scan_netdevs(ibdev, dev, event); 1828 1768 1829 1769 return NOTIFY_DONE; 1830 1770 } ··· 2103 2043 goto err_map; 2104 2044 2105 2045 for (i = 0; i < ibdev->num_ports; ++i) { 2046 + mutex_init(&ibdev->qp1_proxy_lock[i]); 2106 2047 if (mlx4_ib_port_link_layer(&ibdev->ib_dev, i + 1) == 2107 2048 IB_LINK_LAYER_ETHERNET) { 2108 2049 err = mlx4_counter_alloc(ibdev->dev, &ibdev->counters[i]); ··· 2187 2126 for (i = 1 ; i <= ibdev->num_ports ; ++i) 2188 2127 reset_gid_table(ibdev, i); 2189 2128 rtnl_lock(); 2190 - mlx4_ib_scan_netdevs(ibdev); 2129 + mlx4_ib_scan_netdevs(ibdev, NULL, 0); 2191 2130 rtnl_unlock(); 2192 2131 mlx4_ib_init_gid_table(ibdev); 2193 2132 }
+3
drivers/infiniband/hw/mlx4/mlx4_ib.h
··· 522 522 int steer_qpn_count; 523 523 int steer_qpn_base; 524 524 int steering_support; 525 + struct mlx4_ib_qp *qp1_proxy[MLX4_MAX_PORTS]; 526 + /* lock when destroying qp1_proxy and getting netdev events */ 527 + struct mutex qp1_proxy_lock[MLX4_MAX_PORTS]; 525 528 }; 526 529 527 530 struct ib_event_work {
+8
drivers/infiniband/hw/mlx4/qp.c
··· 1132 1132 if (is_qp0(dev, mqp)) 1133 1133 mlx4_CLOSE_PORT(dev->dev, mqp->port); 1134 1134 1135 + if (dev->qp1_proxy[mqp->port - 1] == mqp) { 1136 + mutex_lock(&dev->qp1_proxy_lock[mqp->port - 1]); 1137 + dev->qp1_proxy[mqp->port - 1] = NULL; 1138 + mutex_unlock(&dev->qp1_proxy_lock[mqp->port - 1]); 1139 + } 1140 + 1135 1141 pd = get_pd(mqp); 1136 1142 destroy_qp_common(dev, mqp, !!pd->ibpd.uobject); 1137 1143 ··· 1652 1646 err = handle_eth_ud_smac_index(dev, qp, (u8 *)attr->smac, context); 1653 1647 if (err) 1654 1648 return -EINVAL; 1649 + if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_GSI) 1650 + dev->qp1_proxy[qp->port - 1] = qp; 1655 1651 } 1656 1652 } 1657 1653 }
+38 -16
drivers/net/bonding/bond_alb.c
··· 82 82 } 83 83 84 84 /* Forward declaration */ 85 - static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]); 85 + static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[], 86 + bool strict_match); 86 87 static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp); 87 88 static void rlb_src_unlink(struct bonding *bond, u32 index); 88 89 static void rlb_src_link(struct bonding *bond, u32 ip_src_hash, ··· 460 459 461 460 bond->alb_info.rlb_promisc_timeout_counter = 0; 462 461 463 - alb_send_learning_packets(bond->curr_active_slave, addr); 462 + alb_send_learning_packets(bond->curr_active_slave, addr, true); 464 463 } 465 464 466 465 /* slave being removed should not be active at this point ··· 996 995 /*********************** tlb/rlb shared functions *********************/ 997 996 998 997 static void alb_send_lp_vid(struct slave *slave, u8 mac_addr[], 999 - u16 vid) 998 + __be16 vlan_proto, u16 vid) 1000 999 { 1001 1000 struct learning_pkt pkt; 1002 1001 struct sk_buff *skb; ··· 1022 1021 skb->dev = slave->dev; 1023 1022 1024 1023 if (vid) { 1025 - skb = vlan_put_tag(skb, htons(ETH_P_8021Q), vid); 1024 + skb = vlan_put_tag(skb, vlan_proto, vid); 1026 1025 if (!skb) { 1027 1026 pr_err("%s: Error: failed to insert VLAN tag\n", 1028 1027 slave->bond->dev->name); ··· 1033 1032 dev_queue_xmit(skb); 1034 1033 } 1035 1034 1036 - 1037 - static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) 1035 + static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[], 1036 + bool strict_match) 1038 1037 { 1039 1038 struct bonding *bond = bond_get_bond_by_slave(slave); 1040 1039 struct net_device *upper; 1041 1040 struct list_head *iter; 1042 1041 1043 1042 /* send untagged */ 1044 - alb_send_lp_vid(slave, mac_addr, 0); 1043 + alb_send_lp_vid(slave, mac_addr, 0, 0); 1045 1044 1046 1045 /* loop through vlans and send one packet for each */ 1047 1046 rcu_read_lock(); 1048 1047 netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) { 1049 - if (upper->priv_flags & IFF_802_1Q_VLAN) 1050 - alb_send_lp_vid(slave, mac_addr, 1051 - vlan_dev_vlan_id(upper)); 1048 + if (is_vlan_dev(upper) && vlan_get_encap_level(upper) == 0) { 1049 + if (strict_match && 1050 + ether_addr_equal_64bits(mac_addr, 1051 + upper->dev_addr)) { 1052 + alb_send_lp_vid(slave, mac_addr, 1053 + vlan_dev_vlan_proto(upper), 1054 + vlan_dev_vlan_id(upper)); 1055 + } else if (!strict_match) { 1056 + alb_send_lp_vid(slave, upper->dev_addr, 1057 + vlan_dev_vlan_proto(upper), 1058 + vlan_dev_vlan_id(upper)); 1059 + } 1060 + } 1052 1061 } 1053 1062 rcu_read_unlock(); 1054 1063 } ··· 1118 1107 1119 1108 /* fasten the change in the switch */ 1120 1109 if (SLAVE_IS_OK(slave1)) { 1121 - alb_send_learning_packets(slave1, slave1->dev->dev_addr); 1110 + alb_send_learning_packets(slave1, slave1->dev->dev_addr, false); 1122 1111 if (bond->alb_info.rlb_enabled) { 1123 1112 /* inform the clients that the mac address 1124 1113 * has changed ··· 1130 1119 } 1131 1120 1132 1121 if (SLAVE_IS_OK(slave2)) { 1133 - alb_send_learning_packets(slave2, slave2->dev->dev_addr); 1122 + alb_send_learning_packets(slave2, slave2->dev->dev_addr, false); 1134 1123 if (bond->alb_info.rlb_enabled) { 1135 1124 /* inform the clients that the mac address 1136 1125 * has changed ··· 1501 1490 1502 1491 /* send learning packets */ 1503 1492 if (bond_info->lp_counter >= BOND_ALB_LP_TICKS(bond)) { 1493 + bool strict_match; 1494 + 1504 1495 /* change of curr_active_slave involves swapping of mac addresses. 1505 1496 * in order to avoid this swapping from happening while 1506 1497 * sending the learning packets, the curr_slave_lock must be held for ··· 1510 1497 */ 1511 1498 read_lock(&bond->curr_slave_lock); 1512 1499 1513 - bond_for_each_slave_rcu(bond, slave, iter) 1514 - alb_send_learning_packets(slave, slave->dev->dev_addr); 1500 + bond_for_each_slave_rcu(bond, slave, iter) { 1501 + /* If updating current_active, use all currently 1502 + * user mac addreses (!strict_match). Otherwise, only 1503 + * use mac of the slave device. 1504 + */ 1505 + strict_match = (slave != bond->curr_active_slave); 1506 + alb_send_learning_packets(slave, slave->dev->dev_addr, 1507 + strict_match); 1508 + } 1515 1509 1516 1510 read_unlock(&bond->curr_slave_lock); 1517 1511 ··· 1741 1721 } else { 1742 1722 /* set the new_slave to the bond mac address */ 1743 1723 alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr); 1744 - alb_send_learning_packets(new_slave, bond->dev->dev_addr); 1724 + alb_send_learning_packets(new_slave, bond->dev->dev_addr, 1725 + false); 1745 1726 } 1746 1727 1747 1728 write_lock_bh(&bond->curr_slave_lock); ··· 1785 1764 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr); 1786 1765 1787 1766 read_lock(&bond->lock); 1788 - alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr); 1767 + alb_send_learning_packets(bond->curr_active_slave, 1768 + bond_dev->dev_addr, false); 1789 1769 if (bond->alb_info.rlb_enabled) { 1790 1770 /* inform clients mac address has changed */ 1791 1771 rlb_req_update_slave_clients(bond, bond->curr_active_slave);
+65 -69
drivers/net/bonding/bond_main.c
··· 2126 2126 */ 2127 2127 static void bond_arp_send(struct net_device *slave_dev, int arp_op, 2128 2128 __be32 dest_ip, __be32 src_ip, 2129 - struct bond_vlan_tag *inner, 2130 - struct bond_vlan_tag *outer) 2129 + struct bond_vlan_tag *tags) 2131 2130 { 2132 2131 struct sk_buff *skb; 2132 + int i; 2133 2133 2134 2134 pr_debug("arp %d on slave %s: dst %pI4 src %pI4\n", 2135 2135 arp_op, slave_dev->name, &dest_ip, &src_ip); ··· 2141 2141 net_err_ratelimited("ARP packet allocation failed\n"); 2142 2142 return; 2143 2143 } 2144 - if (outer->vlan_id) { 2145 - if (inner->vlan_id) { 2146 - pr_debug("inner tag: proto %X vid %X\n", 2147 - ntohs(inner->vlan_proto), inner->vlan_id); 2148 - skb = __vlan_put_tag(skb, inner->vlan_proto, 2149 - inner->vlan_id); 2150 - if (!skb) { 2151 - net_err_ratelimited("failed to insert inner VLAN tag\n"); 2152 - return; 2153 - } 2154 - } 2155 2144 2156 - pr_debug("outer reg: proto %X vid %X\n", 2157 - ntohs(outer->vlan_proto), outer->vlan_id); 2158 - skb = vlan_put_tag(skb, outer->vlan_proto, outer->vlan_id); 2145 + /* Go through all the tags backwards and add them to the packet */ 2146 + for (i = BOND_MAX_VLAN_ENCAP - 1; i > 0; i--) { 2147 + if (!tags[i].vlan_id) 2148 + continue; 2149 + 2150 + pr_debug("inner tag: proto %X vid %X\n", 2151 + ntohs(tags[i].vlan_proto), tags[i].vlan_id); 2152 + skb = __vlan_put_tag(skb, tags[i].vlan_proto, 2153 + tags[i].vlan_id); 2154 + if (!skb) { 2155 + net_err_ratelimited("failed to insert inner VLAN tag\n"); 2156 + return; 2157 + } 2158 + } 2159 + /* Set the outer tag */ 2160 + if (tags[0].vlan_id) { 2161 + pr_debug("outer tag: proto %X vid %X\n", 2162 + ntohs(tags[0].vlan_proto), tags[0].vlan_id); 2163 + skb = vlan_put_tag(skb, tags[0].vlan_proto, tags[0].vlan_id); 2159 2164 if (!skb) { 2160 2165 net_err_ratelimited("failed to insert outer VLAN tag\n"); 2161 2166 return; ··· 2169 2164 arp_xmit(skb); 2170 2165 } 2171 2166 2167 + /* Validate the device path between the @start_dev and the @end_dev. 2168 + * The path is valid if the @end_dev is reachable through device 2169 + * stacking. 2170 + * When the path is validated, collect any vlan information in the 2171 + * path. 2172 + */ 2173 + static bool bond_verify_device_path(struct net_device *start_dev, 2174 + struct net_device *end_dev, 2175 + struct bond_vlan_tag *tags) 2176 + { 2177 + struct net_device *upper; 2178 + struct list_head *iter; 2179 + int idx; 2180 + 2181 + if (start_dev == end_dev) 2182 + return true; 2183 + 2184 + netdev_for_each_upper_dev_rcu(start_dev, upper, iter) { 2185 + if (bond_verify_device_path(upper, end_dev, tags)) { 2186 + if (is_vlan_dev(upper)) { 2187 + idx = vlan_get_encap_level(upper); 2188 + if (idx >= BOND_MAX_VLAN_ENCAP) 2189 + return false; 2190 + 2191 + tags[idx].vlan_proto = 2192 + vlan_dev_vlan_proto(upper); 2193 + tags[idx].vlan_id = vlan_dev_vlan_id(upper); 2194 + } 2195 + return true; 2196 + } 2197 + } 2198 + 2199 + return false; 2200 + } 2172 2201 2173 2202 static void bond_arp_send_all(struct bonding *bond, struct slave *slave) 2174 2203 { 2175 - struct net_device *upper, *vlan_upper; 2176 - struct list_head *iter, *vlan_iter; 2177 2204 struct rtable *rt; 2178 - struct bond_vlan_tag inner, outer; 2205 + struct bond_vlan_tag tags[BOND_MAX_VLAN_ENCAP]; 2179 2206 __be32 *targets = bond->params.arp_targets, addr; 2180 2207 int i; 2208 + bool ret; 2181 2209 2182 2210 for (i = 0; i < BOND_MAX_ARP_TARGETS && targets[i]; i++) { 2183 2211 pr_debug("basa: target %pI4\n", &targets[i]); 2184 - inner.vlan_proto = 0; 2185 - inner.vlan_id = 0; 2186 - outer.vlan_proto = 0; 2187 - outer.vlan_id = 0; 2212 + memset(tags, 0, sizeof(tags)); 2188 2213 2189 2214 /* Find out through which dev should the packet go */ 2190 2215 rt = ip_route_output(dev_net(bond->dev), targets[i], 0, ··· 2227 2192 net_warn_ratelimited("%s: no route to arp_ip_target %pI4 and arp_validate is set\n", 2228 2193 bond->dev->name, 2229 2194 &targets[i]); 2230 - bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i], 0, &inner, &outer); 2195 + bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i], 2196 + 0, tags); 2231 2197 continue; 2232 2198 } 2233 2199 ··· 2237 2201 goto found; 2238 2202 2239 2203 rcu_read_lock(); 2240 - /* first we search only for vlan devices. for every vlan 2241 - * found we verify its upper dev list, searching for the 2242 - * rt->dst.dev. If found we save the tag of the vlan and 2243 - * proceed to send the packet. 2244 - */ 2245 - netdev_for_each_all_upper_dev_rcu(bond->dev, vlan_upper, 2246 - vlan_iter) { 2247 - if (!is_vlan_dev(vlan_upper)) 2248 - continue; 2249 - 2250 - if (vlan_upper == rt->dst.dev) { 2251 - outer.vlan_proto = vlan_dev_vlan_proto(vlan_upper); 2252 - outer.vlan_id = vlan_dev_vlan_id(vlan_upper); 2253 - rcu_read_unlock(); 2254 - goto found; 2255 - } 2256 - netdev_for_each_all_upper_dev_rcu(vlan_upper, upper, 2257 - iter) { 2258 - if (upper == rt->dst.dev) { 2259 - /* If the upper dev is a vlan dev too, 2260 - * set the vlan tag to inner tag. 2261 - */ 2262 - if (is_vlan_dev(upper)) { 2263 - inner.vlan_proto = vlan_dev_vlan_proto(upper); 2264 - inner.vlan_id = vlan_dev_vlan_id(upper); 2265 - } 2266 - outer.vlan_proto = vlan_dev_vlan_proto(vlan_upper); 2267 - outer.vlan_id = vlan_dev_vlan_id(vlan_upper); 2268 - rcu_read_unlock(); 2269 - goto found; 2270 - } 2271 - } 2272 - } 2273 - 2274 - /* if the device we're looking for is not on top of any of 2275 - * our upper vlans, then just search for any dev that 2276 - * matches, and in case it's a vlan - save the id 2277 - */ 2278 - netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) { 2279 - if (upper == rt->dst.dev) { 2280 - rcu_read_unlock(); 2281 - goto found; 2282 - } 2283 - } 2204 + ret = bond_verify_device_path(bond->dev, rt->dst.dev, tags); 2284 2205 rcu_read_unlock(); 2206 + 2207 + if (ret) 2208 + goto found; 2285 2209 2286 2210 /* Not our device - skip */ 2287 2211 pr_debug("%s: no path to arp_ip_target %pI4 via rt.dev %s\n", ··· 2255 2259 addr = bond_confirm_addr(rt->dst.dev, targets[i], 0); 2256 2260 ip_rt_put(rt); 2257 2261 bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i], 2258 - addr, &inner, &outer); 2262 + addr, tags); 2259 2263 } 2260 2264 } 2261 2265
+1
drivers/net/bonding/bond_options.c
··· 125 125 static const struct bond_opt_value bond_intmax_tbl[] = { 126 126 { "off", 0, BOND_VALFLAG_DEFAULT}, 127 127 { "maxval", INT_MAX, BOND_VALFLAG_MAX}, 128 + { NULL, -1, 0} 128 129 }; 129 130 130 131 static const struct bond_opt_value bond_lacp_rate_tbl[] = {
+1
drivers/net/bonding/bonding.h
··· 36 36 37 37 #define bond_version DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n" 38 38 39 + #define BOND_MAX_VLAN_ENCAP 2 39 40 #define BOND_MAX_ARP_TARGETS 16 40 41 41 42 #define BOND_DEFAULT_MIIMON 100
-7
drivers/net/can/c_can/Kconfig
··· 14 14 SPEAr1310 and SPEAr320 evaluation boards & TI (www.ti.com) 15 15 boards like am335x, dm814x, dm813x and dm811x. 16 16 17 - config CAN_C_CAN_STRICT_FRAME_ORDERING 18 - bool "Force a strict RX CAN frame order (may cause frame loss)" 19 - ---help--- 20 - The RX split buffer prevents packet reordering but can cause packet 21 - loss. Only enable this option when you accept to lose CAN frames 22 - in favour of getting the received CAN frames in the correct order. 23 - 24 17 config CAN_C_CAN_PCI 25 18 tristate "Generic PCI Bus based C_CAN/D_CAN driver" 26 19 depends on PCI
-36
drivers/net/can/c_can/c_can.c
··· 732 732 static inline void c_can_rx_object_get(struct net_device *dev, 733 733 struct c_can_priv *priv, u32 obj) 734 734 { 735 - #ifdef CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING 736 - if (obj < C_CAN_MSG_RX_LOW_LAST) 737 - c_can_object_get(dev, IF_RX, obj, IF_COMM_RCV_LOW); 738 - else 739 - #endif 740 735 c_can_object_get(dev, IF_RX, obj, priv->comm_rcv_high); 741 736 } 742 737 743 738 static inline void c_can_rx_finalize(struct net_device *dev, 744 739 struct c_can_priv *priv, u32 obj) 745 740 { 746 - #ifdef CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING 747 - if (obj < C_CAN_MSG_RX_LOW_LAST) 748 - priv->rxmasked |= BIT(obj - 1); 749 - else if (obj == C_CAN_MSG_RX_LOW_LAST) { 750 - priv->rxmasked = 0; 751 - /* activate all lower message objects */ 752 - c_can_activate_all_lower_rx_msg_obj(dev, IF_RX); 753 - } 754 - #endif 755 741 if (priv->type != BOSCH_D_CAN) 756 742 c_can_object_get(dev, IF_RX, obj, IF_COMM_CLR_NEWDAT); 757 743 } ··· 785 799 { 786 800 u32 pend = priv->read_reg(priv, C_CAN_NEWDAT1_REG); 787 801 788 - #ifdef CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING 789 - pend &= ~priv->rxmasked; 790 - #endif 791 802 return pend; 792 803 } 793 804 ··· 796 813 * INTPND are set for this message object indicating that a new message 797 814 * has arrived. To work-around this issue, we keep two groups of message 798 815 * objects whose partitioning is defined by C_CAN_MSG_OBJ_RX_SPLIT. 799 - * 800 - * If CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING = y 801 - * 802 - * To ensure in-order frame reception we use the following 803 - * approach while re-activating a message object to receive further 804 - * frames: 805 - * - if the current message object number is lower than 806 - * C_CAN_MSG_RX_LOW_LAST, do not clear the NEWDAT bit while clearing 807 - * the INTPND bit. 808 - * - if the current message object number is equal to 809 - * C_CAN_MSG_RX_LOW_LAST then clear the NEWDAT bit of all lower 810 - * receive message objects. 811 - * - if the current message object number is greater than 812 - * C_CAN_MSG_RX_LOW_LAST then clear the NEWDAT bit of 813 - * only this message object. 814 - * 815 - * This can cause packet loss! 816 - * 817 - * If CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING = n 818 816 * 819 817 * We clear the newdat bit right away. 820 818 *
+9 -5
drivers/net/can/sja1000/peak_pci.c
··· 551 551 { 552 552 struct sja1000_priv *priv; 553 553 struct peak_pci_chan *chan; 554 - struct net_device *dev; 554 + struct net_device *dev, *prev_dev; 555 555 void __iomem *cfg_base, *reg_base; 556 556 u16 sub_sys_id, icr; 557 557 int i, err, channels; ··· 688 688 writew(0x0, cfg_base + PITA_ICR + 2); 689 689 690 690 chan = NULL; 691 - for (dev = pci_get_drvdata(pdev); dev; dev = chan->prev_dev) { 692 - unregister_sja1000dev(dev); 693 - free_sja1000dev(dev); 691 + for (dev = pci_get_drvdata(pdev); dev; dev = prev_dev) { 694 692 priv = netdev_priv(dev); 695 693 chan = priv->priv; 694 + prev_dev = chan->prev_dev; 695 + 696 + unregister_sja1000dev(dev); 697 + free_sja1000dev(dev); 696 698 } 697 699 698 700 /* free any PCIeC resources too */ ··· 728 726 729 727 /* Loop over all registered devices */ 730 728 while (1) { 729 + struct net_device *prev_dev = chan->prev_dev; 730 + 731 731 dev_info(&pdev->dev, "removing device %s\n", dev->name); 732 732 unregister_sja1000dev(dev); 733 733 free_sja1000dev(dev); 734 - dev = chan->prev_dev; 734 + dev = prev_dev; 735 735 736 736 if (!dev) { 737 737 /* do that only for first channel */
+12
drivers/net/ethernet/Kconfig
··· 35 35 source "drivers/net/ethernet/chelsio/Kconfig" 36 36 source "drivers/net/ethernet/cirrus/Kconfig" 37 37 source "drivers/net/ethernet/cisco/Kconfig" 38 + 39 + config CX_ECAT 40 + tristate "Beckhoff CX5020 EtherCAT master support" 41 + depends on PCI 42 + ---help--- 43 + Driver for EtherCAT master module located on CCAT FPGA 44 + that can be found on Beckhoff CX5020, and possibly other of CX 45 + Beckhoff CX series industrial PCs. 46 + 47 + To compile this driver as a module, choose M here. The module 48 + will be called ec_bhf. 49 + 38 50 source "drivers/net/ethernet/davicom/Kconfig" 39 51 40 52 config DNET
+1
drivers/net/ethernet/Makefile
··· 21 21 obj-$(CONFIG_NET_VENDOR_CHELSIO) += chelsio/ 22 22 obj-$(CONFIG_NET_VENDOR_CIRRUS) += cirrus/ 23 23 obj-$(CONFIG_NET_VENDOR_CISCO) += cisco/ 24 + obj-$(CONFIG_CX_ECAT) += ec_bhf.o 24 25 obj-$(CONFIG_DM9000) += davicom/ 25 26 obj-$(CONFIG_DNET) += dnet.o 26 27 obj-$(CONFIG_NET_VENDOR_DEC) += dec/
+1
drivers/net/ethernet/altera/Makefile
··· 5 5 obj-$(CONFIG_ALTERA_TSE) += altera_tse.o 6 6 altera_tse-objs := altera_tse_main.o altera_tse_ethtool.o \ 7 7 altera_msgdma.o altera_sgdma.o altera_utils.o 8 + ccflags-y += -D__CHECK_ENDIAN__
+54 -54
drivers/net/ethernet/altera/altera_msgdma.c
··· 37 37 void msgdma_reset(struct altera_tse_private *priv) 38 38 { 39 39 int counter; 40 - struct msgdma_csr *txcsr = 41 - (struct msgdma_csr *)priv->tx_dma_csr; 42 - struct msgdma_csr *rxcsr = 43 - (struct msgdma_csr *)priv->rx_dma_csr; 44 40 45 41 /* Reset Rx mSGDMA */ 46 - iowrite32(MSGDMA_CSR_STAT_MASK, &rxcsr->status); 47 - iowrite32(MSGDMA_CSR_CTL_RESET, &rxcsr->control); 42 + csrwr32(MSGDMA_CSR_STAT_MASK, priv->rx_dma_csr, 43 + msgdma_csroffs(status)); 44 + csrwr32(MSGDMA_CSR_CTL_RESET, priv->rx_dma_csr, 45 + msgdma_csroffs(control)); 48 46 49 47 counter = 0; 50 48 while (counter++ < ALTERA_TSE_SW_RESET_WATCHDOG_CNTR) { 51 - if (tse_bit_is_clear(&rxcsr->status, 49 + if (tse_bit_is_clear(priv->rx_dma_csr, msgdma_csroffs(status), 52 50 MSGDMA_CSR_STAT_RESETTING)) 53 51 break; 54 52 udelay(1); ··· 57 59 "TSE Rx mSGDMA resetting bit never cleared!\n"); 58 60 59 61 /* clear all status bits */ 60 - iowrite32(MSGDMA_CSR_STAT_MASK, &rxcsr->status); 62 + csrwr32(MSGDMA_CSR_STAT_MASK, priv->rx_dma_csr, msgdma_csroffs(status)); 61 63 62 64 /* Reset Tx mSGDMA */ 63 - iowrite32(MSGDMA_CSR_STAT_MASK, &txcsr->status); 64 - iowrite32(MSGDMA_CSR_CTL_RESET, &txcsr->control); 65 + csrwr32(MSGDMA_CSR_STAT_MASK, priv->tx_dma_csr, 66 + msgdma_csroffs(status)); 67 + 68 + csrwr32(MSGDMA_CSR_CTL_RESET, priv->tx_dma_csr, 69 + msgdma_csroffs(control)); 65 70 66 71 counter = 0; 67 72 while (counter++ < ALTERA_TSE_SW_RESET_WATCHDOG_CNTR) { 68 - if (tse_bit_is_clear(&txcsr->status, 73 + if (tse_bit_is_clear(priv->tx_dma_csr, msgdma_csroffs(status), 69 74 MSGDMA_CSR_STAT_RESETTING)) 70 75 break; 71 76 udelay(1); ··· 79 78 "TSE Tx mSGDMA resetting bit never cleared!\n"); 80 79 81 80 /* clear all status bits */ 82 - iowrite32(MSGDMA_CSR_STAT_MASK, &txcsr->status); 81 + csrwr32(MSGDMA_CSR_STAT_MASK, priv->tx_dma_csr, msgdma_csroffs(status)); 83 82 } 84 83 85 84 void msgdma_disable_rxirq(struct altera_tse_private *priv) 86 85 { 87 - struct msgdma_csr *csr = priv->rx_dma_csr; 88 - tse_clear_bit(&csr->control, MSGDMA_CSR_CTL_GLOBAL_INTR); 86 + tse_clear_bit(priv->rx_dma_csr, msgdma_csroffs(control), 87 + MSGDMA_CSR_CTL_GLOBAL_INTR); 89 88 } 90 89 91 90 void msgdma_enable_rxirq(struct altera_tse_private *priv) 92 91 { 93 - struct msgdma_csr *csr = priv->rx_dma_csr; 94 - tse_set_bit(&csr->control, MSGDMA_CSR_CTL_GLOBAL_INTR); 92 + tse_set_bit(priv->rx_dma_csr, msgdma_csroffs(control), 93 + MSGDMA_CSR_CTL_GLOBAL_INTR); 95 94 } 96 95 97 96 void msgdma_disable_txirq(struct altera_tse_private *priv) 98 97 { 99 - struct msgdma_csr *csr = priv->tx_dma_csr; 100 - tse_clear_bit(&csr->control, MSGDMA_CSR_CTL_GLOBAL_INTR); 98 + tse_clear_bit(priv->tx_dma_csr, msgdma_csroffs(control), 99 + MSGDMA_CSR_CTL_GLOBAL_INTR); 101 100 } 102 101 103 102 void msgdma_enable_txirq(struct altera_tse_private *priv) 104 103 { 105 - struct msgdma_csr *csr = priv->tx_dma_csr; 106 - tse_set_bit(&csr->control, MSGDMA_CSR_CTL_GLOBAL_INTR); 104 + tse_set_bit(priv->tx_dma_csr, msgdma_csroffs(control), 105 + MSGDMA_CSR_CTL_GLOBAL_INTR); 107 106 } 108 107 109 108 void msgdma_clear_rxirq(struct altera_tse_private *priv) 110 109 { 111 - struct msgdma_csr *csr = priv->rx_dma_csr; 112 - iowrite32(MSGDMA_CSR_STAT_IRQ, &csr->status); 110 + csrwr32(MSGDMA_CSR_STAT_IRQ, priv->rx_dma_csr, msgdma_csroffs(status)); 113 111 } 114 112 115 113 void msgdma_clear_txirq(struct altera_tse_private *priv) 116 114 { 117 - struct msgdma_csr *csr = priv->tx_dma_csr; 118 - iowrite32(MSGDMA_CSR_STAT_IRQ, &csr->status); 115 + csrwr32(MSGDMA_CSR_STAT_IRQ, priv->tx_dma_csr, msgdma_csroffs(status)); 119 116 } 120 117 121 118 /* return 0 to indicate transmit is pending */ 122 119 int msgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer) 123 120 { 124 - struct msgdma_extended_desc *desc = priv->tx_dma_desc; 125 - 126 - iowrite32(lower_32_bits(buffer->dma_addr), &desc->read_addr_lo); 127 - iowrite32(upper_32_bits(buffer->dma_addr), &desc->read_addr_hi); 128 - iowrite32(0, &desc->write_addr_lo); 129 - iowrite32(0, &desc->write_addr_hi); 130 - iowrite32(buffer->len, &desc->len); 131 - iowrite32(0, &desc->burst_seq_num); 132 - iowrite32(MSGDMA_DESC_TX_STRIDE, &desc->stride); 133 - iowrite32(MSGDMA_DESC_CTL_TX_SINGLE, &desc->control); 121 + csrwr32(lower_32_bits(buffer->dma_addr), priv->tx_dma_desc, 122 + msgdma_descroffs(read_addr_lo)); 123 + csrwr32(upper_32_bits(buffer->dma_addr), priv->tx_dma_desc, 124 + msgdma_descroffs(read_addr_hi)); 125 + csrwr32(0, priv->tx_dma_desc, msgdma_descroffs(write_addr_lo)); 126 + csrwr32(0, priv->tx_dma_desc, msgdma_descroffs(write_addr_hi)); 127 + csrwr32(buffer->len, priv->tx_dma_desc, msgdma_descroffs(len)); 128 + csrwr32(0, priv->tx_dma_desc, msgdma_descroffs(burst_seq_num)); 129 + csrwr32(MSGDMA_DESC_TX_STRIDE, priv->tx_dma_desc, 130 + msgdma_descroffs(stride)); 131 + csrwr32(MSGDMA_DESC_CTL_TX_SINGLE, priv->tx_dma_desc, 132 + msgdma_descroffs(control)); 134 133 return 0; 135 134 } 136 135 ··· 139 138 u32 ready = 0; 140 139 u32 inuse; 141 140 u32 status; 142 - struct msgdma_csr *txcsr = 143 - (struct msgdma_csr *)priv->tx_dma_csr; 144 141 145 142 /* Get number of sent descriptors */ 146 - inuse = ioread32(&txcsr->rw_fill_level) & 0xffff; 143 + inuse = csrrd32(priv->tx_dma_csr, msgdma_csroffs(rw_fill_level)) 144 + & 0xffff; 147 145 148 146 if (inuse) { /* Tx FIFO is not empty */ 149 147 ready = priv->tx_prod - priv->tx_cons - inuse - 1; 150 148 } else { 151 149 /* Check for buffered last packet */ 152 - status = ioread32(&txcsr->status); 150 + status = csrrd32(priv->tx_dma_csr, msgdma_csroffs(status)); 153 151 if (status & MSGDMA_CSR_STAT_BUSY) 154 152 ready = priv->tx_prod - priv->tx_cons - 1; 155 153 else ··· 162 162 void msgdma_add_rx_desc(struct altera_tse_private *priv, 163 163 struct tse_buffer *rxbuffer) 164 164 { 165 - struct msgdma_extended_desc *desc = priv->rx_dma_desc; 166 165 u32 len = priv->rx_dma_buf_sz; 167 166 dma_addr_t dma_addr = rxbuffer->dma_addr; 168 167 u32 control = (MSGDMA_DESC_CTL_END_ON_EOP ··· 171 172 | MSGDMA_DESC_CTL_TR_ERR_IRQ 172 173 | MSGDMA_DESC_CTL_GO); 173 174 174 - iowrite32(0, &desc->read_addr_lo); 175 - iowrite32(0, &desc->read_addr_hi); 176 - iowrite32(lower_32_bits(dma_addr), &desc->write_addr_lo); 177 - iowrite32(upper_32_bits(dma_addr), &desc->write_addr_hi); 178 - iowrite32(len, &desc->len); 179 - iowrite32(0, &desc->burst_seq_num); 180 - iowrite32(0x00010001, &desc->stride); 181 - iowrite32(control, &desc->control); 175 + csrwr32(0, priv->rx_dma_desc, msgdma_descroffs(read_addr_lo)); 176 + csrwr32(0, priv->rx_dma_desc, msgdma_descroffs(read_addr_hi)); 177 + csrwr32(lower_32_bits(dma_addr), priv->rx_dma_desc, 178 + msgdma_descroffs(write_addr_lo)); 179 + csrwr32(upper_32_bits(dma_addr), priv->rx_dma_desc, 180 + msgdma_descroffs(write_addr_hi)); 181 + csrwr32(len, priv->rx_dma_desc, msgdma_descroffs(len)); 182 + csrwr32(0, priv->rx_dma_desc, msgdma_descroffs(burst_seq_num)); 183 + csrwr32(0x00010001, priv->rx_dma_desc, msgdma_descroffs(stride)); 184 + csrwr32(control, priv->rx_dma_desc, msgdma_descroffs(control)); 182 185 } 183 186 184 187 /* status is returned on upper 16 bits, ··· 191 190 u32 rxstatus = 0; 192 191 u32 pktlength; 193 192 u32 pktstatus; 194 - struct msgdma_csr *rxcsr = 195 - (struct msgdma_csr *)priv->rx_dma_csr; 196 - struct msgdma_response *rxresp = 197 - (struct msgdma_response *)priv->rx_dma_resp; 198 193 199 - if (ioread32(&rxcsr->resp_fill_level) & 0xffff) { 200 - pktlength = ioread32(&rxresp->bytes_transferred); 201 - pktstatus = ioread32(&rxresp->status); 194 + if (csrrd32(priv->rx_dma_csr, msgdma_csroffs(resp_fill_level)) 195 + & 0xffff) { 196 + pktlength = csrrd32(priv->rx_dma_resp, 197 + msgdma_respoffs(bytes_transferred)); 198 + pktstatus = csrrd32(priv->rx_dma_resp, 199 + msgdma_respoffs(status)); 202 200 rxstatus = pktstatus; 203 201 rxstatus = rxstatus << 16; 204 202 rxstatus |= (pktlength & 0xffff);
+4 -9
drivers/net/ethernet/altera/altera_msgdmahw.h
··· 17 17 #ifndef __ALTERA_MSGDMAHW_H__ 18 18 #define __ALTERA_MSGDMAHW_H__ 19 19 20 - /* mSGDMA standard descriptor format 21 - */ 22 - struct msgdma_desc { 23 - u32 read_addr; /* data buffer source address */ 24 - u32 write_addr; /* data buffer destination address */ 25 - u32 len; /* the number of bytes to transfer per descriptor */ 26 - u32 control; /* characteristics of the transfer */ 27 - }; 28 - 29 20 /* mSGDMA extended descriptor format 30 21 */ 31 22 struct msgdma_extended_desc { ··· 149 158 u32 bytes_transferred; 150 159 u32 status; 151 160 }; 161 + 162 + #define msgdma_respoffs(a) (offsetof(struct msgdma_response, a)) 163 + #define msgdma_csroffs(a) (offsetof(struct msgdma_csr, a)) 164 + #define msgdma_descroffs(a) (offsetof(struct msgdma_extended_desc, a)) 152 165 153 166 /* mSGDMA response register bit definitions 154 167 */
+90 -91
drivers/net/ethernet/altera/altera_sgdma.c
··· 20 20 #include "altera_sgdmahw.h" 21 21 #include "altera_sgdma.h" 22 22 23 - static void sgdma_setup_descrip(struct sgdma_descrip *desc, 24 - struct sgdma_descrip *ndesc, 23 + static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc, 24 + struct sgdma_descrip __iomem *ndesc, 25 25 dma_addr_t ndesc_phys, 26 26 dma_addr_t raddr, 27 27 dma_addr_t waddr, ··· 31 31 int wfixed); 32 32 33 33 static int sgdma_async_write(struct altera_tse_private *priv, 34 - struct sgdma_descrip *desc); 34 + struct sgdma_descrip __iomem *desc); 35 35 36 36 static int sgdma_async_read(struct altera_tse_private *priv); 37 37 38 38 static dma_addr_t 39 39 sgdma_txphysaddr(struct altera_tse_private *priv, 40 - struct sgdma_descrip *desc); 40 + struct sgdma_descrip __iomem *desc); 41 41 42 42 static dma_addr_t 43 43 sgdma_rxphysaddr(struct altera_tse_private *priv, 44 - struct sgdma_descrip *desc); 44 + struct sgdma_descrip __iomem *desc); 45 45 46 46 static int sgdma_txbusy(struct altera_tse_private *priv); 47 47 ··· 79 79 priv->rxdescphys = (dma_addr_t) 0; 80 80 priv->txdescphys = (dma_addr_t) 0; 81 81 82 - priv->rxdescphys = dma_map_single(priv->device, priv->rx_dma_desc, 82 + priv->rxdescphys = dma_map_single(priv->device, 83 + (void __force *)priv->rx_dma_desc, 83 84 priv->rxdescmem, DMA_BIDIRECTIONAL); 84 85 85 86 if (dma_mapping_error(priv->device, priv->rxdescphys)) { ··· 89 88 return -EINVAL; 90 89 } 91 90 92 - priv->txdescphys = dma_map_single(priv->device, priv->tx_dma_desc, 91 + priv->txdescphys = dma_map_single(priv->device, 92 + (void __force *)priv->tx_dma_desc, 93 93 priv->txdescmem, DMA_TO_DEVICE); 94 94 95 95 if (dma_mapping_error(priv->device, priv->txdescphys)) { ··· 100 98 } 101 99 102 100 /* Initialize descriptor memory to all 0's, sync memory to cache */ 103 - memset(priv->tx_dma_desc, 0, priv->txdescmem); 104 - memset(priv->rx_dma_desc, 0, priv->rxdescmem); 101 + memset_io(priv->tx_dma_desc, 0, priv->txdescmem); 102 + memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); 105 103 106 104 dma_sync_single_for_device(priv->device, priv->txdescphys, 107 105 priv->txdescmem, DMA_TO_DEVICE); ··· 128 126 */ 129 127 void sgdma_reset(struct altera_tse_private *priv) 130 128 { 131 - u32 *ptxdescripmem = (u32 *)priv->tx_dma_desc; 132 - u32 txdescriplen = priv->txdescmem; 133 - u32 *prxdescripmem = (u32 *)priv->rx_dma_desc; 134 - u32 rxdescriplen = priv->rxdescmem; 135 - struct sgdma_csr *ptxsgdma = (struct sgdma_csr *)priv->tx_dma_csr; 136 - struct sgdma_csr *prxsgdma = (struct sgdma_csr *)priv->rx_dma_csr; 137 - 138 129 /* Initialize descriptor memory to 0 */ 139 - memset(ptxdescripmem, 0, txdescriplen); 140 - memset(prxdescripmem, 0, rxdescriplen); 130 + memset_io(priv->tx_dma_desc, 0, priv->txdescmem); 131 + memset_io(priv->rx_dma_desc, 0, priv->rxdescmem); 141 132 142 - iowrite32(SGDMA_CTRLREG_RESET, &ptxsgdma->control); 143 - iowrite32(0, &ptxsgdma->control); 133 + csrwr32(SGDMA_CTRLREG_RESET, priv->tx_dma_csr, sgdma_csroffs(control)); 134 + csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); 144 135 145 - iowrite32(SGDMA_CTRLREG_RESET, &prxsgdma->control); 146 - iowrite32(0, &prxsgdma->control); 136 + csrwr32(SGDMA_CTRLREG_RESET, priv->rx_dma_csr, sgdma_csroffs(control)); 137 + csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); 147 138 } 148 139 149 140 /* For SGDMA, interrupts remain enabled after initially enabling, ··· 162 167 163 168 void sgdma_clear_rxirq(struct altera_tse_private *priv) 164 169 { 165 - struct sgdma_csr *csr = (struct sgdma_csr *)priv->rx_dma_csr; 166 - tse_set_bit(&csr->control, SGDMA_CTRLREG_CLRINT); 170 + tse_set_bit(priv->rx_dma_csr, sgdma_csroffs(control), 171 + SGDMA_CTRLREG_CLRINT); 167 172 } 168 173 169 174 void sgdma_clear_txirq(struct altera_tse_private *priv) 170 175 { 171 - struct sgdma_csr *csr = (struct sgdma_csr *)priv->tx_dma_csr; 172 - tse_set_bit(&csr->control, SGDMA_CTRLREG_CLRINT); 176 + tse_set_bit(priv->tx_dma_csr, sgdma_csroffs(control), 177 + SGDMA_CTRLREG_CLRINT); 173 178 } 174 179 175 180 /* transmits buffer through SGDMA. Returns number of buffers ··· 179 184 */ 180 185 int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer) 181 186 { 182 - int pktstx = 0; 183 - struct sgdma_descrip *descbase = 184 - (struct sgdma_descrip *)priv->tx_dma_desc; 187 + struct sgdma_descrip __iomem *descbase = 188 + (struct sgdma_descrip __iomem *)priv->tx_dma_desc; 185 189 186 - struct sgdma_descrip *cdesc = &descbase[0]; 187 - struct sgdma_descrip *ndesc = &descbase[1]; 190 + struct sgdma_descrip __iomem *cdesc = &descbase[0]; 191 + struct sgdma_descrip __iomem *ndesc = &descbase[1]; 188 192 189 193 /* wait 'til the tx sgdma is ready for the next transmit request */ 190 194 if (sgdma_txbusy(priv)) ··· 199 205 0, /* read fixed */ 200 206 SGDMA_CONTROL_WR_FIXED); /* Generate SOP */ 201 207 202 - pktstx = sgdma_async_write(priv, cdesc); 208 + sgdma_async_write(priv, cdesc); 203 209 204 210 /* enqueue the request to the pending transmit queue */ 205 211 queue_tx(priv, buffer); ··· 213 219 u32 sgdma_tx_completions(struct altera_tse_private *priv) 214 220 { 215 221 u32 ready = 0; 216 - struct sgdma_descrip *desc = (struct sgdma_descrip *)priv->tx_dma_desc; 217 222 218 223 if (!sgdma_txbusy(priv) && 219 - ((desc->control & SGDMA_CONTROL_HW_OWNED) == 0) && 224 + ((csrrd8(priv->tx_dma_desc, sgdma_descroffs(control)) 225 + & SGDMA_CONTROL_HW_OWNED) == 0) && 220 226 (dequeue_tx(priv))) { 221 227 ready = 1; 222 228 } ··· 240 246 */ 241 247 u32 sgdma_rx_status(struct altera_tse_private *priv) 242 248 { 243 - struct sgdma_csr *csr = (struct sgdma_csr *)priv->rx_dma_csr; 244 - struct sgdma_descrip *base = (struct sgdma_descrip *)priv->rx_dma_desc; 245 - struct sgdma_descrip *desc = NULL; 246 - int pktsrx; 247 - unsigned int rxstatus = 0; 248 - unsigned int pktlength = 0; 249 - unsigned int pktstatus = 0; 249 + struct sgdma_descrip __iomem *base = 250 + (struct sgdma_descrip __iomem *)priv->rx_dma_desc; 251 + struct sgdma_descrip __iomem *desc = NULL; 250 252 struct tse_buffer *rxbuffer = NULL; 253 + unsigned int rxstatus = 0; 251 254 252 - u32 sts = ioread32(&csr->status); 255 + u32 sts = csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)); 253 256 254 257 desc = &base[0]; 255 258 if (sts & SGDMA_STSREG_EOP) { 259 + unsigned int pktlength = 0; 260 + unsigned int pktstatus = 0; 256 261 dma_sync_single_for_cpu(priv->device, 257 262 priv->rxdescphys, 258 263 priv->sgdmadesclen, 259 264 DMA_FROM_DEVICE); 260 265 261 - pktlength = desc->bytes_xferred; 262 - pktstatus = desc->status & 0x3f; 263 - rxstatus = pktstatus; 266 + pktlength = csrrd16(desc, sgdma_descroffs(bytes_xferred)); 267 + pktstatus = csrrd8(desc, sgdma_descroffs(status)); 268 + rxstatus = pktstatus & ~SGDMA_STATUS_EOP; 264 269 rxstatus = rxstatus << 16; 265 270 rxstatus |= (pktlength & 0xffff); 266 271 267 272 if (rxstatus) { 268 - desc->status = 0; 273 + csrwr8(0, desc, sgdma_descroffs(status)); 269 274 270 275 rxbuffer = dequeue_rx(priv); 271 276 if (rxbuffer == NULL) ··· 272 279 "sgdma rx and rx queue empty!\n"); 273 280 274 281 /* Clear control */ 275 - iowrite32(0, &csr->control); 282 + csrwr32(0, priv->rx_dma_csr, sgdma_csroffs(control)); 276 283 /* clear status */ 277 - iowrite32(0xf, &csr->status); 284 + csrwr32(0xf, priv->rx_dma_csr, sgdma_csroffs(status)); 278 285 279 286 /* kick the rx sgdma after reaping this descriptor */ 280 - pktsrx = sgdma_async_read(priv); 287 + sgdma_async_read(priv); 281 288 282 289 } else { 283 290 /* If the SGDMA indicated an end of packet on recv, ··· 291 298 */ 292 299 netdev_err(priv->dev, 293 300 "SGDMA RX Error Info: %x, %x, %x\n", 294 - sts, desc->status, rxstatus); 301 + sts, csrrd8(desc, sgdma_descroffs(status)), 302 + rxstatus); 295 303 } 296 304 } else if (sts == 0) { 297 - pktsrx = sgdma_async_read(priv); 305 + sgdma_async_read(priv); 298 306 } 299 307 300 308 return rxstatus; ··· 303 309 304 310 305 311 /* Private functions */ 306 - static void sgdma_setup_descrip(struct sgdma_descrip *desc, 307 - struct sgdma_descrip *ndesc, 312 + static void sgdma_setup_descrip(struct sgdma_descrip __iomem *desc, 313 + struct sgdma_descrip __iomem *ndesc, 308 314 dma_addr_t ndesc_phys, 309 315 dma_addr_t raddr, 310 316 dma_addr_t waddr, ··· 314 320 int wfixed) 315 321 { 316 322 /* Clear the next descriptor as not owned by hardware */ 317 - u32 ctrl = ndesc->control; 318 - ctrl &= ~SGDMA_CONTROL_HW_OWNED; 319 - ndesc->control = ctrl; 320 323 321 - ctrl = 0; 324 + u32 ctrl = csrrd8(ndesc, sgdma_descroffs(control)); 325 + ctrl &= ~SGDMA_CONTROL_HW_OWNED; 326 + csrwr8(ctrl, ndesc, sgdma_descroffs(control)); 327 + 322 328 ctrl = SGDMA_CONTROL_HW_OWNED; 323 329 ctrl |= generate_eop; 324 330 ctrl |= rfixed; 325 331 ctrl |= wfixed; 326 332 327 333 /* Channel is implicitly zero, initialized to 0 by default */ 334 + csrwr32(lower_32_bits(raddr), desc, sgdma_descroffs(raddr)); 335 + csrwr32(lower_32_bits(waddr), desc, sgdma_descroffs(waddr)); 328 336 329 - desc->raddr = raddr; 330 - desc->waddr = waddr; 331 - desc->next = lower_32_bits(ndesc_phys); 332 - desc->control = ctrl; 333 - desc->status = 0; 334 - desc->rburst = 0; 335 - desc->wburst = 0; 336 - desc->bytes = length; 337 - desc->bytes_xferred = 0; 337 + csrwr32(0, desc, sgdma_descroffs(pad1)); 338 + csrwr32(0, desc, sgdma_descroffs(pad2)); 339 + csrwr32(lower_32_bits(ndesc_phys), desc, sgdma_descroffs(next)); 340 + 341 + csrwr8(ctrl, desc, sgdma_descroffs(control)); 342 + csrwr8(0, desc, sgdma_descroffs(status)); 343 + csrwr8(0, desc, sgdma_descroffs(wburst)); 344 + csrwr8(0, desc, sgdma_descroffs(rburst)); 345 + csrwr16(length, desc, sgdma_descroffs(bytes)); 346 + csrwr16(0, desc, sgdma_descroffs(bytes_xferred)); 338 347 } 339 348 340 349 /* If hardware is busy, don't restart async read. ··· 348 351 */ 349 352 static int sgdma_async_read(struct altera_tse_private *priv) 350 353 { 351 - struct sgdma_csr *csr = (struct sgdma_csr *)priv->rx_dma_csr; 352 - struct sgdma_descrip *descbase = 353 - (struct sgdma_descrip *)priv->rx_dma_desc; 354 + struct sgdma_descrip __iomem *descbase = 355 + (struct sgdma_descrip __iomem *)priv->rx_dma_desc; 354 356 355 - struct sgdma_descrip *cdesc = &descbase[0]; 356 - struct sgdma_descrip *ndesc = &descbase[1]; 357 + struct sgdma_descrip __iomem *cdesc = &descbase[0]; 358 + struct sgdma_descrip __iomem *ndesc = &descbase[1]; 357 359 358 360 struct tse_buffer *rxbuffer = NULL; 359 361 ··· 378 382 priv->sgdmadesclen, 379 383 DMA_TO_DEVICE); 380 384 381 - iowrite32(lower_32_bits(sgdma_rxphysaddr(priv, cdesc)), 382 - &csr->next_descrip); 385 + csrwr32(lower_32_bits(sgdma_rxphysaddr(priv, cdesc)), 386 + priv->rx_dma_csr, 387 + sgdma_csroffs(next_descrip)); 383 388 384 - iowrite32((priv->rxctrlreg | SGDMA_CTRLREG_START), 385 - &csr->control); 389 + csrwr32((priv->rxctrlreg | SGDMA_CTRLREG_START), 390 + priv->rx_dma_csr, 391 + sgdma_csroffs(control)); 386 392 387 393 return 1; 388 394 } ··· 393 395 } 394 396 395 397 static int sgdma_async_write(struct altera_tse_private *priv, 396 - struct sgdma_descrip *desc) 398 + struct sgdma_descrip __iomem *desc) 397 399 { 398 - struct sgdma_csr *csr = (struct sgdma_csr *)priv->tx_dma_csr; 399 - 400 400 if (sgdma_txbusy(priv)) 401 401 return 0; 402 402 403 403 /* clear control and status */ 404 - iowrite32(0, &csr->control); 405 - iowrite32(0x1f, &csr->status); 404 + csrwr32(0, priv->tx_dma_csr, sgdma_csroffs(control)); 405 + csrwr32(0x1f, priv->tx_dma_csr, sgdma_csroffs(status)); 406 406 407 407 dma_sync_single_for_device(priv->device, priv->txdescphys, 408 408 priv->sgdmadesclen, DMA_TO_DEVICE); 409 409 410 - iowrite32(lower_32_bits(sgdma_txphysaddr(priv, desc)), 411 - &csr->next_descrip); 410 + csrwr32(lower_32_bits(sgdma_txphysaddr(priv, desc)), 411 + priv->tx_dma_csr, 412 + sgdma_csroffs(next_descrip)); 412 413 413 - iowrite32((priv->txctrlreg | SGDMA_CTRLREG_START), 414 - &csr->control); 414 + csrwr32((priv->txctrlreg | SGDMA_CTRLREG_START), 415 + priv->tx_dma_csr, 416 + sgdma_csroffs(control)); 415 417 416 418 return 1; 417 419 } 418 420 419 421 static dma_addr_t 420 422 sgdma_txphysaddr(struct altera_tse_private *priv, 421 - struct sgdma_descrip *desc) 423 + struct sgdma_descrip __iomem *desc) 422 424 { 423 425 dma_addr_t paddr = priv->txdescmem_busaddr; 424 426 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->tx_dma_desc; ··· 427 429 428 430 static dma_addr_t 429 431 sgdma_rxphysaddr(struct altera_tse_private *priv, 430 - struct sgdma_descrip *desc) 432 + struct sgdma_descrip __iomem *desc) 431 433 { 432 434 dma_addr_t paddr = priv->rxdescmem_busaddr; 433 435 uintptr_t offs = (uintptr_t)desc - (uintptr_t)priv->rx_dma_desc; ··· 516 518 */ 517 519 static int sgdma_rxbusy(struct altera_tse_private *priv) 518 520 { 519 - struct sgdma_csr *csr = (struct sgdma_csr *)priv->rx_dma_csr; 520 - return ioread32(&csr->status) & SGDMA_STSREG_BUSY; 521 + return csrrd32(priv->rx_dma_csr, sgdma_csroffs(status)) 522 + & SGDMA_STSREG_BUSY; 521 523 } 522 524 523 525 /* waits for the tx sgdma to finish it's current operation, returns 0 ··· 526 528 static int sgdma_txbusy(struct altera_tse_private *priv) 527 529 { 528 530 int delay = 0; 529 - struct sgdma_csr *csr = (struct sgdma_csr *)priv->tx_dma_csr; 530 531 531 532 /* if DMA is busy, wait for current transactino to finish */ 532 - while ((ioread32(&csr->status) & SGDMA_STSREG_BUSY) && (delay++ < 100)) 533 + while ((csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) 534 + & SGDMA_STSREG_BUSY) && (delay++ < 100)) 533 535 udelay(1); 534 536 535 - if (ioread32(&csr->status) & SGDMA_STSREG_BUSY) { 537 + if (csrrd32(priv->tx_dma_csr, sgdma_csroffs(status)) 538 + & SGDMA_STSREG_BUSY) { 536 539 netdev_err(priv->dev, "timeout waiting for tx dma\n"); 537 540 return 1; 538 541 }
+14 -12
drivers/net/ethernet/altera/altera_sgdmahw.h
··· 19 19 20 20 /* SGDMA descriptor structure */ 21 21 struct sgdma_descrip { 22 - unsigned int raddr; /* address of data to be read */ 23 - unsigned int pad1; 24 - unsigned int waddr; 25 - unsigned int pad2; 26 - unsigned int next; 27 - unsigned int pad3; 28 - unsigned short bytes; 29 - unsigned char rburst; 30 - unsigned char wburst; 31 - unsigned short bytes_xferred; /* 16 bits, bytes xferred */ 22 + u32 raddr; /* address of data to be read */ 23 + u32 pad1; 24 + u32 waddr; 25 + u32 pad2; 26 + u32 next; 27 + u32 pad3; 28 + u16 bytes; 29 + u8 rburst; 30 + u8 wburst; 31 + u16 bytes_xferred; /* 16 bits, bytes xferred */ 32 32 33 33 /* bit 0: error 34 34 * bit 1: length error ··· 39 39 * bit 6: reserved 40 40 * bit 7: status eop for recv case 41 41 */ 42 - unsigned char status; 42 + u8 status; 43 43 44 44 /* bit 0: eop 45 45 * bit 1: read_fixed ··· 47 47 * bits 3,4,5,6: Channel (always 0) 48 48 * bit 7: hardware owned 49 49 */ 50 - unsigned char control; 50 + u8 control; 51 51 } __packed; 52 52 53 53 ··· 101 101 u32 pad3[3]; 102 102 }; 103 103 104 + #define sgdma_csroffs(a) (offsetof(struct sgdma_csr, a)) 105 + #define sgdma_descroffs(a) (offsetof(struct sgdma_descrip, a)) 104 106 105 107 #define SGDMA_STSREG_ERR BIT(0) /* Error */ 106 108 #define SGDMA_STSREG_EOP BIT(1) /* EOP */
+47
drivers/net/ethernet/altera/altera_tse.h
··· 357 357 u32 reserved5[42]; 358 358 }; 359 359 360 + #define tse_csroffs(a) (offsetof(struct altera_tse_mac, a)) 361 + 360 362 /* Transmit and Receive Command Registers Bit Definitions 361 363 */ 362 364 #define ALTERA_TSE_TX_CMD_STAT_OMIT_CRC BIT(17) ··· 488 486 /* Function prototypes 489 487 */ 490 488 void altera_tse_set_ethtool_ops(struct net_device *); 489 + 490 + static inline 491 + u32 csrrd32(void __iomem *mac, size_t offs) 492 + { 493 + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); 494 + return readl(paddr); 495 + } 496 + 497 + static inline 498 + u16 csrrd16(void __iomem *mac, size_t offs) 499 + { 500 + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); 501 + return readw(paddr); 502 + } 503 + 504 + static inline 505 + u8 csrrd8(void __iomem *mac, size_t offs) 506 + { 507 + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); 508 + return readb(paddr); 509 + } 510 + 511 + static inline 512 + void csrwr32(u32 val, void __iomem *mac, size_t offs) 513 + { 514 + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); 515 + 516 + writel(val, paddr); 517 + } 518 + 519 + static inline 520 + void csrwr16(u16 val, void __iomem *mac, size_t offs) 521 + { 522 + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); 523 + 524 + writew(val, paddr); 525 + } 526 + 527 + static inline 528 + void csrwr8(u8 val, void __iomem *mac, size_t offs) 529 + { 530 + void __iomem *paddr = (void __iomem *)((uintptr_t)mac + offs); 531 + 532 + writeb(val, paddr); 533 + } 491 534 492 535 #endif /* __ALTERA_TSE_H__ */
+71 -37
drivers/net/ethernet/altera/altera_tse_ethtool.c
··· 96 96 u64 *buf) 97 97 { 98 98 struct altera_tse_private *priv = netdev_priv(dev); 99 - struct altera_tse_mac *mac = priv->mac_dev; 100 99 u64 ext; 101 100 102 - buf[0] = ioread32(&mac->frames_transmitted_ok); 103 - buf[1] = ioread32(&mac->frames_received_ok); 104 - buf[2] = ioread32(&mac->frames_check_sequence_errors); 105 - buf[3] = ioread32(&mac->alignment_errors); 101 + buf[0] = csrrd32(priv->mac_dev, 102 + tse_csroffs(frames_transmitted_ok)); 103 + buf[1] = csrrd32(priv->mac_dev, 104 + tse_csroffs(frames_received_ok)); 105 + buf[2] = csrrd32(priv->mac_dev, 106 + tse_csroffs(frames_check_sequence_errors)); 107 + buf[3] = csrrd32(priv->mac_dev, 108 + tse_csroffs(alignment_errors)); 106 109 107 110 /* Extended aOctetsTransmittedOK counter */ 108 - ext = (u64) ioread32(&mac->msb_octets_transmitted_ok) << 32; 109 - ext |= ioread32(&mac->octets_transmitted_ok); 111 + ext = (u64) csrrd32(priv->mac_dev, 112 + tse_csroffs(msb_octets_transmitted_ok)) << 32; 113 + 114 + ext |= csrrd32(priv->mac_dev, 115 + tse_csroffs(octets_transmitted_ok)); 110 116 buf[4] = ext; 111 117 112 118 /* Extended aOctetsReceivedOK counter */ 113 - ext = (u64) ioread32(&mac->msb_octets_received_ok) << 32; 114 - ext |= ioread32(&mac->octets_received_ok); 119 + ext = (u64) csrrd32(priv->mac_dev, 120 + tse_csroffs(msb_octets_received_ok)) << 32; 121 + 122 + ext |= csrrd32(priv->mac_dev, 123 + tse_csroffs(octets_received_ok)); 115 124 buf[5] = ext; 116 125 117 - buf[6] = ioread32(&mac->tx_pause_mac_ctrl_frames); 118 - buf[7] = ioread32(&mac->rx_pause_mac_ctrl_frames); 119 - buf[8] = ioread32(&mac->if_in_errors); 120 - buf[9] = ioread32(&mac->if_out_errors); 121 - buf[10] = ioread32(&mac->if_in_ucast_pkts); 122 - buf[11] = ioread32(&mac->if_in_multicast_pkts); 123 - buf[12] = ioread32(&mac->if_in_broadcast_pkts); 124 - buf[13] = ioread32(&mac->if_out_discards); 125 - buf[14] = ioread32(&mac->if_out_ucast_pkts); 126 - buf[15] = ioread32(&mac->if_out_multicast_pkts); 127 - buf[16] = ioread32(&mac->if_out_broadcast_pkts); 128 - buf[17] = ioread32(&mac->ether_stats_drop_events); 126 + buf[6] = csrrd32(priv->mac_dev, 127 + tse_csroffs(tx_pause_mac_ctrl_frames)); 128 + buf[7] = csrrd32(priv->mac_dev, 129 + tse_csroffs(rx_pause_mac_ctrl_frames)); 130 + buf[8] = csrrd32(priv->mac_dev, 131 + tse_csroffs(if_in_errors)); 132 + buf[9] = csrrd32(priv->mac_dev, 133 + tse_csroffs(if_out_errors)); 134 + buf[10] = csrrd32(priv->mac_dev, 135 + tse_csroffs(if_in_ucast_pkts)); 136 + buf[11] = csrrd32(priv->mac_dev, 137 + tse_csroffs(if_in_multicast_pkts)); 138 + buf[12] = csrrd32(priv->mac_dev, 139 + tse_csroffs(if_in_broadcast_pkts)); 140 + buf[13] = csrrd32(priv->mac_dev, 141 + tse_csroffs(if_out_discards)); 142 + buf[14] = csrrd32(priv->mac_dev, 143 + tse_csroffs(if_out_ucast_pkts)); 144 + buf[15] = csrrd32(priv->mac_dev, 145 + tse_csroffs(if_out_multicast_pkts)); 146 + buf[16] = csrrd32(priv->mac_dev, 147 + tse_csroffs(if_out_broadcast_pkts)); 148 + buf[17] = csrrd32(priv->mac_dev, 149 + tse_csroffs(ether_stats_drop_events)); 129 150 130 151 /* Extended etherStatsOctets counter */ 131 - ext = (u64) ioread32(&mac->msb_ether_stats_octets) << 32; 132 - ext |= ioread32(&mac->ether_stats_octets); 152 + ext = (u64) csrrd32(priv->mac_dev, 153 + tse_csroffs(msb_ether_stats_octets)) << 32; 154 + ext |= csrrd32(priv->mac_dev, 155 + tse_csroffs(ether_stats_octets)); 133 156 buf[18] = ext; 134 157 135 - buf[19] = ioread32(&mac->ether_stats_pkts); 136 - buf[20] = ioread32(&mac->ether_stats_undersize_pkts); 137 - buf[21] = ioread32(&mac->ether_stats_oversize_pkts); 138 - buf[22] = ioread32(&mac->ether_stats_pkts_64_octets); 139 - buf[23] = ioread32(&mac->ether_stats_pkts_65to127_octets); 140 - buf[24] = ioread32(&mac->ether_stats_pkts_128to255_octets); 141 - buf[25] = ioread32(&mac->ether_stats_pkts_256to511_octets); 142 - buf[26] = ioread32(&mac->ether_stats_pkts_512to1023_octets); 143 - buf[27] = ioread32(&mac->ether_stats_pkts_1024to1518_octets); 144 - buf[28] = ioread32(&mac->ether_stats_pkts_1519tox_octets); 145 - buf[29] = ioread32(&mac->ether_stats_jabbers); 146 - buf[30] = ioread32(&mac->ether_stats_fragments); 158 + buf[19] = csrrd32(priv->mac_dev, 159 + tse_csroffs(ether_stats_pkts)); 160 + buf[20] = csrrd32(priv->mac_dev, 161 + tse_csroffs(ether_stats_undersize_pkts)); 162 + buf[21] = csrrd32(priv->mac_dev, 163 + tse_csroffs(ether_stats_oversize_pkts)); 164 + buf[22] = csrrd32(priv->mac_dev, 165 + tse_csroffs(ether_stats_pkts_64_octets)); 166 + buf[23] = csrrd32(priv->mac_dev, 167 + tse_csroffs(ether_stats_pkts_65to127_octets)); 168 + buf[24] = csrrd32(priv->mac_dev, 169 + tse_csroffs(ether_stats_pkts_128to255_octets)); 170 + buf[25] = csrrd32(priv->mac_dev, 171 + tse_csroffs(ether_stats_pkts_256to511_octets)); 172 + buf[26] = csrrd32(priv->mac_dev, 173 + tse_csroffs(ether_stats_pkts_512to1023_octets)); 174 + buf[27] = csrrd32(priv->mac_dev, 175 + tse_csroffs(ether_stats_pkts_1024to1518_octets)); 176 + buf[28] = csrrd32(priv->mac_dev, 177 + tse_csroffs(ether_stats_pkts_1519tox_octets)); 178 + buf[29] = csrrd32(priv->mac_dev, 179 + tse_csroffs(ether_stats_jabbers)); 180 + buf[30] = csrrd32(priv->mac_dev, 181 + tse_csroffs(ether_stats_fragments)); 147 182 } 148 183 149 184 static int tse_sset_count(struct net_device *dev, int sset) ··· 213 178 { 214 179 int i; 215 180 struct altera_tse_private *priv = netdev_priv(dev); 216 - u32 *tse_mac_regs = (u32 *)priv->mac_dev; 217 181 u32 *buf = regbuf; 218 182 219 183 /* Set version to a known value, so ethtool knows ··· 230 196 regs->version = 1; 231 197 232 198 for (i = 0; i < TSE_NUM_REGS; i++) 233 - buf[i] = ioread32(&tse_mac_regs[i]); 199 + buf[i] = csrrd32(priv->mac_dev, i * 4); 234 200 } 235 201 236 202 static int tse_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+76 -57
drivers/net/ethernet/altera/altera_tse_main.c
··· 100 100 */ 101 101 static int altera_tse_mdio_read(struct mii_bus *bus, int mii_id, int regnum) 102 102 { 103 - struct altera_tse_mac *mac = (struct altera_tse_mac *)bus->priv; 104 - unsigned int *mdio_regs = (unsigned int *)&mac->mdio_phy0; 105 - u32 data; 103 + struct net_device *ndev = bus->priv; 104 + struct altera_tse_private *priv = netdev_priv(ndev); 106 105 107 106 /* set MDIO address */ 108 - iowrite32((mii_id & 0x1f), &mac->mdio_phy0_addr); 107 + csrwr32((mii_id & 0x1f), priv->mac_dev, 108 + tse_csroffs(mdio_phy0_addr)); 109 109 110 110 /* get the data */ 111 - data = ioread32(&mdio_regs[regnum]) & 0xffff; 112 - return data; 111 + return csrrd32(priv->mac_dev, 112 + tse_csroffs(mdio_phy0) + regnum * 4) & 0xffff; 113 113 } 114 114 115 115 static int altera_tse_mdio_write(struct mii_bus *bus, int mii_id, int regnum, 116 116 u16 value) 117 117 { 118 - struct altera_tse_mac *mac = (struct altera_tse_mac *)bus->priv; 119 - unsigned int *mdio_regs = (unsigned int *)&mac->mdio_phy0; 118 + struct net_device *ndev = bus->priv; 119 + struct altera_tse_private *priv = netdev_priv(ndev); 120 120 121 121 /* set MDIO address */ 122 - iowrite32((mii_id & 0x1f), &mac->mdio_phy0_addr); 122 + csrwr32((mii_id & 0x1f), priv->mac_dev, 123 + tse_csroffs(mdio_phy0_addr)); 123 124 124 125 /* write the data */ 125 - iowrite32((u32) value, &mdio_regs[regnum]); 126 + csrwr32(value, priv->mac_dev, tse_csroffs(mdio_phy0) + regnum * 4); 126 127 return 0; 127 128 } 128 129 ··· 169 168 for (i = 0; i < PHY_MAX_ADDR; i++) 170 169 mdio->irq[i] = PHY_POLL; 171 170 172 - mdio->priv = priv->mac_dev; 171 + mdio->priv = dev; 173 172 mdio->parent = priv->device; 174 173 175 174 ret = of_mdiobus_register(mdio, mdio_node); ··· 564 563 unsigned int nopaged_len = skb_headlen(skb); 565 564 enum netdev_tx ret = NETDEV_TX_OK; 566 565 dma_addr_t dma_addr; 567 - int txcomplete = 0; 568 566 569 567 spin_lock_bh(&priv->tx_lock); 570 568 ··· 599 599 dma_sync_single_for_device(priv->device, buffer->dma_addr, 600 600 buffer->len, DMA_TO_DEVICE); 601 601 602 - txcomplete = priv->dmaops->tx_buffer(priv, buffer); 602 + priv->dmaops->tx_buffer(priv, buffer); 603 603 604 604 skb_tx_timestamp(skb); 605 605 ··· 698 698 struct altera_tse_private *priv = netdev_priv(dev); 699 699 struct phy_device *phydev = NULL; 700 700 char phy_id_fmt[MII_BUS_ID_SIZE + 3]; 701 - int ret; 702 701 703 702 if (priv->phy_addr != POLL_PHY) { 704 703 snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, ··· 711 712 netdev_err(dev, "Could not attach to PHY\n"); 712 713 713 714 } else { 715 + int ret; 714 716 phydev = phy_find_first(priv->mdio); 715 717 if (phydev == NULL) { 716 718 netdev_err(dev, "No PHY found\n"); ··· 791 791 792 792 static void tse_update_mac_addr(struct altera_tse_private *priv, u8 *addr) 793 793 { 794 - struct altera_tse_mac *mac = priv->mac_dev; 795 794 u32 msb; 796 795 u32 lsb; 797 796 ··· 798 799 lsb = ((addr[5] << 8) | addr[4]) & 0xffff; 799 800 800 801 /* Set primary MAC address */ 801 - iowrite32(msb, &mac->mac_addr_0); 802 - iowrite32(lsb, &mac->mac_addr_1); 802 + csrwr32(msb, priv->mac_dev, tse_csroffs(mac_addr_0)); 803 + csrwr32(lsb, priv->mac_dev, tse_csroffs(mac_addr_1)); 803 804 } 804 805 805 806 /* MAC software reset. ··· 810 811 */ 811 812 static int reset_mac(struct altera_tse_private *priv) 812 813 { 813 - void __iomem *cmd_cfg_reg = &priv->mac_dev->command_config; 814 814 int counter; 815 815 u32 dat; 816 816 817 - dat = ioread32(cmd_cfg_reg); 817 + dat = csrrd32(priv->mac_dev, tse_csroffs(command_config)); 818 818 dat &= ~(MAC_CMDCFG_TX_ENA | MAC_CMDCFG_RX_ENA); 819 819 dat |= MAC_CMDCFG_SW_RESET | MAC_CMDCFG_CNT_RESET; 820 - iowrite32(dat, cmd_cfg_reg); 820 + csrwr32(dat, priv->mac_dev, tse_csroffs(command_config)); 821 821 822 822 counter = 0; 823 823 while (counter++ < ALTERA_TSE_SW_RESET_WATCHDOG_CNTR) { 824 - if (tse_bit_is_clear(cmd_cfg_reg, MAC_CMDCFG_SW_RESET)) 824 + if (tse_bit_is_clear(priv->mac_dev, tse_csroffs(command_config), 825 + MAC_CMDCFG_SW_RESET)) 825 826 break; 826 827 udelay(1); 827 828 } 828 829 829 830 if (counter >= ALTERA_TSE_SW_RESET_WATCHDOG_CNTR) { 830 - dat = ioread32(cmd_cfg_reg); 831 + dat = csrrd32(priv->mac_dev, tse_csroffs(command_config)); 831 832 dat &= ~MAC_CMDCFG_SW_RESET; 832 - iowrite32(dat, cmd_cfg_reg); 833 + csrwr32(dat, priv->mac_dev, tse_csroffs(command_config)); 833 834 return -1; 834 835 } 835 836 return 0; ··· 839 840 */ 840 841 static int init_mac(struct altera_tse_private *priv) 841 842 { 842 - struct altera_tse_mac *mac = priv->mac_dev; 843 843 unsigned int cmd = 0; 844 844 u32 frm_length; 845 845 846 846 /* Setup Rx FIFO */ 847 - iowrite32(priv->rx_fifo_depth - ALTERA_TSE_RX_SECTION_EMPTY, 848 - &mac->rx_section_empty); 849 - iowrite32(ALTERA_TSE_RX_SECTION_FULL, &mac->rx_section_full); 850 - iowrite32(ALTERA_TSE_RX_ALMOST_EMPTY, &mac->rx_almost_empty); 851 - iowrite32(ALTERA_TSE_RX_ALMOST_FULL, &mac->rx_almost_full); 847 + csrwr32(priv->rx_fifo_depth - ALTERA_TSE_RX_SECTION_EMPTY, 848 + priv->mac_dev, tse_csroffs(rx_section_empty)); 849 + 850 + csrwr32(ALTERA_TSE_RX_SECTION_FULL, priv->mac_dev, 851 + tse_csroffs(rx_section_full)); 852 + 853 + csrwr32(ALTERA_TSE_RX_ALMOST_EMPTY, priv->mac_dev, 854 + tse_csroffs(rx_almost_empty)); 855 + 856 + csrwr32(ALTERA_TSE_RX_ALMOST_FULL, priv->mac_dev, 857 + tse_csroffs(rx_almost_full)); 852 858 853 859 /* Setup Tx FIFO */ 854 - iowrite32(priv->tx_fifo_depth - ALTERA_TSE_TX_SECTION_EMPTY, 855 - &mac->tx_section_empty); 856 - iowrite32(ALTERA_TSE_TX_SECTION_FULL, &mac->tx_section_full); 857 - iowrite32(ALTERA_TSE_TX_ALMOST_EMPTY, &mac->tx_almost_empty); 858 - iowrite32(ALTERA_TSE_TX_ALMOST_FULL, &mac->tx_almost_full); 860 + csrwr32(priv->tx_fifo_depth - ALTERA_TSE_TX_SECTION_EMPTY, 861 + priv->mac_dev, tse_csroffs(tx_section_empty)); 862 + 863 + csrwr32(ALTERA_TSE_TX_SECTION_FULL, priv->mac_dev, 864 + tse_csroffs(tx_section_full)); 865 + 866 + csrwr32(ALTERA_TSE_TX_ALMOST_EMPTY, priv->mac_dev, 867 + tse_csroffs(tx_almost_empty)); 868 + 869 + csrwr32(ALTERA_TSE_TX_ALMOST_FULL, priv->mac_dev, 870 + tse_csroffs(tx_almost_full)); 859 871 860 872 /* MAC Address Configuration */ 861 873 tse_update_mac_addr(priv, priv->dev->dev_addr); 862 874 863 875 /* MAC Function Configuration */ 864 876 frm_length = ETH_HLEN + priv->dev->mtu + ETH_FCS_LEN; 865 - iowrite32(frm_length, &mac->frm_length); 866 - iowrite32(ALTERA_TSE_TX_IPG_LENGTH, &mac->tx_ipg_length); 877 + csrwr32(frm_length, priv->mac_dev, tse_csroffs(frm_length)); 878 + 879 + csrwr32(ALTERA_TSE_TX_IPG_LENGTH, priv->mac_dev, 880 + tse_csroffs(tx_ipg_length)); 867 881 868 882 /* Disable RX/TX shift 16 for alignment of all received frames on 16-bit 869 883 * start address 870 884 */ 871 - tse_set_bit(&mac->rx_cmd_stat, ALTERA_TSE_RX_CMD_STAT_RX_SHIFT16); 872 - tse_clear_bit(&mac->tx_cmd_stat, ALTERA_TSE_TX_CMD_STAT_TX_SHIFT16 | 873 - ALTERA_TSE_TX_CMD_STAT_OMIT_CRC); 885 + tse_set_bit(priv->mac_dev, tse_csroffs(rx_cmd_stat), 886 + ALTERA_TSE_RX_CMD_STAT_RX_SHIFT16); 887 + 888 + tse_clear_bit(priv->mac_dev, tse_csroffs(tx_cmd_stat), 889 + ALTERA_TSE_TX_CMD_STAT_TX_SHIFT16 | 890 + ALTERA_TSE_TX_CMD_STAT_OMIT_CRC); 874 891 875 892 /* Set the MAC options */ 876 - cmd = ioread32(&mac->command_config); 893 + cmd = csrrd32(priv->mac_dev, tse_csroffs(command_config)); 877 894 cmd &= ~MAC_CMDCFG_PAD_EN; /* No padding Removal on Receive */ 878 895 cmd &= ~MAC_CMDCFG_CRC_FWD; /* CRC Removal */ 879 896 cmd |= MAC_CMDCFG_RX_ERR_DISC; /* Automatically discard frames ··· 904 889 cmd &= ~MAC_CMDCFG_ETH_SPEED; 905 890 cmd &= ~MAC_CMDCFG_ENA_10; 906 891 907 - iowrite32(cmd, &mac->command_config); 892 + csrwr32(cmd, priv->mac_dev, tse_csroffs(command_config)); 908 893 909 - iowrite32(ALTERA_TSE_PAUSE_QUANTA, &mac->pause_quanta); 894 + csrwr32(ALTERA_TSE_PAUSE_QUANTA, priv->mac_dev, 895 + tse_csroffs(pause_quanta)); 910 896 911 897 if (netif_msg_hw(priv)) 912 898 dev_dbg(priv->device, ··· 920 904 */ 921 905 static void tse_set_mac(struct altera_tse_private *priv, bool enable) 922 906 { 923 - struct altera_tse_mac *mac = priv->mac_dev; 924 - u32 value = ioread32(&mac->command_config); 907 + u32 value = csrrd32(priv->mac_dev, tse_csroffs(command_config)); 925 908 926 909 if (enable) 927 910 value |= MAC_CMDCFG_TX_ENA | MAC_CMDCFG_RX_ENA; 928 911 else 929 912 value &= ~(MAC_CMDCFG_TX_ENA | MAC_CMDCFG_RX_ENA); 930 913 931 - iowrite32(value, &mac->command_config); 914 + csrwr32(value, priv->mac_dev, tse_csroffs(command_config)); 932 915 } 933 916 934 917 /* Change the MTU ··· 957 942 static void altera_tse_set_mcfilter(struct net_device *dev) 958 943 { 959 944 struct altera_tse_private *priv = netdev_priv(dev); 960 - struct altera_tse_mac *mac = priv->mac_dev; 961 945 int i; 962 946 struct netdev_hw_addr *ha; 963 947 964 948 /* clear the hash filter */ 965 949 for (i = 0; i < 64; i++) 966 - iowrite32(0, &(mac->hash_table[i])); 950 + csrwr32(0, priv->mac_dev, tse_csroffs(hash_table) + i * 4); 967 951 968 952 netdev_for_each_mc_addr(ha, dev) { 969 953 unsigned int hash = 0; ··· 978 964 979 965 hash = (hash << 1) | xor_bit; 980 966 } 981 - iowrite32(1, &(mac->hash_table[hash])); 967 + csrwr32(1, priv->mac_dev, tse_csroffs(hash_table) + hash * 4); 982 968 } 983 969 } 984 970 ··· 986 972 static void altera_tse_set_mcfilterall(struct net_device *dev) 987 973 { 988 974 struct altera_tse_private *priv = netdev_priv(dev); 989 - struct altera_tse_mac *mac = priv->mac_dev; 990 975 int i; 991 976 992 977 /* set the hash filter */ 993 978 for (i = 0; i < 64; i++) 994 - iowrite32(1, &(mac->hash_table[i])); 979 + csrwr32(1, priv->mac_dev, tse_csroffs(hash_table) + i * 4); 995 980 } 996 981 997 982 /* Set or clear the multicast filter for this adaptor ··· 998 985 static void tse_set_rx_mode_hashfilter(struct net_device *dev) 999 986 { 1000 987 struct altera_tse_private *priv = netdev_priv(dev); 1001 - struct altera_tse_mac *mac = priv->mac_dev; 1002 988 1003 989 spin_lock(&priv->mac_cfg_lock); 1004 990 1005 991 if (dev->flags & IFF_PROMISC) 1006 - tse_set_bit(&mac->command_config, MAC_CMDCFG_PROMIS_EN); 992 + tse_set_bit(priv->mac_dev, tse_csroffs(command_config), 993 + MAC_CMDCFG_PROMIS_EN); 1007 994 1008 995 if (dev->flags & IFF_ALLMULTI) 1009 996 altera_tse_set_mcfilterall(dev); ··· 1018 1005 static void tse_set_rx_mode(struct net_device *dev) 1019 1006 { 1020 1007 struct altera_tse_private *priv = netdev_priv(dev); 1021 - struct altera_tse_mac *mac = priv->mac_dev; 1022 1008 1023 1009 spin_lock(&priv->mac_cfg_lock); 1024 1010 1025 1011 if ((dev->flags & IFF_PROMISC) || (dev->flags & IFF_ALLMULTI) || 1026 1012 !netdev_mc_empty(dev) || !netdev_uc_empty(dev)) 1027 - tse_set_bit(&mac->command_config, MAC_CMDCFG_PROMIS_EN); 1013 + tse_set_bit(priv->mac_dev, tse_csroffs(command_config), 1014 + MAC_CMDCFG_PROMIS_EN); 1028 1015 else 1029 - tse_clear_bit(&mac->command_config, MAC_CMDCFG_PROMIS_EN); 1016 + tse_clear_bit(priv->mac_dev, tse_csroffs(command_config), 1017 + MAC_CMDCFG_PROMIS_EN); 1030 1018 1031 1019 spin_unlock(&priv->mac_cfg_lock); 1032 1020 } ··· 1376 1362 of_property_read_bool(pdev->dev.of_node, 1377 1363 "altr,has-hash-multicast-filter"); 1378 1364 1365 + /* Set hash filter to not set for now until the 1366 + * multicast filter receive issue is debugged 1367 + */ 1368 + priv->hash_filter = 0; 1369 + 1379 1370 /* get supplemental address settings for this instance */ 1380 1371 priv->added_unicast = 1381 1372 of_property_read_bool(pdev->dev.of_node, ··· 1512 1493 return 0; 1513 1494 } 1514 1495 1515 - struct altera_dmaops altera_dtype_sgdma = { 1496 + static const struct altera_dmaops altera_dtype_sgdma = { 1516 1497 .altera_dtype = ALTERA_DTYPE_SGDMA, 1517 1498 .dmamask = 32, 1518 1499 .reset_dma = sgdma_reset, ··· 1531 1512 .start_rxdma = sgdma_start_rxdma, 1532 1513 }; 1533 1514 1534 - struct altera_dmaops altera_dtype_msgdma = { 1515 + static const struct altera_dmaops altera_dtype_msgdma = { 1535 1516 .altera_dtype = ALTERA_DTYPE_MSGDMA, 1536 1517 .dmamask = 64, 1537 1518 .reset_dma = msgdma_reset,
+10 -10
drivers/net/ethernet/altera/altera_utils.c
··· 17 17 #include "altera_tse.h" 18 18 #include "altera_utils.h" 19 19 20 - void tse_set_bit(void __iomem *ioaddr, u32 bit_mask) 20 + void tse_set_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask) 21 21 { 22 - u32 value = ioread32(ioaddr); 22 + u32 value = csrrd32(ioaddr, offs); 23 23 value |= bit_mask; 24 - iowrite32(value, ioaddr); 24 + csrwr32(value, ioaddr, offs); 25 25 } 26 26 27 - void tse_clear_bit(void __iomem *ioaddr, u32 bit_mask) 27 + void tse_clear_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask) 28 28 { 29 - u32 value = ioread32(ioaddr); 29 + u32 value = csrrd32(ioaddr, offs); 30 30 value &= ~bit_mask; 31 - iowrite32(value, ioaddr); 31 + csrwr32(value, ioaddr, offs); 32 32 } 33 33 34 - int tse_bit_is_set(void __iomem *ioaddr, u32 bit_mask) 34 + int tse_bit_is_set(void __iomem *ioaddr, size_t offs, u32 bit_mask) 35 35 { 36 - u32 value = ioread32(ioaddr); 36 + u32 value = csrrd32(ioaddr, offs); 37 37 return (value & bit_mask) ? 1 : 0; 38 38 } 39 39 40 - int tse_bit_is_clear(void __iomem *ioaddr, u32 bit_mask) 40 + int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask) 41 41 { 42 - u32 value = ioread32(ioaddr); 42 + u32 value = csrrd32(ioaddr, offs); 43 43 return (value & bit_mask) ? 0 : 1; 44 44 }
+4 -4
drivers/net/ethernet/altera/altera_utils.h
··· 19 19 #ifndef __ALTERA_UTILS_H__ 20 20 #define __ALTERA_UTILS_H__ 21 21 22 - void tse_set_bit(void __iomem *ioaddr, u32 bit_mask); 23 - void tse_clear_bit(void __iomem *ioaddr, u32 bit_mask); 24 - int tse_bit_is_set(void __iomem *ioaddr, u32 bit_mask); 25 - int tse_bit_is_clear(void __iomem *ioaddr, u32 bit_mask); 22 + void tse_set_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask); 23 + void tse_clear_bit(void __iomem *ioaddr, size_t offs, u32 bit_mask); 24 + int tse_bit_is_set(void __iomem *ioaddr, size_t offs, u32 bit_mask); 25 + int tse_bit_is_clear(void __iomem *ioaddr, size_t offs, u32 bit_mask); 26 26 27 27 #endif /* __ALTERA_UTILS_H__*/
+7 -3
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 10051 10051 #define BCM_5710_UNDI_FW_MF_MAJOR (0x07) 10052 10052 #define BCM_5710_UNDI_FW_MF_MINOR (0x08) 10053 10053 #define BCM_5710_UNDI_FW_MF_VERS (0x05) 10054 - #define BNX2X_PREV_UNDI_MF_PORT(p) (0x1a150c + ((p) << 4)) 10055 - #define BNX2X_PREV_UNDI_MF_FUNC(f) (0x1a184c + ((f) << 4)) 10054 + #define BNX2X_PREV_UNDI_MF_PORT(p) (BAR_TSTRORM_INTMEM + 0x150c + ((p) << 4)) 10055 + #define BNX2X_PREV_UNDI_MF_FUNC(f) (BAR_TSTRORM_INTMEM + 0x184c + ((f) << 4)) 10056 10056 static bool bnx2x_prev_unload_undi_fw_supports_mf(struct bnx2x *bp) 10057 10057 { 10058 10058 u8 major, minor, version; ··· 10352 10352 /* Reset should be performed after BRB is emptied */ 10353 10353 if (reset_reg & MISC_REGISTERS_RESET_REG_1_RST_BRB1) { 10354 10354 u32 timer_count = 1000; 10355 + bool need_write = true; 10355 10356 10356 10357 /* Close the MAC Rx to prevent BRB from filling up */ 10357 10358 bnx2x_prev_unload_close_mac(bp, &mac_vals); ··· 10399 10398 * cleaning methods - might be redundant but harmless. 10400 10399 */ 10401 10400 if (bnx2x_prev_unload_undi_fw_supports_mf(bp)) { 10402 - bnx2x_prev_unload_undi_mf(bp); 10401 + if (need_write) { 10402 + bnx2x_prev_unload_undi_mf(bp); 10403 + need_write = false; 10404 + } 10403 10405 } else if (prev_undi) { 10404 10406 /* If UNDI resides in memory, 10405 10407 * manually increment it
+1 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
··· 2695 2695 bnx2x_unlock_vf_pf_channel(bp, vf, CHANNEL_TLV_PF_SET_MAC); 2696 2696 } 2697 2697 2698 - return 0; 2698 + return rc; 2699 2699 } 2700 2700 2701 2701 int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos)
+1 -1
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
··· 747 747 out: 748 748 bnx2x_vfpf_finalize(bp, &req->first_tlv); 749 749 750 - return 0; 750 + return rc; 751 751 } 752 752 753 753 /* request pf to config rss table for vf queues*/
+706
drivers/net/ethernet/ec_bhf.c
··· 1 + /* 2 + * drivers/net/ethernet/beckhoff/ec_bhf.c 3 + * 4 + * Copyright (C) 2014 Darek Marcinkiewicz <reksio@newterm.pl> 5 + * 6 + * This software is licensed under the terms of the GNU General Public 7 + * License version 2, as published by the Free Software Foundation, and 8 + * may be copied, distributed, and modified under those terms. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + */ 16 + 17 + /* This is a driver for EtherCAT master module present on CCAT FPGA. 18 + * Those can be found on Bechhoff CX50xx industrial PCs. 19 + */ 20 + 21 + #if 0 22 + #define DEBUG 23 + #endif 24 + #include <linux/kernel.h> 25 + #include <linux/module.h> 26 + #include <linux/moduleparam.h> 27 + #include <linux/pci.h> 28 + #include <linux/init.h> 29 + 30 + #include <linux/netdevice.h> 31 + #include <linux/etherdevice.h> 32 + #include <linux/ip.h> 33 + #include <linux/skbuff.h> 34 + #include <linux/hrtimer.h> 35 + #include <linux/interrupt.h> 36 + #include <linux/stat.h> 37 + 38 + #define TIMER_INTERVAL_NSEC 20000 39 + 40 + #define INFO_BLOCK_SIZE 0x10 41 + #define INFO_BLOCK_TYPE 0x0 42 + #define INFO_BLOCK_REV 0x2 43 + #define INFO_BLOCK_BLK_CNT 0x4 44 + #define INFO_BLOCK_TX_CHAN 0x4 45 + #define INFO_BLOCK_RX_CHAN 0x5 46 + #define INFO_BLOCK_OFFSET 0x8 47 + 48 + #define EC_MII_OFFSET 0x4 49 + #define EC_FIFO_OFFSET 0x8 50 + #define EC_MAC_OFFSET 0xc 51 + 52 + #define MAC_FRAME_ERR_CNT 0x0 53 + #define MAC_RX_ERR_CNT 0x1 54 + #define MAC_CRC_ERR_CNT 0x2 55 + #define MAC_LNK_LST_ERR_CNT 0x3 56 + #define MAC_TX_FRAME_CNT 0x10 57 + #define MAC_RX_FRAME_CNT 0x14 58 + #define MAC_TX_FIFO_LVL 0x20 59 + #define MAC_DROPPED_FRMS 0x28 60 + #define MAC_CONNECTED_CCAT_FLAG 0x78 61 + 62 + #define MII_MAC_ADDR 0x8 63 + #define MII_MAC_FILT_FLAG 0xe 64 + #define MII_LINK_STATUS 0xf 65 + 66 + #define FIFO_TX_REG 0x0 67 + #define FIFO_TX_RESET 0x8 68 + #define FIFO_RX_REG 0x10 69 + #define FIFO_RX_ADDR_VALID (1u << 31) 70 + #define FIFO_RX_RESET 0x18 71 + 72 + #define DMA_CHAN_OFFSET 0x1000 73 + #define DMA_CHAN_SIZE 0x8 74 + 75 + #define DMA_WINDOW_SIZE_MASK 0xfffffffc 76 + 77 + static struct pci_device_id ids[] = { 78 + { PCI_DEVICE(0x15ec, 0x5000), }, 79 + { 0, } 80 + }; 81 + MODULE_DEVICE_TABLE(pci, ids); 82 + 83 + struct rx_header { 84 + #define RXHDR_NEXT_ADDR_MASK 0xffffffu 85 + #define RXHDR_NEXT_VALID (1u << 31) 86 + __le32 next; 87 + #define RXHDR_NEXT_RECV_FLAG 0x1 88 + __le32 recv; 89 + #define RXHDR_LEN_MASK 0xfffu 90 + __le16 len; 91 + __le16 port; 92 + __le32 reserved; 93 + u8 timestamp[8]; 94 + } __packed; 95 + 96 + #define PKT_PAYLOAD_SIZE 0x7e8 97 + struct rx_desc { 98 + struct rx_header header; 99 + u8 data[PKT_PAYLOAD_SIZE]; 100 + } __packed; 101 + 102 + struct tx_header { 103 + __le16 len; 104 + #define TX_HDR_PORT_0 0x1 105 + #define TX_HDR_PORT_1 0x2 106 + u8 port; 107 + u8 ts_enable; 108 + #define TX_HDR_SENT 0x1 109 + __le32 sent; 110 + u8 timestamp[8]; 111 + } __packed; 112 + 113 + struct tx_desc { 114 + struct tx_header header; 115 + u8 data[PKT_PAYLOAD_SIZE]; 116 + } __packed; 117 + 118 + #define FIFO_SIZE 64 119 + 120 + static long polling_frequency = TIMER_INTERVAL_NSEC; 121 + 122 + struct bhf_dma { 123 + u8 *buf; 124 + size_t len; 125 + dma_addr_t buf_phys; 126 + 127 + u8 *alloc; 128 + size_t alloc_len; 129 + dma_addr_t alloc_phys; 130 + }; 131 + 132 + struct ec_bhf_priv { 133 + struct net_device *net_dev; 134 + 135 + struct pci_dev *dev; 136 + 137 + void * __iomem io; 138 + void * __iomem dma_io; 139 + 140 + struct hrtimer hrtimer; 141 + 142 + int tx_dma_chan; 143 + int rx_dma_chan; 144 + void * __iomem ec_io; 145 + void * __iomem fifo_io; 146 + void * __iomem mii_io; 147 + void * __iomem mac_io; 148 + 149 + struct bhf_dma rx_buf; 150 + struct rx_desc *rx_descs; 151 + int rx_dnext; 152 + int rx_dcount; 153 + 154 + struct bhf_dma tx_buf; 155 + struct tx_desc *tx_descs; 156 + int tx_dcount; 157 + int tx_dnext; 158 + 159 + u64 stat_rx_bytes; 160 + u64 stat_tx_bytes; 161 + }; 162 + 163 + #define PRIV_TO_DEV(priv) (&(priv)->dev->dev) 164 + 165 + #define ETHERCAT_MASTER_ID 0x14 166 + 167 + static void ec_bhf_print_status(struct ec_bhf_priv *priv) 168 + { 169 + struct device *dev = PRIV_TO_DEV(priv); 170 + 171 + dev_dbg(dev, "Frame error counter: %d\n", 172 + ioread8(priv->mac_io + MAC_FRAME_ERR_CNT)); 173 + dev_dbg(dev, "RX error counter: %d\n", 174 + ioread8(priv->mac_io + MAC_RX_ERR_CNT)); 175 + dev_dbg(dev, "CRC error counter: %d\n", 176 + ioread8(priv->mac_io + MAC_CRC_ERR_CNT)); 177 + dev_dbg(dev, "TX frame counter: %d\n", 178 + ioread32(priv->mac_io + MAC_TX_FRAME_CNT)); 179 + dev_dbg(dev, "RX frame counter: %d\n", 180 + ioread32(priv->mac_io + MAC_RX_FRAME_CNT)); 181 + dev_dbg(dev, "TX fifo level: %d\n", 182 + ioread8(priv->mac_io + MAC_TX_FIFO_LVL)); 183 + dev_dbg(dev, "Dropped frames: %d\n", 184 + ioread8(priv->mac_io + MAC_DROPPED_FRMS)); 185 + dev_dbg(dev, "Connected with CCAT slot: %d\n", 186 + ioread8(priv->mac_io + MAC_CONNECTED_CCAT_FLAG)); 187 + dev_dbg(dev, "Link status: %d\n", 188 + ioread8(priv->mii_io + MII_LINK_STATUS)); 189 + } 190 + 191 + static void ec_bhf_reset(struct ec_bhf_priv *priv) 192 + { 193 + iowrite8(0, priv->mac_io + MAC_FRAME_ERR_CNT); 194 + iowrite8(0, priv->mac_io + MAC_RX_ERR_CNT); 195 + iowrite8(0, priv->mac_io + MAC_CRC_ERR_CNT); 196 + iowrite8(0, priv->mac_io + MAC_LNK_LST_ERR_CNT); 197 + iowrite32(0, priv->mac_io + MAC_TX_FRAME_CNT); 198 + iowrite32(0, priv->mac_io + MAC_RX_FRAME_CNT); 199 + iowrite8(0, priv->mac_io + MAC_DROPPED_FRMS); 200 + 201 + iowrite8(0, priv->fifo_io + FIFO_TX_RESET); 202 + iowrite8(0, priv->fifo_io + FIFO_RX_RESET); 203 + 204 + iowrite8(0, priv->mac_io + MAC_TX_FIFO_LVL); 205 + } 206 + 207 + static void ec_bhf_send_packet(struct ec_bhf_priv *priv, struct tx_desc *desc) 208 + { 209 + u32 len = le16_to_cpu(desc->header.len) + sizeof(desc->header); 210 + u32 addr = (u8 *)desc - priv->tx_buf.buf; 211 + 212 + iowrite32((ALIGN(len, 8) << 24) | addr, priv->fifo_io + FIFO_TX_REG); 213 + 214 + dev_dbg(PRIV_TO_DEV(priv), "Done sending packet\n"); 215 + } 216 + 217 + static int ec_bhf_desc_sent(struct tx_desc *desc) 218 + { 219 + return le32_to_cpu(desc->header.sent) & TX_HDR_SENT; 220 + } 221 + 222 + static void ec_bhf_process_tx(struct ec_bhf_priv *priv) 223 + { 224 + if (unlikely(netif_queue_stopped(priv->net_dev))) { 225 + /* Make sure that we perceive changes to tx_dnext. */ 226 + smp_rmb(); 227 + 228 + if (ec_bhf_desc_sent(&priv->tx_descs[priv->tx_dnext])) 229 + netif_wake_queue(priv->net_dev); 230 + } 231 + } 232 + 233 + static int ec_bhf_pkt_received(struct rx_desc *desc) 234 + { 235 + return le32_to_cpu(desc->header.recv) & RXHDR_NEXT_RECV_FLAG; 236 + } 237 + 238 + static void ec_bhf_add_rx_desc(struct ec_bhf_priv *priv, struct rx_desc *desc) 239 + { 240 + iowrite32(FIFO_RX_ADDR_VALID | ((u8 *)(desc) - priv->rx_buf.buf), 241 + priv->fifo_io + FIFO_RX_REG); 242 + } 243 + 244 + static void ec_bhf_process_rx(struct ec_bhf_priv *priv) 245 + { 246 + struct rx_desc *desc = &priv->rx_descs[priv->rx_dnext]; 247 + struct device *dev = PRIV_TO_DEV(priv); 248 + 249 + while (ec_bhf_pkt_received(desc)) { 250 + int pkt_size = (le16_to_cpu(desc->header.len) & 251 + RXHDR_LEN_MASK) - sizeof(struct rx_header) - 4; 252 + u8 *data = desc->data; 253 + struct sk_buff *skb; 254 + 255 + skb = netdev_alloc_skb_ip_align(priv->net_dev, pkt_size); 256 + dev_dbg(dev, "Received packet, size: %d\n", pkt_size); 257 + 258 + if (skb) { 259 + memcpy(skb_put(skb, pkt_size), data, pkt_size); 260 + skb->protocol = eth_type_trans(skb, priv->net_dev); 261 + dev_dbg(dev, "Protocol type: %x\n", skb->protocol); 262 + 263 + priv->stat_rx_bytes += pkt_size; 264 + 265 + netif_rx(skb); 266 + } else { 267 + dev_err_ratelimited(dev, 268 + "Couldn't allocate a skb_buff for a packet of size %u\n", 269 + pkt_size); 270 + } 271 + 272 + desc->header.recv = 0; 273 + 274 + ec_bhf_add_rx_desc(priv, desc); 275 + 276 + priv->rx_dnext = (priv->rx_dnext + 1) % priv->rx_dcount; 277 + desc = &priv->rx_descs[priv->rx_dnext]; 278 + } 279 + 280 + } 281 + 282 + static enum hrtimer_restart ec_bhf_timer_fun(struct hrtimer *timer) 283 + { 284 + struct ec_bhf_priv *priv = container_of(timer, struct ec_bhf_priv, 285 + hrtimer); 286 + ec_bhf_process_rx(priv); 287 + ec_bhf_process_tx(priv); 288 + 289 + if (!netif_running(priv->net_dev)) 290 + return HRTIMER_NORESTART; 291 + 292 + hrtimer_forward_now(timer, ktime_set(0, polling_frequency)); 293 + return HRTIMER_RESTART; 294 + } 295 + 296 + static int ec_bhf_setup_offsets(struct ec_bhf_priv *priv) 297 + { 298 + struct device *dev = PRIV_TO_DEV(priv); 299 + unsigned block_count, i; 300 + void * __iomem ec_info; 301 + 302 + dev_dbg(dev, "Info block:\n"); 303 + dev_dbg(dev, "Type of function: %x\n", (unsigned)ioread16(priv->io)); 304 + dev_dbg(dev, "Revision of function: %x\n", 305 + (unsigned)ioread16(priv->io + INFO_BLOCK_REV)); 306 + 307 + block_count = ioread8(priv->io + INFO_BLOCK_BLK_CNT); 308 + dev_dbg(dev, "Number of function blocks: %x\n", block_count); 309 + 310 + for (i = 0; i < block_count; i++) { 311 + u16 type = ioread16(priv->io + i * INFO_BLOCK_SIZE + 312 + INFO_BLOCK_TYPE); 313 + if (type == ETHERCAT_MASTER_ID) 314 + break; 315 + } 316 + if (i == block_count) { 317 + dev_err(dev, "EtherCAT master with DMA block not found\n"); 318 + return -ENODEV; 319 + } 320 + dev_dbg(dev, "EtherCAT master with DMA block found at pos: %d\n", i); 321 + 322 + ec_info = priv->io + i * INFO_BLOCK_SIZE; 323 + dev_dbg(dev, "EtherCAT master revision: %d\n", 324 + ioread16(ec_info + INFO_BLOCK_REV)); 325 + 326 + priv->tx_dma_chan = ioread8(ec_info + INFO_BLOCK_TX_CHAN); 327 + dev_dbg(dev, "EtherCAT master tx dma channel: %d\n", 328 + priv->tx_dma_chan); 329 + 330 + priv->rx_dma_chan = ioread8(ec_info + INFO_BLOCK_RX_CHAN); 331 + dev_dbg(dev, "EtherCAT master rx dma channel: %d\n", 332 + priv->rx_dma_chan); 333 + 334 + priv->ec_io = priv->io + ioread32(ec_info + INFO_BLOCK_OFFSET); 335 + priv->mii_io = priv->ec_io + ioread32(priv->ec_io + EC_MII_OFFSET); 336 + priv->fifo_io = priv->ec_io + ioread32(priv->ec_io + EC_FIFO_OFFSET); 337 + priv->mac_io = priv->ec_io + ioread32(priv->ec_io + EC_MAC_OFFSET); 338 + 339 + dev_dbg(dev, 340 + "EtherCAT block addres: %p, fifo address: %p, mii address: %p, mac address: %p\n", 341 + priv->ec_io, priv->fifo_io, priv->mii_io, priv->mac_io); 342 + 343 + return 0; 344 + } 345 + 346 + static netdev_tx_t ec_bhf_start_xmit(struct sk_buff *skb, 347 + struct net_device *net_dev) 348 + { 349 + struct ec_bhf_priv *priv = netdev_priv(net_dev); 350 + struct tx_desc *desc; 351 + unsigned len; 352 + 353 + dev_dbg(PRIV_TO_DEV(priv), "Starting xmit\n"); 354 + 355 + desc = &priv->tx_descs[priv->tx_dnext]; 356 + 357 + skb_copy_and_csum_dev(skb, desc->data); 358 + len = skb->len; 359 + 360 + memset(&desc->header, 0, sizeof(desc->header)); 361 + desc->header.len = cpu_to_le16(len); 362 + desc->header.port = TX_HDR_PORT_0; 363 + 364 + ec_bhf_send_packet(priv, desc); 365 + 366 + priv->tx_dnext = (priv->tx_dnext + 1) % priv->tx_dcount; 367 + 368 + if (!ec_bhf_desc_sent(&priv->tx_descs[priv->tx_dnext])) { 369 + /* Make sure that update updates to tx_dnext are perceived 370 + * by timer routine. 371 + */ 372 + smp_wmb(); 373 + 374 + netif_stop_queue(net_dev); 375 + 376 + dev_dbg(PRIV_TO_DEV(priv), "Stopping netif queue\n"); 377 + ec_bhf_print_status(priv); 378 + } 379 + 380 + priv->stat_tx_bytes += len; 381 + 382 + dev_kfree_skb(skb); 383 + 384 + return NETDEV_TX_OK; 385 + } 386 + 387 + static int ec_bhf_alloc_dma_mem(struct ec_bhf_priv *priv, 388 + struct bhf_dma *buf, 389 + int channel, 390 + int size) 391 + { 392 + int offset = channel * DMA_CHAN_SIZE + DMA_CHAN_OFFSET; 393 + struct device *dev = PRIV_TO_DEV(priv); 394 + u32 mask; 395 + 396 + iowrite32(0xffffffff, priv->dma_io + offset); 397 + 398 + mask = ioread32(priv->dma_io + offset); 399 + mask &= DMA_WINDOW_SIZE_MASK; 400 + dev_dbg(dev, "Read mask %x for channel %d\n", mask, channel); 401 + 402 + /* We want to allocate a chunk of memory that is: 403 + * - aligned to the mask we just read 404 + * - is of size 2^mask bytes (at most) 405 + * In order to ensure that we will allocate buffer of 406 + * 2 * 2^mask bytes. 407 + */ 408 + buf->len = min_t(int, ~mask + 1, size); 409 + buf->alloc_len = 2 * buf->len; 410 + 411 + dev_dbg(dev, "Allocating %d bytes for channel %d", 412 + (int)buf->alloc_len, channel); 413 + buf->alloc = dma_alloc_coherent(dev, buf->alloc_len, &buf->alloc_phys, 414 + GFP_KERNEL); 415 + if (buf->alloc == NULL) { 416 + dev_info(dev, "Failed to allocate buffer\n"); 417 + return -ENOMEM; 418 + } 419 + 420 + buf->buf_phys = (buf->alloc_phys + buf->len) & mask; 421 + buf->buf = buf->alloc + (buf->buf_phys - buf->alloc_phys); 422 + 423 + iowrite32(0, priv->dma_io + offset + 4); 424 + iowrite32(buf->buf_phys, priv->dma_io + offset); 425 + dev_dbg(dev, "Buffer: %x and read from dev: %x", 426 + (unsigned)buf->buf_phys, ioread32(priv->dma_io + offset)); 427 + 428 + return 0; 429 + } 430 + 431 + static void ec_bhf_setup_tx_descs(struct ec_bhf_priv *priv) 432 + { 433 + int i = 0; 434 + 435 + priv->tx_dcount = priv->tx_buf.len / sizeof(struct tx_desc); 436 + priv->tx_descs = (struct tx_desc *) priv->tx_buf.buf; 437 + priv->tx_dnext = 0; 438 + 439 + for (i = 0; i < priv->tx_dcount; i++) 440 + priv->tx_descs[i].header.sent = cpu_to_le32(TX_HDR_SENT); 441 + } 442 + 443 + static void ec_bhf_setup_rx_descs(struct ec_bhf_priv *priv) 444 + { 445 + int i; 446 + 447 + priv->rx_dcount = priv->rx_buf.len / sizeof(struct rx_desc); 448 + priv->rx_descs = (struct rx_desc *) priv->rx_buf.buf; 449 + priv->rx_dnext = 0; 450 + 451 + for (i = 0; i < priv->rx_dcount; i++) { 452 + struct rx_desc *desc = &priv->rx_descs[i]; 453 + u32 next; 454 + 455 + if (i != priv->rx_dcount - 1) 456 + next = (u8 *)(desc + 1) - priv->rx_buf.buf; 457 + else 458 + next = 0; 459 + next |= RXHDR_NEXT_VALID; 460 + desc->header.next = cpu_to_le32(next); 461 + desc->header.recv = 0; 462 + ec_bhf_add_rx_desc(priv, desc); 463 + } 464 + } 465 + 466 + static int ec_bhf_open(struct net_device *net_dev) 467 + { 468 + struct ec_bhf_priv *priv = netdev_priv(net_dev); 469 + struct device *dev = PRIV_TO_DEV(priv); 470 + int err = 0; 471 + 472 + dev_info(dev, "Opening device\n"); 473 + 474 + ec_bhf_reset(priv); 475 + 476 + err = ec_bhf_alloc_dma_mem(priv, &priv->rx_buf, priv->rx_dma_chan, 477 + FIFO_SIZE * sizeof(struct rx_desc)); 478 + if (err) { 479 + dev_err(dev, "Failed to allocate rx buffer\n"); 480 + goto out; 481 + } 482 + ec_bhf_setup_rx_descs(priv); 483 + 484 + dev_info(dev, "RX buffer allocated, address: %x\n", 485 + (unsigned)priv->rx_buf.buf_phys); 486 + 487 + err = ec_bhf_alloc_dma_mem(priv, &priv->tx_buf, priv->tx_dma_chan, 488 + FIFO_SIZE * sizeof(struct tx_desc)); 489 + if (err) { 490 + dev_err(dev, "Failed to allocate tx buffer\n"); 491 + goto error_rx_free; 492 + } 493 + dev_dbg(dev, "TX buffer allocated, addres: %x\n", 494 + (unsigned)priv->tx_buf.buf_phys); 495 + 496 + iowrite8(0, priv->mii_io + MII_MAC_FILT_FLAG); 497 + 498 + ec_bhf_setup_tx_descs(priv); 499 + 500 + netif_start_queue(net_dev); 501 + 502 + hrtimer_init(&priv->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 503 + priv->hrtimer.function = ec_bhf_timer_fun; 504 + hrtimer_start(&priv->hrtimer, ktime_set(0, polling_frequency), 505 + HRTIMER_MODE_REL); 506 + 507 + dev_info(PRIV_TO_DEV(priv), "Device open\n"); 508 + 509 + ec_bhf_print_status(priv); 510 + 511 + return 0; 512 + 513 + error_rx_free: 514 + dma_free_coherent(dev, priv->rx_buf.alloc_len, priv->rx_buf.alloc, 515 + priv->rx_buf.alloc_len); 516 + out: 517 + return err; 518 + } 519 + 520 + static int ec_bhf_stop(struct net_device *net_dev) 521 + { 522 + struct ec_bhf_priv *priv = netdev_priv(net_dev); 523 + struct device *dev = PRIV_TO_DEV(priv); 524 + 525 + hrtimer_cancel(&priv->hrtimer); 526 + 527 + ec_bhf_reset(priv); 528 + 529 + netif_tx_disable(net_dev); 530 + 531 + dma_free_coherent(dev, priv->tx_buf.alloc_len, 532 + priv->tx_buf.alloc, priv->tx_buf.alloc_phys); 533 + dma_free_coherent(dev, priv->rx_buf.alloc_len, 534 + priv->rx_buf.alloc, priv->rx_buf.alloc_phys); 535 + 536 + return 0; 537 + } 538 + 539 + static struct rtnl_link_stats64 * 540 + ec_bhf_get_stats(struct net_device *net_dev, 541 + struct rtnl_link_stats64 *stats) 542 + { 543 + struct ec_bhf_priv *priv = netdev_priv(net_dev); 544 + 545 + stats->rx_errors = ioread8(priv->mac_io + MAC_RX_ERR_CNT) + 546 + ioread8(priv->mac_io + MAC_CRC_ERR_CNT) + 547 + ioread8(priv->mac_io + MAC_FRAME_ERR_CNT); 548 + stats->rx_packets = ioread32(priv->mac_io + MAC_RX_FRAME_CNT); 549 + stats->tx_packets = ioread32(priv->mac_io + MAC_TX_FRAME_CNT); 550 + stats->rx_dropped = ioread8(priv->mac_io + MAC_DROPPED_FRMS); 551 + 552 + stats->tx_bytes = priv->stat_tx_bytes; 553 + stats->rx_bytes = priv->stat_rx_bytes; 554 + 555 + return stats; 556 + } 557 + 558 + static const struct net_device_ops ec_bhf_netdev_ops = { 559 + .ndo_start_xmit = ec_bhf_start_xmit, 560 + .ndo_open = ec_bhf_open, 561 + .ndo_stop = ec_bhf_stop, 562 + .ndo_get_stats64 = ec_bhf_get_stats, 563 + .ndo_change_mtu = eth_change_mtu, 564 + .ndo_validate_addr = eth_validate_addr, 565 + .ndo_set_mac_address = eth_mac_addr 566 + }; 567 + 568 + static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id) 569 + { 570 + struct net_device *net_dev; 571 + struct ec_bhf_priv *priv; 572 + void * __iomem dma_io; 573 + void * __iomem io; 574 + int err = 0; 575 + 576 + err = pci_enable_device(dev); 577 + if (err) 578 + return err; 579 + 580 + pci_set_master(dev); 581 + 582 + err = pci_set_dma_mask(dev, DMA_BIT_MASK(32)); 583 + if (err) { 584 + dev_err(&dev->dev, 585 + "Required dma mask not supported, failed to initialize device\n"); 586 + err = -EIO; 587 + goto err_disable_dev; 588 + } 589 + 590 + err = pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(32)); 591 + if (err) { 592 + dev_err(&dev->dev, 593 + "Required dma mask not supported, failed to initialize device\n"); 594 + goto err_disable_dev; 595 + } 596 + 597 + err = pci_request_regions(dev, "ec_bhf"); 598 + if (err) { 599 + dev_err(&dev->dev, "Failed to request pci memory regions\n"); 600 + goto err_disable_dev; 601 + } 602 + 603 + io = pci_iomap(dev, 0, 0); 604 + if (!io) { 605 + dev_err(&dev->dev, "Failed to map pci card memory bar 0"); 606 + err = -EIO; 607 + goto err_release_regions; 608 + } 609 + 610 + dma_io = pci_iomap(dev, 2, 0); 611 + if (!dma_io) { 612 + dev_err(&dev->dev, "Failed to map pci card memory bar 2"); 613 + err = -EIO; 614 + goto err_unmap; 615 + } 616 + 617 + net_dev = alloc_etherdev(sizeof(struct ec_bhf_priv)); 618 + if (net_dev == 0) { 619 + err = -ENOMEM; 620 + goto err_unmap_dma_io; 621 + } 622 + 623 + pci_set_drvdata(dev, net_dev); 624 + SET_NETDEV_DEV(net_dev, &dev->dev); 625 + 626 + net_dev->features = 0; 627 + net_dev->flags |= IFF_NOARP; 628 + 629 + net_dev->netdev_ops = &ec_bhf_netdev_ops; 630 + 631 + priv = netdev_priv(net_dev); 632 + priv->net_dev = net_dev; 633 + priv->io = io; 634 + priv->dma_io = dma_io; 635 + priv->dev = dev; 636 + 637 + err = ec_bhf_setup_offsets(priv); 638 + if (err < 0) 639 + goto err_free_net_dev; 640 + 641 + memcpy_fromio(net_dev->dev_addr, priv->mii_io + MII_MAC_ADDR, 6); 642 + 643 + dev_dbg(&dev->dev, "CX5020 Ethercat master address: %pM\n", 644 + net_dev->dev_addr); 645 + 646 + err = register_netdev(net_dev); 647 + if (err < 0) 648 + goto err_free_net_dev; 649 + 650 + return 0; 651 + 652 + err_free_net_dev: 653 + free_netdev(net_dev); 654 + err_unmap_dma_io: 655 + pci_iounmap(dev, dma_io); 656 + err_unmap: 657 + pci_iounmap(dev, io); 658 + err_release_regions: 659 + pci_release_regions(dev); 660 + err_disable_dev: 661 + pci_clear_master(dev); 662 + pci_disable_device(dev); 663 + 664 + return err; 665 + } 666 + 667 + static void ec_bhf_remove(struct pci_dev *dev) 668 + { 669 + struct net_device *net_dev = pci_get_drvdata(dev); 670 + struct ec_bhf_priv *priv = netdev_priv(net_dev); 671 + 672 + unregister_netdev(net_dev); 673 + free_netdev(net_dev); 674 + 675 + pci_iounmap(dev, priv->dma_io); 676 + pci_iounmap(dev, priv->io); 677 + pci_release_regions(dev); 678 + pci_clear_master(dev); 679 + pci_disable_device(dev); 680 + } 681 + 682 + static struct pci_driver pci_driver = { 683 + .name = "ec_bhf", 684 + .id_table = ids, 685 + .probe = ec_bhf_probe, 686 + .remove = ec_bhf_remove, 687 + }; 688 + 689 + static int __init ec_bhf_init(void) 690 + { 691 + return pci_register_driver(&pci_driver); 692 + } 693 + 694 + static void __exit ec_bhf_exit(void) 695 + { 696 + pci_unregister_driver(&pci_driver); 697 + } 698 + 699 + module_init(ec_bhf_init); 700 + module_exit(ec_bhf_exit); 701 + 702 + module_param(polling_frequency, long, S_IRUGO); 703 + MODULE_PARM_DESC(polling_frequency, "Polling timer frequency in ns"); 704 + 705 + MODULE_LICENSE("GPL"); 706 + MODULE_AUTHOR("Dariusz Marcinkiewicz <reksio@newterm.pl>");
+6
drivers/net/ethernet/emulex/benet/be_main.c
··· 4949 4949 if (status) 4950 4950 goto err; 4951 4951 4952 + /* On some BE3 FW versions, after a HW reset, 4953 + * interrupts will remain disabled for each function. 4954 + * So, explicitly enable interrupts 4955 + */ 4956 + be_intr_set(adapter, true); 4957 + 4952 4958 /* tell fw we're ready to fire cmds */ 4953 4959 status = be_cmd_fw_init(adapter); 4954 4960 if (status)
+47 -6
drivers/net/ethernet/jme.c
··· 1988 1988 return idx; 1989 1989 } 1990 1990 1991 - static void 1991 + static int 1992 1992 jme_fill_tx_map(struct pci_dev *pdev, 1993 1993 struct txdesc *txdesc, 1994 1994 struct jme_buffer_info *txbi, ··· 2004 2004 page_offset, 2005 2005 len, 2006 2006 PCI_DMA_TODEVICE); 2007 + 2008 + if (unlikely(pci_dma_mapping_error(pdev, dmaaddr))) 2009 + return -EINVAL; 2007 2010 2008 2011 pci_dma_sync_single_for_device(pdev, 2009 2012 dmaaddr, ··· 2024 2021 2025 2022 txbi->mapping = dmaaddr; 2026 2023 txbi->len = len; 2024 + return 0; 2027 2025 } 2028 2026 2029 - static void 2027 + static void jme_drop_tx_map(struct jme_adapter *jme, int startidx, int count) 2028 + { 2029 + struct jme_ring *txring = &(jme->txring[0]); 2030 + struct jme_buffer_info *txbi = txring->bufinf, *ctxbi; 2031 + int mask = jme->tx_ring_mask; 2032 + int j; 2033 + 2034 + for (j = 0 ; j < count ; j++) { 2035 + ctxbi = txbi + ((startidx + j + 2) & (mask)); 2036 + pci_unmap_page(jme->pdev, 2037 + ctxbi->mapping, 2038 + ctxbi->len, 2039 + PCI_DMA_TODEVICE); 2040 + 2041 + ctxbi->mapping = 0; 2042 + ctxbi->len = 0; 2043 + } 2044 + 2045 + } 2046 + 2047 + static int 2030 2048 jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx) 2031 2049 { 2032 2050 struct jme_ring *txring = &(jme->txring[0]); ··· 2058 2034 int mask = jme->tx_ring_mask; 2059 2035 const struct skb_frag_struct *frag; 2060 2036 u32 len; 2037 + int ret = 0; 2061 2038 2062 2039 for (i = 0 ; i < nr_frags ; ++i) { 2063 2040 frag = &skb_shinfo(skb)->frags[i]; 2064 2041 ctxdesc = txdesc + ((idx + i + 2) & (mask)); 2065 2042 ctxbi = txbi + ((idx + i + 2) & (mask)); 2066 2043 2067 - jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi, 2044 + ret = jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi, 2068 2045 skb_frag_page(frag), 2069 2046 frag->page_offset, skb_frag_size(frag), hidma); 2047 + if (ret) { 2048 + jme_drop_tx_map(jme, idx, i); 2049 + goto out; 2050 + } 2051 + 2070 2052 } 2071 2053 2072 2054 len = skb_is_nonlinear(skb) ? skb_headlen(skb) : skb->len; 2073 2055 ctxdesc = txdesc + ((idx + 1) & (mask)); 2074 2056 ctxbi = txbi + ((idx + 1) & (mask)); 2075 - jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi, virt_to_page(skb->data), 2057 + ret = jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi, virt_to_page(skb->data), 2076 2058 offset_in_page(skb->data), len, hidma); 2059 + if (ret) 2060 + jme_drop_tx_map(jme, idx, i); 2061 + 2062 + out: 2063 + return ret; 2077 2064 2078 2065 } 2066 + 2079 2067 2080 2068 static int 2081 2069 jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags) ··· 2167 2131 struct txdesc *txdesc; 2168 2132 struct jme_buffer_info *txbi; 2169 2133 u8 flags; 2134 + int ret = 0; 2170 2135 2171 2136 txdesc = (struct txdesc *)txring->desc + idx; 2172 2137 txbi = txring->bufinf + idx; ··· 2192 2155 if (jme_tx_tso(skb, &txdesc->desc1.mss, &flags)) 2193 2156 jme_tx_csum(jme, skb, &flags); 2194 2157 jme_tx_vlan(skb, &txdesc->desc1.vlan, &flags); 2195 - jme_map_tx_skb(jme, skb, idx); 2158 + ret = jme_map_tx_skb(jme, skb, idx); 2159 + if (ret) 2160 + return ret; 2161 + 2196 2162 txdesc->desc1.flags = flags; 2197 2163 /* 2198 2164 * Set tx buffer info after telling NIC to send ··· 2268 2228 return NETDEV_TX_BUSY; 2269 2229 } 2270 2230 2271 - jme_fill_tx_desc(jme, skb, idx); 2231 + if (jme_fill_tx_desc(jme, skb, idx)) 2232 + return NETDEV_TX_OK; 2272 2233 2273 2234 jwrite32(jme, JME_TXCS, jme->reg_txcs | 2274 2235 TXCS_SELECT_QUEUE0 |
+2 -2
drivers/net/ethernet/mellanox/mlx4/cmd.c
··· 1253 1253 }, 1254 1254 { 1255 1255 .opcode = MLX4_CMD_UPDATE_QP, 1256 - .has_inbox = false, 1256 + .has_inbox = true, 1257 1257 .has_outbox = false, 1258 1258 .out_is_imm = false, 1259 1259 .encode_slave_id = false, 1260 1260 .verify = NULL, 1261 - .wrapper = mlx4_CMD_EPERM_wrapper 1261 + .wrapper = mlx4_UPDATE_QP_wrapper 1262 1262 }, 1263 1263 { 1264 1264 .opcode = MLX4_CMD_GET_OP_REQ,
+6
drivers/net/ethernet/mellanox/mlx4/mlx4.h
··· 1195 1195 struct mlx4_cmd_mailbox *outbox, 1196 1196 struct mlx4_cmd_info *cmd); 1197 1197 1198 + int mlx4_UPDATE_QP_wrapper(struct mlx4_dev *dev, int slave, 1199 + struct mlx4_vhcr *vhcr, 1200 + struct mlx4_cmd_mailbox *inbox, 1201 + struct mlx4_cmd_mailbox *outbox, 1202 + struct mlx4_cmd_info *cmd); 1203 + 1198 1204 int mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave, 1199 1205 struct mlx4_vhcr *vhcr, 1200 1206 struct mlx4_cmd_mailbox *inbox,
+35
drivers/net/ethernet/mellanox/mlx4/qp.c
··· 389 389 390 390 EXPORT_SYMBOL_GPL(mlx4_qp_alloc); 391 391 392 + #define MLX4_UPDATE_QP_SUPPORTED_ATTRS MLX4_UPDATE_QP_SMAC 393 + int mlx4_update_qp(struct mlx4_dev *dev, struct mlx4_qp *qp, 394 + enum mlx4_update_qp_attr attr, 395 + struct mlx4_update_qp_params *params) 396 + { 397 + struct mlx4_cmd_mailbox *mailbox; 398 + struct mlx4_update_qp_context *cmd; 399 + u64 pri_addr_path_mask = 0; 400 + int err = 0; 401 + 402 + mailbox = mlx4_alloc_cmd_mailbox(dev); 403 + if (IS_ERR(mailbox)) 404 + return PTR_ERR(mailbox); 405 + 406 + cmd = (struct mlx4_update_qp_context *)mailbox->buf; 407 + 408 + if (!attr || (attr & ~MLX4_UPDATE_QP_SUPPORTED_ATTRS)) 409 + return -EINVAL; 410 + 411 + if (attr & MLX4_UPDATE_QP_SMAC) { 412 + pri_addr_path_mask |= 1ULL << MLX4_UPD_QP_PATH_MASK_MAC_INDEX; 413 + cmd->qp_context.pri_path.grh_mylmc = params->smac_index; 414 + } 415 + 416 + cmd->primary_addr_path_mask = cpu_to_be64(pri_addr_path_mask); 417 + 418 + err = mlx4_cmd(dev, mailbox->dma, qp->qpn & 0xffffff, 0, 419 + MLX4_CMD_UPDATE_QP, MLX4_CMD_TIME_CLASS_A, 420 + MLX4_CMD_NATIVE); 421 + 422 + mlx4_free_cmd_mailbox(dev, mailbox); 423 + return err; 424 + } 425 + EXPORT_SYMBOL_GPL(mlx4_update_qp); 426 + 392 427 void mlx4_qp_remove(struct mlx4_dev *dev, struct mlx4_qp *qp) 393 428 { 394 429 struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
+54
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
··· 3895 3895 3896 3896 } 3897 3897 3898 + #define MLX4_UPD_QP_PATH_MASK_SUPPORTED (1ULL << MLX4_UPD_QP_PATH_MASK_MAC_INDEX) 3899 + int mlx4_UPDATE_QP_wrapper(struct mlx4_dev *dev, int slave, 3900 + struct mlx4_vhcr *vhcr, 3901 + struct mlx4_cmd_mailbox *inbox, 3902 + struct mlx4_cmd_mailbox *outbox, 3903 + struct mlx4_cmd_info *cmd_info) 3904 + { 3905 + int err; 3906 + u32 qpn = vhcr->in_modifier & 0xffffff; 3907 + struct res_qp *rqp; 3908 + u64 mac; 3909 + unsigned port; 3910 + u64 pri_addr_path_mask; 3911 + struct mlx4_update_qp_context *cmd; 3912 + int smac_index; 3913 + 3914 + cmd = (struct mlx4_update_qp_context *)inbox->buf; 3915 + 3916 + pri_addr_path_mask = be64_to_cpu(cmd->primary_addr_path_mask); 3917 + if (cmd->qp_mask || cmd->secondary_addr_path_mask || 3918 + (pri_addr_path_mask & ~MLX4_UPD_QP_PATH_MASK_SUPPORTED)) 3919 + return -EPERM; 3920 + 3921 + /* Just change the smac for the QP */ 3922 + err = get_res(dev, slave, qpn, RES_QP, &rqp); 3923 + if (err) { 3924 + mlx4_err(dev, "Updating qpn 0x%x for slave %d rejected\n", qpn, slave); 3925 + return err; 3926 + } 3927 + 3928 + port = (rqp->sched_queue >> 6 & 1) + 1; 3929 + smac_index = cmd->qp_context.pri_path.grh_mylmc; 3930 + err = mac_find_smac_ix_in_slave(dev, slave, port, 3931 + smac_index, &mac); 3932 + if (err) { 3933 + mlx4_err(dev, "Failed to update qpn 0x%x, MAC is invalid. smac_ix: %d\n", 3934 + qpn, smac_index); 3935 + goto err_mac; 3936 + } 3937 + 3938 + err = mlx4_cmd(dev, inbox->dma, 3939 + vhcr->in_modifier, 0, 3940 + MLX4_CMD_UPDATE_QP, MLX4_CMD_TIME_CLASS_A, 3941 + MLX4_CMD_NATIVE); 3942 + if (err) { 3943 + mlx4_err(dev, "Failed to update qpn on qpn 0x%x, command failed\n", qpn); 3944 + goto err_mac; 3945 + } 3946 + 3947 + err_mac: 3948 + put_res(dev, slave, qpn, RES_QP); 3949 + return err; 3950 + } 3951 + 3898 3952 int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, 3899 3953 struct mlx4_vhcr *vhcr, 3900 3954 struct mlx4_cmd_mailbox *inbox,
-16
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
··· 1719 1719 tx_ring->producer; 1720 1720 } 1721 1721 1722 - static inline int qlcnic_set_real_num_queues(struct qlcnic_adapter *adapter, 1723 - struct net_device *netdev) 1724 - { 1725 - int err; 1726 - 1727 - netdev->num_tx_queues = adapter->drv_tx_rings; 1728 - netdev->real_num_tx_queues = adapter->drv_tx_rings; 1729 - 1730 - err = netif_set_real_num_tx_queues(netdev, adapter->drv_tx_rings); 1731 - if (err) 1732 - netdev_err(netdev, "failed to set %d Tx queues\n", 1733 - adapter->drv_tx_rings); 1734 - 1735 - return err; 1736 - } 1737 - 1738 1722 struct qlcnic_nic_template { 1739 1723 int (*config_bridged_mode) (struct qlcnic_adapter *, u32); 1740 1724 int (*config_led) (struct qlcnic_adapter *, u32, u32);
+53 -4
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
··· 2206 2206 ahw->max_uc_count = count; 2207 2207 } 2208 2208 2209 + static int qlcnic_set_real_num_queues(struct qlcnic_adapter *adapter, 2210 + u8 tx_queues, u8 rx_queues) 2211 + { 2212 + struct net_device *netdev = adapter->netdev; 2213 + int err = 0; 2214 + 2215 + if (tx_queues) { 2216 + err = netif_set_real_num_tx_queues(netdev, tx_queues); 2217 + if (err) { 2218 + netdev_err(netdev, "failed to set %d Tx queues\n", 2219 + tx_queues); 2220 + return err; 2221 + } 2222 + } 2223 + 2224 + if (rx_queues) { 2225 + err = netif_set_real_num_rx_queues(netdev, rx_queues); 2226 + if (err) 2227 + netdev_err(netdev, "failed to set %d Rx queues\n", 2228 + rx_queues); 2229 + } 2230 + 2231 + return err; 2232 + } 2233 + 2209 2234 int 2210 2235 qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev, 2211 2236 int pci_using_dac) ··· 2294 2269 netdev->priv_flags |= IFF_UNICAST_FLT; 2295 2270 netdev->irq = adapter->msix_entries[0].vector; 2296 2271 2297 - err = qlcnic_set_real_num_queues(adapter, netdev); 2272 + err = qlcnic_set_real_num_queues(adapter, adapter->drv_tx_rings, 2273 + adapter->drv_sds_rings); 2298 2274 if (err) 2299 2275 return err; 2300 2276 ··· 2969 2943 tx_ring->tx_stats.xmit_called, 2970 2944 tx_ring->tx_stats.xmit_on, 2971 2945 tx_ring->tx_stats.xmit_off); 2946 + 2947 + if (tx_ring->crb_intr_mask) 2948 + netdev_info(netdev, "crb_intr_mask=%d\n", 2949 + readl(tx_ring->crb_intr_mask)); 2950 + 2972 2951 netdev_info(netdev, 2973 - "crb_intr_mask=%d, hw_producer=%d, sw_producer=%d sw_consumer=%d, hw_consumer=%d\n", 2974 - readl(tx_ring->crb_intr_mask), 2952 + "hw_producer=%d, sw_producer=%d sw_consumer=%d, hw_consumer=%d\n", 2975 2953 readl(tx_ring->crb_cmd_producer), 2976 2954 tx_ring->producer, tx_ring->sw_consumer, 2977 2955 le32_to_cpu(*(tx_ring->hw_consumer))); ··· 4008 3978 int qlcnic_setup_rings(struct qlcnic_adapter *adapter) 4009 3979 { 4010 3980 struct net_device *netdev = adapter->netdev; 3981 + u8 tx_rings, rx_rings; 4011 3982 int err; 4012 3983 4013 3984 if (test_bit(__QLCNIC_RESETTING, &adapter->state)) 4014 3985 return -EBUSY; 4015 3986 3987 + tx_rings = adapter->drv_tss_rings; 3988 + rx_rings = adapter->drv_rss_rings; 3989 + 4016 3990 netif_device_detach(netdev); 3991 + 3992 + err = qlcnic_set_real_num_queues(adapter, tx_rings, rx_rings); 3993 + if (err) 3994 + goto done; 3995 + 4017 3996 if (netif_running(netdev)) 4018 3997 __qlcnic_down(adapter, netdev); 4019 3998 ··· 4042 4003 return err; 4043 4004 } 4044 4005 4045 - netif_set_real_num_tx_queues(netdev, adapter->drv_tx_rings); 4006 + /* Check if we need to update real_num_{tx|rx}_queues because 4007 + * qlcnic_setup_intr() may change Tx/Rx rings size 4008 + */ 4009 + if ((tx_rings != adapter->drv_tx_rings) || 4010 + (rx_rings != adapter->drv_sds_rings)) { 4011 + err = qlcnic_set_real_num_queues(adapter, 4012 + adapter->drv_tx_rings, 4013 + adapter->drv_sds_rings); 4014 + if (err) 4015 + goto done; 4016 + } 4046 4017 4047 4018 if (qlcnic_83xx_check(adapter)) { 4048 4019 qlcnic_83xx_initialize_nic(adapter, 1);
+8 -6
drivers/net/ethernet/sfc/nic.c
··· 156 156 efx->net_dev->rx_cpu_rmap = NULL; 157 157 #endif 158 158 159 - /* Disable MSI/MSI-X interrupts */ 160 - efx_for_each_channel(channel, efx) 161 - free_irq(channel->irq, &efx->msi_context[channel->channel]); 162 - 163 - /* Disable legacy interrupt */ 164 - if (efx->legacy_irq) 159 + if (EFX_INT_MODE_USE_MSI(efx)) { 160 + /* Disable MSI/MSI-X interrupts */ 161 + efx_for_each_channel(channel, efx) 162 + free_irq(channel->irq, 163 + &efx->msi_context[channel->channel]); 164 + } else { 165 + /* Disable legacy interrupt */ 165 166 free_irq(efx->legacy_irq, efx); 167 + } 166 168 } 167 169 168 170 /* Register dump */
+1 -3
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1704 1704 if (ret) { 1705 1705 pr_err("%s: Cannot attach to PHY (error: %d)\n", 1706 1706 __func__, ret); 1707 - goto phy_error; 1707 + return ret; 1708 1708 } 1709 1709 } 1710 1710 ··· 1779 1779 dma_desc_error: 1780 1780 if (priv->phydev) 1781 1781 phy_disconnect(priv->phydev); 1782 - phy_error: 1783 - clk_disable_unprepare(priv->stmmac_clk); 1784 1782 1785 1783 return ret; 1786 1784 }
+1 -1
drivers/net/ethernet/sun/cassini.c
··· 246 246 int i; 247 247 248 248 for (i = 0; i < N_TX_RINGS; i++) 249 - spin_lock(&cp->tx_lock[i]); 249 + spin_lock_nested(&cp->tx_lock[i], i); 250 250 } 251 251 252 252 static inline void cas_lock_all(struct cas *cp)
+6 -11
drivers/net/ethernet/ti/cpsw.c
··· 1871 1871 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); 1872 1872 phyid = be32_to_cpup(parp+1); 1873 1873 mdio = of_find_device_by_node(mdio_node); 1874 - 1875 - if (strncmp(mdio->name, "gpio", 4) == 0) { 1876 - /* GPIO bitbang MDIO driver attached */ 1877 - struct mii_bus *bus = dev_get_drvdata(&mdio->dev); 1878 - 1879 - snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 1880 - PHY_ID_FMT, bus->id, phyid); 1881 - } else { 1882 - /* davinci MDIO driver attached */ 1883 - snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 1884 - PHY_ID_FMT, mdio->name, phyid); 1874 + of_node_put(mdio_node); 1875 + if (!mdio) { 1876 + pr_err("Missing mdio platform device\n"); 1877 + return -EINVAL; 1885 1878 } 1879 + snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 1880 + PHY_ID_FMT, mdio->name, phyid); 1886 1881 1887 1882 mac_addr = of_get_mac_address(slave_node); 1888 1883 if (mac_addr)
+14 -4
drivers/net/macvlan.c
··· 458 458 struct macvlan_dev *vlan = netdev_priv(dev); 459 459 struct net_device *lowerdev = vlan->lowerdev; 460 460 461 - if (change & IFF_ALLMULTI) 462 - dev_set_allmulti(lowerdev, dev->flags & IFF_ALLMULTI ? 1 : -1); 461 + if (dev->flags & IFF_UP) { 462 + if (change & IFF_ALLMULTI) 463 + dev_set_allmulti(lowerdev, dev->flags & IFF_ALLMULTI ? 1 : -1); 464 + } 463 465 } 464 466 465 467 static void macvlan_set_mac_lists(struct net_device *dev) ··· 517 515 #define MACVLAN_STATE_MASK \ 518 516 ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT)) 519 517 518 + static int macvlan_get_nest_level(struct net_device *dev) 519 + { 520 + return ((struct macvlan_dev *)netdev_priv(dev))->nest_level; 521 + } 522 + 520 523 static void macvlan_set_lockdep_class_one(struct net_device *dev, 521 524 struct netdev_queue *txq, 522 525 void *_unused) ··· 532 525 533 526 static void macvlan_set_lockdep_class(struct net_device *dev) 534 527 { 535 - lockdep_set_class(&dev->addr_list_lock, 536 - &macvlan_netdev_addr_lock_key); 528 + lockdep_set_class_and_subclass(&dev->addr_list_lock, 529 + &macvlan_netdev_addr_lock_key, 530 + macvlan_get_nest_level(dev)); 537 531 netdev_for_each_tx_queue(dev, macvlan_set_lockdep_class_one, NULL); 538 532 } 539 533 ··· 729 721 .ndo_fdb_add = macvlan_fdb_add, 730 722 .ndo_fdb_del = macvlan_fdb_del, 731 723 .ndo_fdb_dump = ndo_dflt_fdb_dump, 724 + .ndo_get_lock_subclass = macvlan_get_nest_level, 732 725 }; 733 726 734 727 void macvlan_common_setup(struct net_device *dev) ··· 858 849 vlan->dev = dev; 859 850 vlan->port = port; 860 851 vlan->set_features = MACVLAN_FEATURES; 852 + vlan->nest_level = dev_get_nest_level(lowerdev, netif_is_macvlan) + 1; 861 853 862 854 vlan->mode = MACVLAN_MODE_VEPA; 863 855 if (data && data[IFLA_MACVLAN_MODE])
+4
drivers/net/phy/mdio-gpio.c
··· 215 215 if (pdev->dev.of_node) { 216 216 pdata = mdio_gpio_of_get_data(pdev); 217 217 bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio"); 218 + if (bus_id < 0) { 219 + dev_warn(&pdev->dev, "failed to get alias id\n"); 220 + bus_id = 0; 221 + } 218 222 } else { 219 223 pdata = dev_get_platdata(&pdev->dev); 220 224 bus_id = pdev->id;
+9 -7
drivers/net/phy/phy.c
··· 715 715 struct delayed_work *dwork = to_delayed_work(work); 716 716 struct phy_device *phydev = 717 717 container_of(dwork, struct phy_device, state_queue); 718 - int needs_aneg = 0, do_suspend = 0; 718 + bool needs_aneg = false, do_suspend = false, do_resume = false; 719 719 int err = 0; 720 720 721 721 mutex_lock(&phydev->lock); ··· 727 727 case PHY_PENDING: 728 728 break; 729 729 case PHY_UP: 730 - needs_aneg = 1; 730 + needs_aneg = true; 731 731 732 732 phydev->link_timeout = PHY_AN_TIMEOUT; 733 733 ··· 757 757 phydev->adjust_link(phydev->attached_dev); 758 758 759 759 } else if (0 == phydev->link_timeout--) 760 - needs_aneg = 1; 760 + needs_aneg = true; 761 761 break; 762 762 case PHY_NOLINK: 763 763 err = phy_read_status(phydev); ··· 791 791 netif_carrier_on(phydev->attached_dev); 792 792 } else { 793 793 if (0 == phydev->link_timeout--) 794 - needs_aneg = 1; 794 + needs_aneg = true; 795 795 } 796 796 797 797 phydev->adjust_link(phydev->attached_dev); ··· 827 827 phydev->link = 0; 828 828 netif_carrier_off(phydev->attached_dev); 829 829 phydev->adjust_link(phydev->attached_dev); 830 - do_suspend = 1; 830 + do_suspend = true; 831 831 } 832 832 break; 833 833 case PHY_RESUMING: ··· 876 876 } 877 877 phydev->adjust_link(phydev->attached_dev); 878 878 } 879 + do_resume = true; 879 880 break; 880 881 } 881 882 ··· 884 883 885 884 if (needs_aneg) 886 885 err = phy_start_aneg(phydev); 887 - 888 - if (do_suspend) 886 + else if (do_suspend) 889 887 phy_suspend(phydev); 888 + else if (do_resume) 889 + phy_resume(phydev); 890 890 891 891 if (err < 0) 892 892 phy_error(phydev);
+2 -2
drivers/net/phy/phy_device.c
··· 614 614 err = phy_init_hw(phydev); 615 615 if (err) 616 616 phy_detach(phydev); 617 - 618 - phy_resume(phydev); 617 + else 618 + phy_resume(phydev); 619 619 620 620 return err; 621 621 }
+41 -16
drivers/net/usb/cdc_mbim.c
··· 120 120 cdc_ncm_unbind(dev, intf); 121 121 } 122 122 123 + /* verify that the ethernet protocol is IPv4 or IPv6 */ 124 + static bool is_ip_proto(__be16 proto) 125 + { 126 + switch (proto) { 127 + case htons(ETH_P_IP): 128 + case htons(ETH_P_IPV6): 129 + return true; 130 + } 131 + return false; 132 + } 123 133 124 134 static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 125 135 { ··· 138 128 struct cdc_ncm_ctx *ctx = info->ctx; 139 129 __le32 sign = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN); 140 130 u16 tci = 0; 131 + bool is_ip; 141 132 u8 *c; 142 133 143 134 if (!ctx) ··· 148 137 if (skb->len <= ETH_HLEN) 149 138 goto error; 150 139 140 + /* Some applications using e.g. packet sockets will 141 + * bypass the VLAN acceleration and create tagged 142 + * ethernet frames directly. We primarily look for 143 + * the accelerated out-of-band tag, but fall back if 144 + * required 145 + */ 146 + skb_reset_mac_header(skb); 147 + if (vlan_get_tag(skb, &tci) < 0 && skb->len > VLAN_ETH_HLEN && 148 + __vlan_get_tag(skb, &tci) == 0) { 149 + is_ip = is_ip_proto(vlan_eth_hdr(skb)->h_vlan_encapsulated_proto); 150 + skb_pull(skb, VLAN_ETH_HLEN); 151 + } else { 152 + is_ip = is_ip_proto(eth_hdr(skb)->h_proto); 153 + skb_pull(skb, ETH_HLEN); 154 + } 155 + 151 156 /* mapping VLANs to MBIM sessions: 152 157 * no tag => IPS session <0> 153 158 * 1 - 255 => IPS session <vlanid> 154 159 * 256 - 511 => DSS session <vlanid - 256> 155 160 * 512 - 4095 => unsupported, drop 156 161 */ 157 - vlan_get_tag(skb, &tci); 158 - 159 162 switch (tci & 0x0f00) { 160 163 case 0x0000: /* VLAN ID 0 - 255 */ 161 - /* verify that datagram is IPv4 or IPv6 */ 162 - skb_reset_mac_header(skb); 163 - switch (eth_hdr(skb)->h_proto) { 164 - case htons(ETH_P_IP): 165 - case htons(ETH_P_IPV6): 166 - break; 167 - default: 164 + if (!is_ip) 168 165 goto error; 169 - } 170 166 c = (u8 *)&sign; 171 167 c[3] = tci; 172 168 break; ··· 187 169 "unsupported tci=0x%04x\n", tci); 188 170 goto error; 189 171 } 190 - skb_pull(skb, ETH_HLEN); 191 172 } 192 173 193 174 spin_lock_bh(&ctx->mtx); ··· 221 204 return; 222 205 223 206 /* need to send the NA on the VLAN dev, if any */ 224 - if (tci) 207 + rcu_read_lock(); 208 + if (tci) { 225 209 netdev = __vlan_find_dev_deep(dev->net, htons(ETH_P_8021Q), 226 210 tci); 227 - else 211 + if (!netdev) { 212 + rcu_read_unlock(); 213 + return; 214 + } 215 + } else { 228 216 netdev = dev->net; 229 - if (!netdev) 230 - return; 217 + } 218 + dev_hold(netdev); 219 + rcu_read_unlock(); 231 220 232 221 in6_dev = in6_dev_get(netdev); 233 222 if (!in6_dev) 234 - return; 223 + goto out; 235 224 is_router = !!in6_dev->cnf.forwarding; 236 225 in6_dev_put(in6_dev); 237 226 ··· 247 224 true /* solicited */, 248 225 false /* override */, 249 226 true /* inc_opt */); 227 + out: 228 + dev_put(netdev); 250 229 } 251 230 252 231 static bool is_neigh_solicit(u8 *buf, size_t len)
+4 -1
drivers/net/wireless/ath/ath9k/htc_drv_main.c
··· 95 95 96 96 if ((vif->type == NL80211_IFTYPE_AP || 97 97 vif->type == NL80211_IFTYPE_MESH_POINT) && 98 - bss_conf->enable_beacon) 98 + bss_conf->enable_beacon) { 99 99 priv->reconfig_beacon = true; 100 + priv->rearm_ani = true; 101 + } 100 102 101 103 if (bss_conf->assoc) { 102 104 priv->rearm_ani = true; ··· 259 257 260 258 ath9k_htc_ps_wakeup(priv); 261 259 260 + ath9k_htc_stop_ani(priv); 262 261 del_timer_sync(&priv->tx.cleanup_timer); 263 262 ath9k_htc_tx_drain(priv); 264 263
+1 -1
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
··· 4948 4948 if (!err) { 4949 4949 /* only set 2G bandwidth using bw_cap command */ 4950 4950 band_bwcap.band = cpu_to_le32(WLC_BAND_2G); 4951 - band_bwcap.bw_cap = cpu_to_le32(WLC_BW_40MHZ_BIT); 4951 + band_bwcap.bw_cap = cpu_to_le32(WLC_BW_CAP_40MHZ); 4952 4952 err = brcmf_fil_iovar_data_set(ifp, "bw_cap", &band_bwcap, 4953 4953 sizeof(band_bwcap)); 4954 4954 } else {
+3 -3
drivers/net/wireless/iwlwifi/mvm/coex.c
··· 611 611 bt_cmd->flags |= cpu_to_le32(BT_COEX_SYNC2SCO); 612 612 613 613 if (IWL_MVM_BT_COEX_CORUNNING) { 614 - bt_cmd->valid_bit_msk = cpu_to_le32(BT_VALID_CORUN_LUT_20 | 615 - BT_VALID_CORUN_LUT_40); 614 + bt_cmd->valid_bit_msk |= cpu_to_le32(BT_VALID_CORUN_LUT_20 | 615 + BT_VALID_CORUN_LUT_40); 616 616 bt_cmd->flags |= cpu_to_le32(BT_COEX_CORUNNING); 617 617 } 618 618 619 619 if (IWL_MVM_BT_COEX_MPLUT) { 620 620 bt_cmd->flags |= cpu_to_le32(BT_COEX_MPLUT); 621 - bt_cmd->valid_bit_msk = cpu_to_le32(BT_VALID_MULTI_PRIO_LUT); 621 + bt_cmd->valid_bit_msk |= cpu_to_le32(BT_VALID_MULTI_PRIO_LUT); 622 622 } 623 623 624 624 if (mvm->cfg->bt_shared_single_ant)
+4 -4
drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
··· 183 183 * this number of packets were received (typically 1) 184 184 * @passive2active: is auto switching from passive to active during scan allowed 185 185 * @rxchain_sel_flags: RXON_RX_CHAIN_* 186 - * @max_out_time: in usecs, max out of serving channel time 186 + * @max_out_time: in TUs, max out of serving channel time 187 187 * @suspend_time: how long to pause scan when returning to service channel: 188 - * bits 0-19: beacon interal in usecs (suspend before executing) 188 + * bits 0-19: beacon interal in TUs (suspend before executing) 189 189 * bits 20-23: reserved 190 190 * bits 24-31: number of beacons (suspend between channels) 191 191 * @rxon_flags: RXON_FLG_* ··· 383 383 * @quiet_plcp_th: quiet channel num of packets threshold 384 384 * @good_CRC_th: passive to active promotion threshold 385 385 * @rx_chain: RXON rx chain. 386 - * @max_out_time: max uSec to be out of assoceated channel 387 - * @suspend_time: pause scan this long when returning to service channel 386 + * @max_out_time: max TUs to be out of assoceated channel 387 + * @suspend_time: pause scan this TUs when returning to service channel 388 388 * @flags: RXON flags 389 389 * @filter_flags: RXONfilter 390 390 * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz.
+7 -2
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 1007 1007 memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN); 1008 1008 len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4); 1009 1009 1010 - ret = iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC, len, cmd); 1010 + ret = iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_ASYNC, len, cmd); 1011 1011 if (ret) 1012 1012 IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret); 1013 1013 } ··· 1023 1023 if (WARN_ON_ONCE(!mvm->mcast_filter_cmd)) 1024 1024 return; 1025 1025 1026 - ieee80211_iterate_active_interfaces( 1026 + ieee80211_iterate_active_interfaces_atomic( 1027 1027 mvm->hw, IEEE80211_IFACE_ITER_NORMAL, 1028 1028 iwl_mvm_mc_iface_iterator, &iter_data); 1029 1029 } ··· 1806 1806 int ret; 1807 1807 1808 1808 mutex_lock(&mvm->mutex); 1809 + 1810 + if (!iwl_mvm_is_idle(mvm)) { 1811 + ret = -EBUSY; 1812 + goto out; 1813 + } 1809 1814 1810 1815 switch (mvm->scan_status) { 1811 1816 case IWL_MVM_SCAN_OS:
+3
drivers/net/wireless/iwlwifi/mvm/mvm.h
··· 1003 1003 return mvmvif->low_latency; 1004 1004 } 1005 1005 1006 + /* Assoc status */ 1007 + bool iwl_mvm_is_idle(struct iwl_mvm *mvm); 1008 + 1006 1009 /* Thermal management and CT-kill */ 1007 1010 void iwl_mvm_tt_tx_backoff(struct iwl_mvm *mvm, u32 backoff); 1008 1011 void iwl_mvm_tt_handler(struct iwl_mvm *mvm);
+1 -1
drivers/net/wireless/iwlwifi/mvm/rs.c
··· 1010 1010 return; 1011 1011 } 1012 1012 1013 - #ifdef CPTCFG_MAC80211_DEBUGFS 1013 + #ifdef CONFIG_MAC80211_DEBUGFS 1014 1014 /* Disable last tx check if we are debugging with fixed rate */ 1015 1015 if (lq_sta->dbg_fixed_rate) { 1016 1016 IWL_DEBUG_RATE(mvm, "Fixed rate. avoid rate scaling\n");
+13 -42
drivers/net/wireless/iwlwifi/mvm/scan.c
··· 277 277 IEEE80211_IFACE_ITER_NORMAL, 278 278 iwl_mvm_scan_condition_iterator, 279 279 &global_bound); 280 - /* 281 - * Under low latency traffic passive scan is fragmented meaning 282 - * that dwell on a particular channel will be fragmented. Each fragment 283 - * dwell time is 20ms and fragments period is 105ms. Skipping to next 284 - * channel will be delayed by the same period - 105ms. So suspend_time 285 - * parameter describing both fragments and channels skipping periods is 286 - * set to 105ms. This value is chosen so that overall passive scan 287 - * duration will not be too long. Max_out_time in this case is set to 288 - * 70ms, so for active scanning operating channel will be left for 70ms 289 - * while for passive still for 20ms (fragment dwell). 290 - */ 291 - if (global_bound) { 292 - if (!iwl_mvm_low_latency(mvm)) { 293 - params->suspend_time = ieee80211_tu_to_usec(100); 294 - params->max_out_time = ieee80211_tu_to_usec(600); 295 - } else { 296 - params->suspend_time = ieee80211_tu_to_usec(105); 297 - /* P2P doesn't support fragmented passive scan, so 298 - * configure max_out_time to be at least longest dwell 299 - * time for passive scan. 300 - */ 301 - if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p) { 302 - params->max_out_time = ieee80211_tu_to_usec(70); 303 - params->passive_fragmented = true; 304 - } else { 305 - u32 passive_dwell; 306 280 307 - /* 308 - * Use band G so that passive channel dwell time 309 - * will be assigned with maximum value. 310 - */ 311 - band = IEEE80211_BAND_2GHZ; 312 - passive_dwell = iwl_mvm_get_passive_dwell(band); 313 - params->max_out_time = 314 - ieee80211_tu_to_usec(passive_dwell); 315 - } 316 - } 281 + if (!global_bound) 282 + goto not_bound; 283 + 284 + params->suspend_time = 100; 285 + params->max_out_time = 600; 286 + 287 + if (iwl_mvm_low_latency(mvm)) { 288 + params->suspend_time = 250; 289 + params->max_out_time = 250; 317 290 } 318 291 292 + not_bound: 293 + 319 294 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { 320 - if (params->passive_fragmented) 321 - params->dwell[band].passive = 20; 322 - else 323 - params->dwell[band].passive = 324 - iwl_mvm_get_passive_dwell(band); 295 + params->dwell[band].passive = iwl_mvm_get_passive_dwell(band); 325 296 params->dwell[band].active = iwl_mvm_get_active_dwell(band, 326 297 n_ssids); 327 298 } ··· 732 761 int band_2ghz = mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels; 733 762 int band_5ghz = mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; 734 763 int head = 0; 735 - int tail = band_2ghz + band_5ghz; 764 + int tail = band_2ghz + band_5ghz - 1; 736 765 u32 ssid_bitmap; 737 766 int cmd_len; 738 767 int ret;
+19
drivers/net/wireless/iwlwifi/mvm/utils.c
··· 644 644 645 645 return result; 646 646 } 647 + 648 + static void iwl_mvm_idle_iter(void *_data, u8 *mac, struct ieee80211_vif *vif) 649 + { 650 + bool *idle = _data; 651 + 652 + if (!vif->bss_conf.idle) 653 + *idle = false; 654 + } 655 + 656 + bool iwl_mvm_is_idle(struct iwl_mvm *mvm) 657 + { 658 + bool idle = true; 659 + 660 + ieee80211_iterate_active_interfaces_atomic( 661 + mvm->hw, IEEE80211_IFACE_ITER_NORMAL, 662 + iwl_mvm_idle_iter, &idle); 663 + 664 + return idle; 665 + }
+6 -4
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 1749 1749 * PCI Tx retries from interfering with C3 CPU state */ 1750 1750 pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); 1751 1751 1752 + trans->dev = &pdev->dev; 1753 + trans_pcie->pci_dev = pdev; 1754 + iwl_disable_interrupts(trans); 1755 + 1752 1756 err = pci_enable_msi(pdev); 1753 1757 if (err) { 1754 1758 dev_err(&pdev->dev, "pci_enable_msi failed(0X%x)\n", err); ··· 1764 1760 } 1765 1761 } 1766 1762 1767 - trans->dev = &pdev->dev; 1768 - trans_pcie->pci_dev = pdev; 1769 1763 trans->hw_rev = iwl_read32(trans, CSR_HW_REV); 1770 1764 trans->hw_id = (pdev->device << 16) + pdev->subsystem_device; 1771 1765 snprintf(trans->hw_id_str, sizeof(trans->hw_id_str), ··· 1789 1787 goto out_pci_disable_msi; 1790 1788 } 1791 1789 1792 - trans_pcie->inta_mask = CSR_INI_SET_MASK; 1793 - 1794 1790 if (iwl_pcie_alloc_ict(trans)) 1795 1791 goto out_free_cmd_pool; 1796 1792 ··· 1799 1799 IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq); 1800 1800 goto out_free_ict; 1801 1801 } 1802 + 1803 + trans_pcie->inta_mask = CSR_INI_SET_MASK; 1802 1804 1803 1805 return trans; 1804 1806
+1 -1
drivers/net/xen-netback/common.h
··· 226 226 grant_ref_t rx_ring_ref); 227 227 228 228 /* Check for SKBs from frontend and schedule backend processing */ 229 - void xenvif_check_rx_xenvif(struct xenvif *vif); 229 + void xenvif_napi_schedule_or_enable_events(struct xenvif *vif); 230 230 231 231 /* Prevent the device from generating any further traffic. */ 232 232 void xenvif_carrier_off(struct xenvif *vif);
+3 -27
drivers/net/xen-netback/interface.c
··· 75 75 work_done = xenvif_tx_action(vif, budget); 76 76 77 77 if (work_done < budget) { 78 - int more_to_do = 0; 79 - unsigned long flags; 80 - 81 - /* It is necessary to disable IRQ before calling 82 - * RING_HAS_UNCONSUMED_REQUESTS. Otherwise we might 83 - * lose event from the frontend. 84 - * 85 - * Consider: 86 - * RING_HAS_UNCONSUMED_REQUESTS 87 - * <frontend generates event to trigger napi_schedule> 88 - * __napi_complete 89 - * 90 - * This handler is still in scheduled state so the 91 - * event has no effect at all. After __napi_complete 92 - * this handler is descheduled and cannot get 93 - * scheduled again. We lose event in this case and the ring 94 - * will be completely stalled. 95 - */ 96 - 97 - local_irq_save(flags); 98 - 99 - RING_FINAL_CHECK_FOR_REQUESTS(&vif->tx, more_to_do); 100 - if (!more_to_do) 101 - __napi_complete(napi); 102 - 103 - local_irq_restore(flags); 78 + napi_complete(napi); 79 + xenvif_napi_schedule_or_enable_events(vif); 104 80 } 105 81 106 82 return work_done; ··· 170 194 enable_irq(vif->tx_irq); 171 195 if (vif->tx_irq != vif->rx_irq) 172 196 enable_irq(vif->rx_irq); 173 - xenvif_check_rx_xenvif(vif); 197 + xenvif_napi_schedule_or_enable_events(vif); 174 198 } 175 199 176 200 static void xenvif_down(struct xenvif *vif)
+82 -20
drivers/net/xen-netback/netback.c
··· 104 104 105 105 /* Find the containing VIF's structure from a pointer in pending_tx_info array 106 106 */ 107 - static inline struct xenvif* ubuf_to_vif(struct ubuf_info *ubuf) 107 + static inline struct xenvif *ubuf_to_vif(const struct ubuf_info *ubuf) 108 108 { 109 109 u16 pending_idx = ubuf->desc; 110 110 struct pending_tx_info *temp = ··· 323 323 } 324 324 325 325 /* 326 + * Find the grant ref for a given frag in a chain of struct ubuf_info's 327 + * skb: the skb itself 328 + * i: the frag's number 329 + * ubuf: a pointer to an element in the chain. It should not be NULL 330 + * 331 + * Returns a pointer to the element in the chain where the page were found. If 332 + * not found, returns NULL. 333 + * See the definition of callback_struct in common.h for more details about 334 + * the chain. 335 + */ 336 + static const struct ubuf_info *xenvif_find_gref(const struct sk_buff *const skb, 337 + const int i, 338 + const struct ubuf_info *ubuf) 339 + { 340 + struct xenvif *foreign_vif = ubuf_to_vif(ubuf); 341 + 342 + do { 343 + u16 pending_idx = ubuf->desc; 344 + 345 + if (skb_shinfo(skb)->frags[i].page.p == 346 + foreign_vif->mmap_pages[pending_idx]) 347 + break; 348 + ubuf = (struct ubuf_info *) ubuf->ctx; 349 + } while (ubuf); 350 + 351 + return ubuf; 352 + } 353 + 354 + /* 326 355 * Prepare an SKB to be transmitted to the frontend. 327 356 * 328 357 * This function is responsible for allocating grant operations, meta ··· 375 346 int head = 1; 376 347 int old_meta_prod; 377 348 int gso_type; 378 - struct ubuf_info *ubuf = skb_shinfo(skb)->destructor_arg; 379 - grant_ref_t foreign_grefs[MAX_SKB_FRAGS]; 380 - struct xenvif *foreign_vif = NULL; 349 + const struct ubuf_info *ubuf = skb_shinfo(skb)->destructor_arg; 350 + const struct ubuf_info *const head_ubuf = ubuf; 381 351 382 352 old_meta_prod = npo->meta_prod; 383 353 ··· 414 386 npo->copy_off = 0; 415 387 npo->copy_gref = req->gref; 416 388 417 - if ((skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) && 418 - (ubuf->callback == &xenvif_zerocopy_callback)) { 419 - int i = 0; 420 - foreign_vif = ubuf_to_vif(ubuf); 421 - 422 - do { 423 - u16 pending_idx = ubuf->desc; 424 - foreign_grefs[i++] = 425 - foreign_vif->pending_tx_info[pending_idx].req.gref; 426 - ubuf = (struct ubuf_info *) ubuf->ctx; 427 - } while (ubuf); 428 - } 429 - 430 389 data = skb->data; 431 390 while (data < skb_tail_pointer(skb)) { 432 391 unsigned int offset = offset_in_page(data); ··· 430 415 } 431 416 432 417 for (i = 0; i < nr_frags; i++) { 418 + /* This variable also signals whether foreign_gref has a real 419 + * value or not. 420 + */ 421 + struct xenvif *foreign_vif = NULL; 422 + grant_ref_t foreign_gref; 423 + 424 + if ((skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) && 425 + (ubuf->callback == &xenvif_zerocopy_callback)) { 426 + const struct ubuf_info *const startpoint = ubuf; 427 + 428 + /* Ideally ubuf points to the chain element which 429 + * belongs to this frag. Or if frags were removed from 430 + * the beginning, then shortly before it. 431 + */ 432 + ubuf = xenvif_find_gref(skb, i, ubuf); 433 + 434 + /* Try again from the beginning of the list, if we 435 + * haven't tried from there. This only makes sense in 436 + * the unlikely event of reordering the original frags. 437 + * For injected local pages it's an unnecessary second 438 + * run. 439 + */ 440 + if (unlikely(!ubuf) && startpoint != head_ubuf) 441 + ubuf = xenvif_find_gref(skb, i, head_ubuf); 442 + 443 + if (likely(ubuf)) { 444 + u16 pending_idx = ubuf->desc; 445 + 446 + foreign_vif = ubuf_to_vif(ubuf); 447 + foreign_gref = foreign_vif->pending_tx_info[pending_idx].req.gref; 448 + /* Just a safety measure. If this was the last 449 + * element on the list, the for loop will 450 + * iterate again if a local page were added to 451 + * the end. Using head_ubuf here prevents the 452 + * second search on the chain. Or the original 453 + * frags changed order, but that's less likely. 454 + * In any way, ubuf shouldn't be NULL. 455 + */ 456 + ubuf = ubuf->ctx ? 457 + (struct ubuf_info *) ubuf->ctx : 458 + head_ubuf; 459 + } else 460 + /* This frag was a local page, added to the 461 + * array after the skb left netback. 462 + */ 463 + ubuf = head_ubuf; 464 + } 433 465 xenvif_gop_frag_copy(vif, skb, npo, 434 466 skb_frag_page(&skb_shinfo(skb)->frags[i]), 435 467 skb_frag_size(&skb_shinfo(skb)->frags[i]), 436 468 skb_shinfo(skb)->frags[i].page_offset, 437 469 &head, 438 470 foreign_vif, 439 - foreign_grefs[i]); 471 + foreign_vif ? foreign_gref : UINT_MAX); 440 472 } 441 473 442 474 return npo->meta_prod - old_meta_prod; ··· 716 654 notify_remote_via_irq(vif->rx_irq); 717 655 } 718 656 719 - void xenvif_check_rx_xenvif(struct xenvif *vif) 657 + void xenvif_napi_schedule_or_enable_events(struct xenvif *vif) 720 658 { 721 659 int more_to_do; 722 660 ··· 750 688 { 751 689 struct xenvif *vif = (struct xenvif *)data; 752 690 tx_add_credit(vif); 753 - xenvif_check_rx_xenvif(vif); 691 + xenvif_napi_schedule_or_enable_events(vif); 754 692 } 755 693 756 694 static void xenvif_tx_err(struct xenvif *vif,
+2 -1
drivers/ptp/Kconfig
··· 6 6 7 7 config PTP_1588_CLOCK 8 8 tristate "PTP clock support" 9 + depends on NET 9 10 select PPS 10 11 select NET_PTP_CLASSIFY 11 12 help ··· 75 74 config PTP_1588_CLOCK_PCH 76 75 tristate "Intel PCH EG20T as PTP clock" 77 76 depends on X86 || COMPILE_TEST 78 - depends on HAS_IOMEM 77 + depends on HAS_IOMEM && NET 79 78 select PTP_1588_CLOCK 80 79 help 81 80 This driver adds support for using the PCH EG20T as a PTP
+1 -2
drivers/scsi/scsi_transport_sas.c
··· 1621 1621 list_del(&rphy->list); 1622 1622 mutex_unlock(&sas_host->lock); 1623 1623 1624 - sas_bsg_remove(shost, rphy); 1625 - 1626 1624 transport_destroy_device(dev); 1627 1625 1628 1626 put_device(dev); ··· 1679 1681 } 1680 1682 1681 1683 sas_rphy_unlink(rphy); 1684 + sas_bsg_remove(NULL, rphy); 1682 1685 transport_remove_device(dev); 1683 1686 device_del(dev); 1684 1687 }
+19
fs/afs/cmservice.c
··· 130 130 { 131 131 _enter(""); 132 132 133 + /* Break the callbacks here so that we do it after the final ACK is 134 + * received. The step number here must match the final number in 135 + * afs_deliver_cb_callback(). 136 + */ 137 + if (call->unmarshall == 6) { 138 + ASSERT(call->server && call->count && call->request); 139 + afs_break_callbacks(call->server, call->count, call->request); 140 + } 141 + 133 142 afs_put_server(call->server); 134 143 call->server = NULL; 135 144 kfree(call->buffer); ··· 281 272 _debug("trailer"); 282 273 if (skb->len != 0) 283 274 return -EBADMSG; 275 + 276 + /* Record that the message was unmarshalled successfully so 277 + * that the call destructor can know do the callback breaking 278 + * work, even if the final ACK isn't received. 279 + * 280 + * If the step number changes, then afs_cm_destructor() must be 281 + * updated also. 282 + */ 283 + call->unmarshall++; 284 + case 6: 284 285 break; 285 286 } 286 287
+1 -1
fs/afs/internal.h
··· 75 75 const struct afs_call_type *type; /* type of call */ 76 76 const struct afs_wait_mode *wait_mode; /* completion wait mode */ 77 77 wait_queue_head_t waitq; /* processes awaiting completion */ 78 - work_func_t async_workfn; 78 + void (*async_workfn)(struct afs_call *call); /* asynchronous work function */ 79 79 struct work_struct async_work; /* asynchronous work processor */ 80 80 struct work_struct work; /* actual work processor */ 81 81 struct sk_buff_head rx_queue; /* received packets */
+43 -43
fs/afs/rxrpc.c
··· 25 25 static int afs_wait_for_call_to_complete(struct afs_call *); 26 26 static void afs_wake_up_async_call(struct afs_call *); 27 27 static int afs_dont_wait_for_call_to_complete(struct afs_call *); 28 - static void afs_process_async_call(struct work_struct *); 28 + static void afs_process_async_call(struct afs_call *); 29 29 static void afs_rx_interceptor(struct sock *, unsigned long, struct sk_buff *); 30 30 static int afs_deliver_cm_op_id(struct afs_call *, struct sk_buff *, bool); 31 31 ··· 57 57 58 58 static struct sk_buff_head afs_incoming_calls; 59 59 static DECLARE_WORK(afs_collect_incoming_call_work, afs_collect_incoming_call); 60 + 61 + static void afs_async_workfn(struct work_struct *work) 62 + { 63 + struct afs_call *call = container_of(work, struct afs_call, async_work); 64 + 65 + call->async_workfn(call); 66 + } 60 67 61 68 /* 62 69 * open an RxRPC socket and bind it to be a server for callback notifications ··· 188 181 189 182 kfree(call->request); 190 183 kfree(call); 184 + } 185 + 186 + /* 187 + * End a call but do not free it 188 + */ 189 + static void afs_end_call_nofree(struct afs_call *call) 190 + { 191 + if (call->rxcall) { 192 + rxrpc_kernel_end_call(call->rxcall); 193 + call->rxcall = NULL; 194 + } 195 + if (call->type->destructor) 196 + call->type->destructor(call); 197 + } 198 + 199 + /* 200 + * End a call and free it 201 + */ 202 + static void afs_end_call(struct afs_call *call) 203 + { 204 + afs_end_call_nofree(call); 205 + afs_free_call(call); 191 206 } 192 207 193 208 /* ··· 355 326 atomic_read(&afs_outstanding_calls)); 356 327 357 328 call->wait_mode = wait_mode; 358 - INIT_WORK(&call->async_work, afs_process_async_call); 329 + call->async_workfn = afs_process_async_call; 330 + INIT_WORK(&call->async_work, afs_async_workfn); 359 331 360 332 memset(&srx, 0, sizeof(srx)); 361 333 srx.srx_family = AF_RXRPC; ··· 413 383 rxrpc_kernel_abort_call(rxcall, RX_USER_ABORT); 414 384 while ((skb = skb_dequeue(&call->rx_queue))) 415 385 afs_free_skb(skb); 416 - rxrpc_kernel_end_call(rxcall); 417 - call->rxcall = NULL; 418 386 error_kill_call: 419 - call->type->destructor(call); 420 - afs_free_call(call); 387 + afs_end_call(call); 421 388 _leave(" = %d", ret); 422 389 return ret; 423 390 } ··· 536 509 if (call->state >= AFS_CALL_COMPLETE) { 537 510 while ((skb = skb_dequeue(&call->rx_queue))) 538 511 afs_free_skb(skb); 539 - if (call->incoming) { 540 - rxrpc_kernel_end_call(call->rxcall); 541 - call->rxcall = NULL; 542 - call->type->destructor(call); 543 - afs_free_call(call); 544 - } 512 + if (call->incoming) 513 + afs_end_call(call); 545 514 } 546 515 547 516 _leave(""); ··· 587 564 } 588 565 589 566 _debug("call complete"); 590 - rxrpc_kernel_end_call(call->rxcall); 591 - call->rxcall = NULL; 592 - call->type->destructor(call); 593 - afs_free_call(call); 567 + afs_end_call(call); 594 568 _leave(" = %d", ret); 595 569 return ret; 596 570 } ··· 623 603 /* 624 604 * delete an asynchronous call 625 605 */ 626 - static void afs_delete_async_call(struct work_struct *work) 606 + static void afs_delete_async_call(struct afs_call *call) 627 607 { 628 - struct afs_call *call = 629 - container_of(work, struct afs_call, async_work); 630 - 631 608 _enter(""); 632 609 633 610 afs_free_call(call); ··· 637 620 * - on a multiple-thread workqueue this work item may try to run on several 638 621 * CPUs at the same time 639 622 */ 640 - static void afs_process_async_call(struct work_struct *work) 623 + static void afs_process_async_call(struct afs_call *call) 641 624 { 642 - struct afs_call *call = 643 - container_of(work, struct afs_call, async_work); 644 - 645 625 _enter(""); 646 626 647 627 if (!skb_queue_empty(&call->rx_queue)) ··· 651 637 call->reply = NULL; 652 638 653 639 /* kill the call */ 654 - rxrpc_kernel_end_call(call->rxcall); 655 - call->rxcall = NULL; 656 - if (call->type->destructor) 657 - call->type->destructor(call); 640 + afs_end_call_nofree(call); 658 641 659 642 /* we can't just delete the call because the work item may be 660 643 * queued */ ··· 672 661 if (skb_copy_bits(skb, 0, call->buffer + call->reply_size, len) < 0) 673 662 BUG(); 674 663 call->reply_size += len; 675 - } 676 - 677 - static void afs_async_workfn(struct work_struct *work) 678 - { 679 - struct afs_call *call = container_of(work, struct afs_call, async_work); 680 - 681 - call->async_workfn(work); 682 664 } 683 665 684 666 /* ··· 794 790 _debug("oom"); 795 791 rxrpc_kernel_abort_call(call->rxcall, RX_USER_ABORT); 796 792 default: 797 - rxrpc_kernel_end_call(call->rxcall); 798 - call->rxcall = NULL; 799 - call->type->destructor(call); 800 - afs_free_call(call); 793 + afs_end_call(call); 801 794 _leave(" [error]"); 802 795 return; 803 796 } ··· 824 823 call->state = AFS_CALL_AWAIT_ACK; 825 824 n = rxrpc_kernel_send_data(call->rxcall, &msg, len); 826 825 if (n >= 0) { 826 + /* Success */ 827 827 _leave(" [replied]"); 828 828 return; 829 829 } 830 + 830 831 if (n == -ENOMEM) { 831 832 _debug("oom"); 832 833 rxrpc_kernel_abort_call(call->rxcall, RX_USER_ABORT); 833 834 } 834 - rxrpc_kernel_end_call(call->rxcall); 835 - call->rxcall = NULL; 836 - call->type->destructor(call); 837 - afs_free_call(call); 835 + afs_end_call(call); 838 836 _leave(" [error]"); 839 837 } 840 838
+1 -1
fs/nfsd/nfs4acl.c
··· 590 590 add_to_mask(state, &state->groups->aces[i].perms); 591 591 } 592 592 593 - if (!state->users->n && !state->groups->n) { 593 + if (state->users->n || state->groups->n) { 594 594 pace++; 595 595 pace->e_tag = ACL_MASK; 596 596 low_mode_from_nfs4(state->mask.allow, &pace->e_perm, flags);
+13 -2
fs/nfsd/nfs4state.c
··· 3717 3717 static __be32 3718 3718 nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp) 3719 3719 { 3720 - if (check_for_locks(stp->st_file, lockowner(stp->st_stateowner))) 3720 + struct nfs4_lockowner *lo = lockowner(stp->st_stateowner); 3721 + 3722 + if (check_for_locks(stp->st_file, lo)) 3721 3723 return nfserr_locks_held; 3722 - release_lock_stateid(stp); 3724 + /* 3725 + * Currently there's a 1-1 lock stateid<->lockowner 3726 + * correspondance, and we have to delete the lockowner when we 3727 + * delete the lock stateid: 3728 + */ 3729 + unhash_lockowner(lo); 3723 3730 return nfs_ok; 3724 3731 } 3725 3732 ··· 4166 4159 4167 4160 if (!same_owner_str(&lo->lo_owner, owner, clid)) 4168 4161 return false; 4162 + if (list_empty(&lo->lo_owner.so_stateids)) { 4163 + WARN_ON_ONCE(1); 4164 + return false; 4165 + } 4169 4166 lst = list_first_entry(&lo->lo_owner.so_stateids, 4170 4167 struct nfs4_ol_stateid, st_perstateowner); 4171 4168 return lst->st_file->fi_inode == inode;
+6 -2
fs/ocfs2/dlm/dlmmaster.c
··· 472 472 473 473 void dlm_destroy_master_caches(void) 474 474 { 475 - if (dlm_lockname_cache) 475 + if (dlm_lockname_cache) { 476 476 kmem_cache_destroy(dlm_lockname_cache); 477 + dlm_lockname_cache = NULL; 478 + } 477 479 478 - if (dlm_lockres_cache) 480 + if (dlm_lockres_cache) { 479 481 kmem_cache_destroy(dlm_lockres_cache); 482 + dlm_lockres_cache = NULL; 483 + } 480 484 } 481 485 482 486 static void dlm_lockres_release(struct kref *kref)
+2
include/acpi/acpi_bus.h
··· 406 406 extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); 407 407 void acpi_bus_private_data_handler(acpi_handle, void *); 408 408 int acpi_bus_get_private_data(acpi_handle, void **); 409 + int acpi_bus_attach_private_data(acpi_handle, void *); 410 + void acpi_bus_detach_private_data(acpi_handle); 409 411 void acpi_bus_no_hotplug(acpi_handle handle); 410 412 extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); 411 413 extern int register_acpi_notifier(struct notifier_block *);
+1
include/linux/dmaengine.h
··· 429 429 typedef void (*dma_async_tx_callback)(void *dma_async_param); 430 430 431 431 struct dmaengine_unmap_data { 432 + u8 map_cnt; 432 433 u8 to_cnt; 433 434 u8 from_cnt; 434 435 u8 bidi_cnt;
+1
include/linux/if_macvlan.h
··· 56 56 int numqueues; 57 57 netdev_features_t tap_features; 58 58 int minor; 59 + int nest_level; 59 60 }; 60 61 61 62 static inline void macvlan_count_rx(const struct macvlan_dev *vlan,
+14 -1
include/linux/if_vlan.h
··· 73 73 /* found in socket.c */ 74 74 extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); 75 75 76 - static inline int is_vlan_dev(struct net_device *dev) 76 + static inline bool is_vlan_dev(struct net_device *dev) 77 77 { 78 78 return dev->priv_flags & IFF_802_1Q_VLAN; 79 79 } ··· 159 159 #ifdef CONFIG_NET_POLL_CONTROLLER 160 160 struct netpoll *netpoll; 161 161 #endif 162 + unsigned int nest_level; 162 163 }; 163 164 164 165 static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev) ··· 198 197 const struct net_device *by_dev); 199 198 200 199 extern bool vlan_uses_dev(const struct net_device *dev); 200 + 201 + static inline int vlan_get_encap_level(struct net_device *dev) 202 + { 203 + BUG_ON(!is_vlan_dev(dev)); 204 + return vlan_dev_priv(dev)->nest_level; 205 + } 201 206 #else 202 207 static inline struct net_device * 203 208 __vlan_find_dev_deep(struct net_device *real_dev, ··· 269 262 static inline bool vlan_uses_dev(const struct net_device *dev) 270 263 { 271 264 return false; 265 + } 266 + static inline int vlan_get_encap_level(struct net_device *dev) 267 + { 268 + BUG(); 269 + return 0; 272 270 } 273 271 #endif 274 272 ··· 495 483 */ 496 484 skb->protocol = htons(ETH_P_802_2); 497 485 } 486 + 498 487 #endif /* !(_LINUX_IF_VLAN_H_) */
+11
include/linux/mlx4/qp.h
··· 421 421 __be32 byte_count; 422 422 }; 423 423 424 + enum mlx4_update_qp_attr { 425 + MLX4_UPDATE_QP_SMAC = 1 << 0, 426 + }; 427 + 428 + struct mlx4_update_qp_params { 429 + u8 smac_index; 430 + }; 431 + 432 + int mlx4_update_qp(struct mlx4_dev *dev, struct mlx4_qp *qp, 433 + enum mlx4_update_qp_attr attr, 434 + struct mlx4_update_qp_params *params); 424 435 int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt, 425 436 enum mlx4_qp_state cur_state, enum mlx4_qp_state new_state, 426 437 struct mlx4_qp_context *context, enum mlx4_qp_optpar optpar,
+4 -11
include/linux/net.h
··· 248 248 bool __net_get_random_once(void *buf, int nbytes, bool *done, 249 249 struct static_key *done_key); 250 250 251 - #ifdef HAVE_JUMP_LABEL 252 - #define ___NET_RANDOM_STATIC_KEY_INIT ((struct static_key) \ 253 - { .enabled = ATOMIC_INIT(0), .entries = (void *)1 }) 254 - #else /* !HAVE_JUMP_LABEL */ 255 - #define ___NET_RANDOM_STATIC_KEY_INIT STATIC_KEY_INIT_FALSE 256 - #endif /* HAVE_JUMP_LABEL */ 257 - 258 251 #define net_get_random_once(buf, nbytes) \ 259 252 ({ \ 260 253 bool ___ret = false; \ 261 254 static bool ___done = false; \ 262 - static struct static_key ___done_key = \ 263 - ___NET_RANDOM_STATIC_KEY_INIT; \ 264 - if (!static_key_true(&___done_key)) \ 255 + static struct static_key ___once_key = \ 256 + STATIC_KEY_INIT_TRUE; \ 257 + if (static_key_true(&___once_key)) \ 265 258 ___ret = __net_get_random_once(buf, \ 266 259 nbytes, \ 267 260 &___done, \ 268 - &___done_key); \ 261 + &___once_key); \ 269 262 ___ret; \ 270 263 }) 271 264
+27 -7
include/linux/netdevice.h
··· 1144 1144 netdev_tx_t (*ndo_dfwd_start_xmit) (struct sk_buff *skb, 1145 1145 struct net_device *dev, 1146 1146 void *priv); 1147 + int (*ndo_get_lock_subclass)(struct net_device *dev); 1147 1148 }; 1148 1149 1149 1150 /** ··· 2951 2950 2952 2951 static inline void netif_addr_lock_nested(struct net_device *dev) 2953 2952 { 2954 - spin_lock_nested(&dev->addr_list_lock, SINGLE_DEPTH_NESTING); 2953 + int subclass = SINGLE_DEPTH_NESTING; 2954 + 2955 + if (dev->netdev_ops->ndo_get_lock_subclass) 2956 + subclass = dev->netdev_ops->ndo_get_lock_subclass(dev); 2957 + 2958 + spin_lock_nested(&dev->addr_list_lock, subclass); 2955 2959 } 2956 2960 2957 2961 static inline void netif_addr_lock_bh(struct net_device *dev) ··· 3056 3050 extern int bpf_jit_enable; 3057 3051 3058 3052 bool netdev_has_upper_dev(struct net_device *dev, struct net_device *upper_dev); 3053 + struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev, 3054 + struct list_head **iter); 3059 3055 struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev, 3060 3056 struct list_head **iter); 3057 + 3058 + /* iterate through upper list, must be called under RCU read lock */ 3059 + #define netdev_for_each_upper_dev_rcu(dev, updev, iter) \ 3060 + for (iter = &(dev)->adj_list.upper, \ 3061 + updev = netdev_upper_get_next_dev_rcu(dev, &(iter)); \ 3062 + updev; \ 3063 + updev = netdev_upper_get_next_dev_rcu(dev, &(iter))) 3061 3064 3062 3065 /* iterate through upper list, must be called under RCU read lock */ 3063 3066 #define netdev_for_each_all_upper_dev_rcu(dev, updev, iter) \ ··· 3092 3077 priv; \ 3093 3078 priv = netdev_lower_get_next_private_rcu(dev, &(iter))) 3094 3079 3080 + void *netdev_lower_get_next(struct net_device *dev, 3081 + struct list_head **iter); 3082 + #define netdev_for_each_lower_dev(dev, ldev, iter) \ 3083 + for (iter = &(dev)->adj_list.lower, \ 3084 + ldev = netdev_lower_get_next(dev, &(iter)); \ 3085 + ldev; \ 3086 + ldev = netdev_lower_get_next(dev, &(iter))) 3087 + 3095 3088 void *netdev_adjacent_get_private(struct list_head *adj_list); 3096 3089 void *netdev_lower_get_first_private_rcu(struct net_device *dev); 3097 3090 struct net_device *netdev_master_upper_dev_get(struct net_device *dev); ··· 3115 3092 void netdev_adjacent_rename_links(struct net_device *dev, char *oldname); 3116 3093 void *netdev_lower_dev_get_private(struct net_device *dev, 3117 3094 struct net_device *lower_dev); 3095 + int dev_get_nest_level(struct net_device *dev, 3096 + bool (*type_check)(struct net_device *dev)); 3118 3097 int skb_checksum_help(struct sk_buff *skb); 3119 3098 struct sk_buff *__skb_gso_segment(struct sk_buff *skb, 3120 3099 netdev_features_t features, bool tx_path); ··· 3205 3180 void netif_stacked_transfer_operstate(const struct net_device *rootdev, 3206 3181 struct net_device *dev); 3207 3182 3208 - netdev_features_t netif_skb_dev_features(struct sk_buff *skb, 3209 - const struct net_device *dev); 3210 - static inline netdev_features_t netif_skb_features(struct sk_buff *skb) 3211 - { 3212 - return netif_skb_dev_features(skb, skb->dev); 3213 - } 3183 + netdev_features_t netif_skb_features(struct sk_buff *skb); 3214 3184 3215 3185 static inline bool net_gso_ok(netdev_features_t features, int gso_type) 3216 3186 {
+6 -1
include/linux/of_mdio.h
··· 31 31 #else /* CONFIG_OF */ 32 32 static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) 33 33 { 34 - return -ENOSYS; 34 + /* 35 + * Fall back to the non-DT function to register a bus. 36 + * This way, we don't have to keep compat bits around in drivers. 37 + */ 38 + 39 + return mdiobus_register(mdio); 35 40 } 36 41 37 42 static inline struct phy_device *of_phy_find_device(struct device_node *phy_np)
+2
include/linux/perf_event.h
··· 402 402 403 403 struct ring_buffer *rb; 404 404 struct list_head rb_entry; 405 + unsigned long rcu_batches; 406 + int rcu_pending; 405 407 406 408 /* poll related */ 407 409 wait_queue_head_t waitq;
+5
include/linux/rtnetlink.h
··· 4 4 5 5 #include <linux/mutex.h> 6 6 #include <linux/netdevice.h> 7 + #include <linux/wait.h> 7 8 #include <uapi/linux/rtnetlink.h> 8 9 9 10 extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo); ··· 23 22 extern void rtnl_unlock(void); 24 23 extern int rtnl_trylock(void); 25 24 extern int rtnl_is_locked(void); 25 + 26 + extern wait_queue_head_t netdev_unregistering_wq; 27 + extern struct mutex net_mutex; 28 + 26 29 #ifdef CONFIG_PROVE_LOCKING 27 30 extern int lockdep_rtnl_is_held(void); 28 31 #else
+6 -3
include/linux/sched.h
··· 220 220 #define TASK_PARKED 512 221 221 #define TASK_STATE_MAX 1024 222 222 223 - #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP" 223 + #define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWP" 224 224 225 225 extern char ___assert_task_state[1 - 2*!!( 226 226 sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)]; ··· 1153 1153 * 1154 1154 * @dl_boosted tells if we are boosted due to DI. If so we are 1155 1155 * outside bandwidth enforcement mechanism (but only until we 1156 - * exit the critical section). 1156 + * exit the critical section); 1157 + * 1158 + * @dl_yielded tells if task gave up the cpu before consuming 1159 + * all its available runtime during the last job. 1157 1160 */ 1158 - int dl_throttled, dl_new, dl_boosted; 1161 + int dl_throttled, dl_new, dl_boosted, dl_yielded; 1159 1162 1160 1163 /* 1161 1164 * Bandwidth enforcement timer. Each -deadline task has its
+12
include/net/cfg80211.h
··· 3669 3669 void cfg80211_sched_scan_stopped(struct wiphy *wiphy); 3670 3670 3671 3671 /** 3672 + * cfg80211_sched_scan_stopped_rtnl - notify that the scheduled scan has stopped 3673 + * 3674 + * @wiphy: the wiphy on which the scheduled scan stopped 3675 + * 3676 + * The driver can call this function to inform cfg80211 that the 3677 + * scheduled scan had to be stopped, for whatever reason. The driver 3678 + * is then called back via the sched_scan_stop operation when done. 3679 + * This function should be called with rtnl locked. 3680 + */ 3681 + void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy); 3682 + 3683 + /** 3672 3684 * cfg80211_inform_bss_width_frame - inform cfg80211 of a received BSS frame 3673 3685 * 3674 3686 * @wiphy: the wiphy reporting the BSS
+1
include/net/ip6_route.h
··· 127 127 void rt6_ifdown(struct net *net, struct net_device *dev); 128 128 void rt6_mtu_change(struct net_device *dev, unsigned int mtu); 129 129 void rt6_remove_prefsrc(struct inet6_ifaddr *ifp); 130 + void rt6_clean_tohost(struct net *net, struct in6_addr *gateway); 130 131 131 132 132 133 /*
+7 -2
include/net/netns/ipv4.h
··· 20 20 int range[2]; 21 21 }; 22 22 23 + struct ping_group_range { 24 + seqlock_t lock; 25 + kgid_t range[2]; 26 + }; 27 + 23 28 struct netns_ipv4 { 24 29 #ifdef CONFIG_SYSCTL 25 30 struct ctl_table_header *forw_hdr; ··· 71 66 int sysctl_icmp_ratemask; 72 67 int sysctl_icmp_errors_use_inbound_ifaddr; 73 68 74 - struct local_ports sysctl_local_ports; 69 + struct local_ports ip_local_ports; 75 70 76 71 int sysctl_tcp_ecn; 77 72 int sysctl_ip_no_pmtu_disc; 78 73 int sysctl_ip_fwd_use_pmtu; 79 74 80 - kgid_t sysctl_ping_group_range[2]; 75 + struct ping_group_range ping_group_range; 81 76 82 77 atomic_t dev_addr_genid; 83 78
+3 -1
include/uapi/linux/nl80211.h
··· 3856 3856 * @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested 3857 3857 * to work properly to suppport receiving regulatory hints from 3858 3858 * cellular base stations. 3859 + * @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only 3860 + * here to reserve the value for API/ABI compatibility) 3859 3861 * @NL80211_FEATURE_SAE: This driver supports simultaneous authentication of 3860 3862 * equals (SAE) with user space SME (NL80211_CMD_AUTHENTICATE) in station 3861 3863 * mode ··· 3899 3897 NL80211_FEATURE_HT_IBSS = 1 << 1, 3900 3898 NL80211_FEATURE_INACTIVITY_TIMER = 1 << 2, 3901 3899 NL80211_FEATURE_CELL_BASE_REG_HINTS = 1 << 3, 3902 - /* bit 4 is reserved - don't use */ 3900 + NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL = 1 << 4, 3903 3901 NL80211_FEATURE_SAE = 1 << 5, 3904 3902 NL80211_FEATURE_LOW_PRIORITY_SCAN = 1 << 6, 3905 3903 NL80211_FEATURE_SCAN_FLUSH = 1 << 7,
+92 -82
kernel/events/core.c
··· 1443 1443 cpuctx->exclusive = 0; 1444 1444 } 1445 1445 1446 + struct remove_event { 1447 + struct perf_event *event; 1448 + bool detach_group; 1449 + }; 1450 + 1446 1451 /* 1447 1452 * Cross CPU call to remove a performance event 1448 1453 * ··· 1456 1451 */ 1457 1452 static int __perf_remove_from_context(void *info) 1458 1453 { 1459 - struct perf_event *event = info; 1454 + struct remove_event *re = info; 1455 + struct perf_event *event = re->event; 1460 1456 struct perf_event_context *ctx = event->ctx; 1461 1457 struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); 1462 1458 1463 1459 raw_spin_lock(&ctx->lock); 1464 1460 event_sched_out(event, cpuctx, ctx); 1461 + if (re->detach_group) 1462 + perf_group_detach(event); 1465 1463 list_del_event(event, ctx); 1466 1464 if (!ctx->nr_events && cpuctx->task_ctx == ctx) { 1467 1465 ctx->is_active = 0; ··· 1489 1481 * When called from perf_event_exit_task, it's OK because the 1490 1482 * context has been detached from its task. 1491 1483 */ 1492 - static void perf_remove_from_context(struct perf_event *event) 1484 + static void perf_remove_from_context(struct perf_event *event, bool detach_group) 1493 1485 { 1494 1486 struct perf_event_context *ctx = event->ctx; 1495 1487 struct task_struct *task = ctx->task; 1488 + struct remove_event re = { 1489 + .event = event, 1490 + .detach_group = detach_group, 1491 + }; 1496 1492 1497 1493 lockdep_assert_held(&ctx->mutex); 1498 1494 ··· 1505 1493 * Per cpu events are removed via an smp call and 1506 1494 * the removal is always successful. 1507 1495 */ 1508 - cpu_function_call(event->cpu, __perf_remove_from_context, event); 1496 + cpu_function_call(event->cpu, __perf_remove_from_context, &re); 1509 1497 return; 1510 1498 } 1511 1499 1512 1500 retry: 1513 - if (!task_function_call(task, __perf_remove_from_context, event)) 1501 + if (!task_function_call(task, __perf_remove_from_context, &re)) 1514 1502 return; 1515 1503 1516 1504 raw_spin_lock_irq(&ctx->lock); ··· 1527 1515 * Since the task isn't running, its safe to remove the event, us 1528 1516 * holding the ctx->lock ensures the task won't get scheduled in. 1529 1517 */ 1518 + if (detach_group) 1519 + perf_group_detach(event); 1530 1520 list_del_event(event, ctx); 1531 1521 raw_spin_unlock_irq(&ctx->lock); 1532 1522 } ··· 3192 3178 } 3193 3179 3194 3180 static void ring_buffer_put(struct ring_buffer *rb); 3195 - static void ring_buffer_detach(struct perf_event *event, struct ring_buffer *rb); 3181 + static void ring_buffer_attach(struct perf_event *event, 3182 + struct ring_buffer *rb); 3196 3183 3197 3184 static void unaccount_event_cpu(struct perf_event *event, int cpu) 3198 3185 { ··· 3253 3238 unaccount_event(event); 3254 3239 3255 3240 if (event->rb) { 3256 - struct ring_buffer *rb; 3257 - 3258 3241 /* 3259 3242 * Can happen when we close an event with re-directed output. 3260 3243 * ··· 3260 3247 * over us; possibly making our ring_buffer_put() the last. 3261 3248 */ 3262 3249 mutex_lock(&event->mmap_mutex); 3263 - rb = event->rb; 3264 - if (rb) { 3265 - rcu_assign_pointer(event->rb, NULL); 3266 - ring_buffer_detach(event, rb); 3267 - ring_buffer_put(rb); /* could be last */ 3268 - } 3250 + ring_buffer_attach(event, NULL); 3269 3251 mutex_unlock(&event->mmap_mutex); 3270 3252 } 3271 3253 ··· 3289 3281 * to trigger the AB-BA case. 3290 3282 */ 3291 3283 mutex_lock_nested(&ctx->mutex, SINGLE_DEPTH_NESTING); 3292 - raw_spin_lock_irq(&ctx->lock); 3293 - perf_group_detach(event); 3294 - raw_spin_unlock_irq(&ctx->lock); 3295 - perf_remove_from_context(event); 3284 + perf_remove_from_context(event, true); 3296 3285 mutex_unlock(&ctx->mutex); 3297 3286 3298 3287 free_event(event); ··· 3844 3839 static void ring_buffer_attach(struct perf_event *event, 3845 3840 struct ring_buffer *rb) 3846 3841 { 3842 + struct ring_buffer *old_rb = NULL; 3847 3843 unsigned long flags; 3848 3844 3849 - if (!list_empty(&event->rb_entry)) 3850 - return; 3845 + if (event->rb) { 3846 + /* 3847 + * Should be impossible, we set this when removing 3848 + * event->rb_entry and wait/clear when adding event->rb_entry. 3849 + */ 3850 + WARN_ON_ONCE(event->rcu_pending); 3851 3851 3852 - spin_lock_irqsave(&rb->event_lock, flags); 3853 - if (list_empty(&event->rb_entry)) 3854 - list_add(&event->rb_entry, &rb->event_list); 3855 - spin_unlock_irqrestore(&rb->event_lock, flags); 3856 - } 3852 + old_rb = event->rb; 3853 + event->rcu_batches = get_state_synchronize_rcu(); 3854 + event->rcu_pending = 1; 3857 3855 3858 - static void ring_buffer_detach(struct perf_event *event, struct ring_buffer *rb) 3859 - { 3860 - unsigned long flags; 3856 + spin_lock_irqsave(&old_rb->event_lock, flags); 3857 + list_del_rcu(&event->rb_entry); 3858 + spin_unlock_irqrestore(&old_rb->event_lock, flags); 3859 + } 3861 3860 3862 - if (list_empty(&event->rb_entry)) 3863 - return; 3861 + if (event->rcu_pending && rb) { 3862 + cond_synchronize_rcu(event->rcu_batches); 3863 + event->rcu_pending = 0; 3864 + } 3864 3865 3865 - spin_lock_irqsave(&rb->event_lock, flags); 3866 - list_del_init(&event->rb_entry); 3867 - wake_up_all(&event->waitq); 3868 - spin_unlock_irqrestore(&rb->event_lock, flags); 3866 + if (rb) { 3867 + spin_lock_irqsave(&rb->event_lock, flags); 3868 + list_add_rcu(&event->rb_entry, &rb->event_list); 3869 + spin_unlock_irqrestore(&rb->event_lock, flags); 3870 + } 3871 + 3872 + rcu_assign_pointer(event->rb, rb); 3873 + 3874 + if (old_rb) { 3875 + ring_buffer_put(old_rb); 3876 + /* 3877 + * Since we detached before setting the new rb, so that we 3878 + * could attach the new rb, we could have missed a wakeup. 3879 + * Provide it now. 3880 + */ 3881 + wake_up_all(&event->waitq); 3882 + } 3869 3883 } 3870 3884 3871 3885 static void ring_buffer_wakeup(struct perf_event *event) ··· 3953 3929 { 3954 3930 struct perf_event *event = vma->vm_file->private_data; 3955 3931 3956 - struct ring_buffer *rb = event->rb; 3932 + struct ring_buffer *rb = ring_buffer_get(event); 3957 3933 struct user_struct *mmap_user = rb->mmap_user; 3958 3934 int mmap_locked = rb->mmap_locked; 3959 3935 unsigned long size = perf_data_size(rb); ··· 3961 3937 atomic_dec(&rb->mmap_count); 3962 3938 3963 3939 if (!atomic_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex)) 3964 - return; 3940 + goto out_put; 3965 3941 3966 - /* Detach current event from the buffer. */ 3967 - rcu_assign_pointer(event->rb, NULL); 3968 - ring_buffer_detach(event, rb); 3942 + ring_buffer_attach(event, NULL); 3969 3943 mutex_unlock(&event->mmap_mutex); 3970 3944 3971 3945 /* If there's still other mmap()s of this buffer, we're done. */ 3972 - if (atomic_read(&rb->mmap_count)) { 3973 - ring_buffer_put(rb); /* can't be last */ 3974 - return; 3975 - } 3946 + if (atomic_read(&rb->mmap_count)) 3947 + goto out_put; 3976 3948 3977 3949 /* 3978 3950 * No other mmap()s, detach from all other events that might redirect ··· 3998 3978 * still restart the iteration to make sure we're not now 3999 3979 * iterating the wrong list. 4000 3980 */ 4001 - if (event->rb == rb) { 4002 - rcu_assign_pointer(event->rb, NULL); 4003 - ring_buffer_detach(event, rb); 4004 - ring_buffer_put(rb); /* can't be last, we still have one */ 4005 - } 3981 + if (event->rb == rb) 3982 + ring_buffer_attach(event, NULL); 3983 + 4006 3984 mutex_unlock(&event->mmap_mutex); 4007 3985 put_event(event); 4008 3986 ··· 4025 4007 vma->vm_mm->pinned_vm -= mmap_locked; 4026 4008 free_uid(mmap_user); 4027 4009 4010 + out_put: 4028 4011 ring_buffer_put(rb); /* could be last */ 4029 4012 } 4030 4013 ··· 4143 4124 vma->vm_mm->pinned_vm += extra; 4144 4125 4145 4126 ring_buffer_attach(event, rb); 4146 - rcu_assign_pointer(event->rb, rb); 4147 4127 4148 4128 perf_event_init_userpage(event); 4149 4129 perf_event_update_userpage(event); ··· 5426 5408 5427 5409 /* Recursion avoidance in each contexts */ 5428 5410 int recursion[PERF_NR_CONTEXTS]; 5411 + 5412 + /* Keeps track of cpu being initialized/exited */ 5413 + bool online; 5429 5414 }; 5430 5415 5431 5416 static DEFINE_PER_CPU(struct swevent_htable, swevent_htable); ··· 5675 5654 hwc->state = !(flags & PERF_EF_START); 5676 5655 5677 5656 head = find_swevent_head(swhash, event); 5678 - if (WARN_ON_ONCE(!head)) 5657 + if (!head) { 5658 + /* 5659 + * We can race with cpu hotplug code. Do not 5660 + * WARN if the cpu just got unplugged. 5661 + */ 5662 + WARN_ON_ONCE(swhash->online); 5679 5663 return -EINVAL; 5664 + } 5680 5665 5681 5666 hlist_add_head_rcu(&event->hlist_entry, head); 5682 5667 ··· 6941 6914 static int 6942 6915 perf_event_set_output(struct perf_event *event, struct perf_event *output_event) 6943 6916 { 6944 - struct ring_buffer *rb = NULL, *old_rb = NULL; 6917 + struct ring_buffer *rb = NULL; 6945 6918 int ret = -EINVAL; 6946 6919 6947 6920 if (!output_event) ··· 6969 6942 if (atomic_read(&event->mmap_count)) 6970 6943 goto unlock; 6971 6944 6972 - old_rb = event->rb; 6973 - 6974 6945 if (output_event) { 6975 6946 /* get the rb we want to redirect to */ 6976 6947 rb = ring_buffer_get(output_event); ··· 6976 6951 goto unlock; 6977 6952 } 6978 6953 6979 - if (old_rb) 6980 - ring_buffer_detach(event, old_rb); 6981 - 6982 - if (rb) 6983 - ring_buffer_attach(event, rb); 6984 - 6985 - rcu_assign_pointer(event->rb, rb); 6986 - 6987 - if (old_rb) { 6988 - ring_buffer_put(old_rb); 6989 - /* 6990 - * Since we detached before setting the new rb, so that we 6991 - * could attach the new rb, we could have missed a wakeup. 6992 - * Provide it now. 6993 - */ 6994 - wake_up_all(&event->waitq); 6995 - } 6954 + ring_buffer_attach(event, rb); 6996 6955 6997 6956 ret = 0; 6998 6957 unlock: ··· 7026 7017 7027 7018 if (attr.freq) { 7028 7019 if (attr.sample_freq > sysctl_perf_event_sample_rate) 7020 + return -EINVAL; 7021 + } else { 7022 + if (attr.sample_period & (1ULL << 63)) 7029 7023 return -EINVAL; 7030 7024 } 7031 7025 ··· 7177 7165 struct perf_event_context *gctx = group_leader->ctx; 7178 7166 7179 7167 mutex_lock(&gctx->mutex); 7180 - perf_remove_from_context(group_leader); 7168 + perf_remove_from_context(group_leader, false); 7181 7169 7182 7170 /* 7183 7171 * Removing from the context ends up with disabled ··· 7187 7175 perf_event__state_init(group_leader); 7188 7176 list_for_each_entry(sibling, &group_leader->sibling_list, 7189 7177 group_entry) { 7190 - perf_remove_from_context(sibling); 7178 + perf_remove_from_context(sibling, false); 7191 7179 perf_event__state_init(sibling); 7192 7180 put_ctx(gctx); 7193 7181 } ··· 7317 7305 mutex_lock(&src_ctx->mutex); 7318 7306 list_for_each_entry_safe(event, tmp, &src_ctx->event_list, 7319 7307 event_entry) { 7320 - perf_remove_from_context(event); 7308 + perf_remove_from_context(event, false); 7321 7309 unaccount_event_cpu(event, src_cpu); 7322 7310 put_ctx(src_ctx); 7323 7311 list_add(&event->migrate_entry, &events); ··· 7379 7367 struct perf_event_context *child_ctx, 7380 7368 struct task_struct *child) 7381 7369 { 7382 - if (child_event->parent) { 7383 - raw_spin_lock_irq(&child_ctx->lock); 7384 - perf_group_detach(child_event); 7385 - raw_spin_unlock_irq(&child_ctx->lock); 7386 - } 7387 - 7388 - perf_remove_from_context(child_event); 7370 + perf_remove_from_context(child_event, !!child_event->parent); 7389 7371 7390 7372 /* 7391 7373 * It can happen that the parent exits first, and has events ··· 7730 7724 * swapped under us. 7731 7725 */ 7732 7726 parent_ctx = perf_pin_task_context(parent, ctxn); 7727 + if (!parent_ctx) 7728 + return 0; 7733 7729 7734 7730 /* 7735 7731 * No need to check if parent_ctx != NULL here; since we saw ··· 7843 7835 struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu); 7844 7836 7845 7837 mutex_lock(&swhash->hlist_mutex); 7838 + swhash->online = true; 7846 7839 if (swhash->hlist_refcount > 0) { 7847 7840 struct swevent_hlist *hlist; 7848 7841 ··· 7866 7857 7867 7858 static void __perf_event_exit_context(void *__info) 7868 7859 { 7860 + struct remove_event re = { .detach_group = false }; 7869 7861 struct perf_event_context *ctx = __info; 7870 - struct perf_event *event; 7871 7862 7872 7863 perf_pmu_rotate_stop(ctx->pmu); 7873 7864 7874 7865 rcu_read_lock(); 7875 - list_for_each_entry_rcu(event, &ctx->event_list, event_entry) 7876 - __perf_remove_from_context(event); 7866 + list_for_each_entry_rcu(re.event, &ctx->event_list, event_entry) 7867 + __perf_remove_from_context(&re); 7877 7868 rcu_read_unlock(); 7878 7869 } 7879 7870 ··· 7901 7892 perf_event_exit_cpu_context(cpu); 7902 7893 7903 7894 mutex_lock(&swhash->hlist_mutex); 7895 + swhash->online = false; 7904 7896 swevent_hlist_release(swhash); 7905 7897 mutex_unlock(&swhash->hlist_mutex); 7906 7898 }
+13 -2
kernel/sched/core.c
··· 2592 2592 if (likely(prev->sched_class == class && 2593 2593 rq->nr_running == rq->cfs.h_nr_running)) { 2594 2594 p = fair_sched_class.pick_next_task(rq, prev); 2595 - if (likely(p && p != RETRY_TASK)) 2596 - return p; 2595 + if (unlikely(p == RETRY_TASK)) 2596 + goto again; 2597 + 2598 + /* assumes fair_sched_class->next == idle_sched_class */ 2599 + if (unlikely(!p)) 2600 + p = idle_sched_class.pick_next_task(rq, prev); 2601 + 2602 + return p; 2597 2603 } 2598 2604 2599 2605 again: ··· 3130 3124 dl_se->dl_bw = to_ratio(dl_se->dl_period, dl_se->dl_runtime); 3131 3125 dl_se->dl_throttled = 0; 3132 3126 dl_se->dl_new = 1; 3127 + dl_se->dl_yielded = 0; 3133 3128 } 3134 3129 3135 3130 static void __setscheduler_params(struct task_struct *p, ··· 3646 3639 * sys_sched_setattr - same as above, but with extended sched_attr 3647 3640 * @pid: the pid in question. 3648 3641 * @uattr: structure containing the extended parameters. 3642 + * @flags: for future extension. 3649 3643 */ 3650 3644 SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr, 3651 3645 unsigned int, flags) ··· 3791 3783 * @pid: the pid in question. 3792 3784 * @uattr: structure containing the extended parameters. 3793 3785 * @size: sizeof(attr) for fwd/bwd comp. 3786 + * @flags: for future extension. 3794 3787 */ 3795 3788 SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr, 3796 3789 unsigned int, size, unsigned int, flags) ··· 6026 6017 , 6027 6018 .last_balance = jiffies, 6028 6019 .balance_interval = sd_weight, 6020 + .max_newidle_lb_cost = 0, 6021 + .next_decay_max_lb_cost = jiffies, 6029 6022 }; 6030 6023 SD_INIT_NAME(sd, NUMA); 6031 6024 sd->private = &tl->data;
+1 -3
kernel/sched/cpudeadline.c
··· 210 210 */ 211 211 void cpudl_cleanup(struct cpudl *cp) 212 212 { 213 - /* 214 - * nothing to do for the moment 215 - */ 213 + free_cpumask_var(cp->free_cpus); 216 214 }
+1 -2
kernel/sched/cpupri.c
··· 70 70 int idx = 0; 71 71 int task_pri = convert_prio(p->prio); 72 72 73 - if (task_pri >= MAX_RT_PRIO) 74 - return 0; 73 + BUG_ON(task_pri >= CPUPRI_NR_PRIORITIES); 75 74 76 75 for (idx = 0; idx < task_pri; idx++) { 77 76 struct cpupri_vec *vec = &cp->pri_to_cpu[idx];
+16 -16
kernel/sched/cputime.c
··· 332 332 * softirq as those do not count in task exec_runtime any more. 333 333 */ 334 334 static void irqtime_account_process_tick(struct task_struct *p, int user_tick, 335 - struct rq *rq) 335 + struct rq *rq, int ticks) 336 336 { 337 - cputime_t one_jiffy_scaled = cputime_to_scaled(cputime_one_jiffy); 337 + cputime_t scaled = cputime_to_scaled(cputime_one_jiffy); 338 + u64 cputime = (__force u64) cputime_one_jiffy; 338 339 u64 *cpustat = kcpustat_this_cpu->cpustat; 339 340 340 341 if (steal_account_process_tick()) 341 342 return; 342 343 344 + cputime *= ticks; 345 + scaled *= ticks; 346 + 343 347 if (irqtime_account_hi_update()) { 344 - cpustat[CPUTIME_IRQ] += (__force u64) cputime_one_jiffy; 348 + cpustat[CPUTIME_IRQ] += cputime; 345 349 } else if (irqtime_account_si_update()) { 346 - cpustat[CPUTIME_SOFTIRQ] += (__force u64) cputime_one_jiffy; 350 + cpustat[CPUTIME_SOFTIRQ] += cputime; 347 351 } else if (this_cpu_ksoftirqd() == p) { 348 352 /* 349 353 * ksoftirqd time do not get accounted in cpu_softirq_time. 350 354 * So, we have to handle it separately here. 351 355 * Also, p->stime needs to be updated for ksoftirqd. 352 356 */ 353 - __account_system_time(p, cputime_one_jiffy, one_jiffy_scaled, 354 - CPUTIME_SOFTIRQ); 357 + __account_system_time(p, cputime, scaled, CPUTIME_SOFTIRQ); 355 358 } else if (user_tick) { 356 - account_user_time(p, cputime_one_jiffy, one_jiffy_scaled); 359 + account_user_time(p, cputime, scaled); 357 360 } else if (p == rq->idle) { 358 - account_idle_time(cputime_one_jiffy); 361 + account_idle_time(cputime); 359 362 } else if (p->flags & PF_VCPU) { /* System time or guest time */ 360 - account_guest_time(p, cputime_one_jiffy, one_jiffy_scaled); 363 + account_guest_time(p, cputime, scaled); 361 364 } else { 362 - __account_system_time(p, cputime_one_jiffy, one_jiffy_scaled, 363 - CPUTIME_SYSTEM); 365 + __account_system_time(p, cputime, scaled, CPUTIME_SYSTEM); 364 366 } 365 367 } 366 368 367 369 static void irqtime_account_idle_ticks(int ticks) 368 370 { 369 - int i; 370 371 struct rq *rq = this_rq(); 371 372 372 - for (i = 0; i < ticks; i++) 373 - irqtime_account_process_tick(current, 0, rq); 373 + irqtime_account_process_tick(current, 0, rq, ticks); 374 374 } 375 375 #else /* CONFIG_IRQ_TIME_ACCOUNTING */ 376 376 static inline void irqtime_account_idle_ticks(int ticks) {} 377 377 static inline void irqtime_account_process_tick(struct task_struct *p, int user_tick, 378 - struct rq *rq) {} 378 + struct rq *rq, int nr_ticks) {} 379 379 #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ 380 380 381 381 /* ··· 464 464 return; 465 465 466 466 if (sched_clock_irqtime) { 467 - irqtime_account_process_tick(p, user_tick, rq); 467 + irqtime_account_process_tick(p, user_tick, rq, 1); 468 468 return; 469 469 } 470 470
+3 -2
kernel/sched/deadline.c
··· 528 528 sched_clock_tick(); 529 529 update_rq_clock(rq); 530 530 dl_se->dl_throttled = 0; 531 + dl_se->dl_yielded = 0; 531 532 if (p->on_rq) { 532 533 enqueue_task_dl(rq, p, ENQUEUE_REPLENISH); 533 534 if (task_has_dl_policy(rq->curr)) ··· 894 893 * We make the task go to sleep until its current deadline by 895 894 * forcing its runtime to zero. This way, update_curr_dl() stops 896 895 * it and the bandwidth timer will wake it up and will give it 897 - * new scheduling parameters (thanks to dl_new=1). 896 + * new scheduling parameters (thanks to dl_yielded=1). 898 897 */ 899 898 if (p->dl.runtime > 0) { 900 - rq->curr->dl.dl_new = 1; 899 + rq->curr->dl.dl_yielded = 1; 901 900 p->dl.runtime = 0; 902 901 } 903 902 update_curr_dl(rq);
+8 -8
kernel/sched/fair.c
··· 6653 6653 int this_cpu = this_rq->cpu; 6654 6654 6655 6655 idle_enter_fair(this_rq); 6656 + 6656 6657 /* 6657 6658 * We must set idle_stamp _before_ calling idle_balance(), such that we 6658 6659 * measure the duration of idle_balance() as idle time. ··· 6706 6705 6707 6706 raw_spin_lock(&this_rq->lock); 6708 6707 6708 + if (curr_cost > this_rq->max_idle_balance_cost) 6709 + this_rq->max_idle_balance_cost = curr_cost; 6710 + 6709 6711 /* 6710 - * While browsing the domains, we released the rq lock. 6711 - * A task could have be enqueued in the meantime 6712 + * While browsing the domains, we released the rq lock, a task could 6713 + * have been enqueued in the meantime. Since we're not going idle, 6714 + * pretend we pulled a task. 6712 6715 */ 6713 - if (this_rq->cfs.h_nr_running && !pulled_task) { 6716 + if (this_rq->cfs.h_nr_running && !pulled_task) 6714 6717 pulled_task = 1; 6715 - goto out; 6716 - } 6717 6718 6718 6719 if (pulled_task || time_after(jiffies, this_rq->next_balance)) { 6719 6720 /* ··· 6724 6721 */ 6725 6722 this_rq->next_balance = next_balance; 6726 6723 } 6727 - 6728 - if (curr_cost > this_rq->max_idle_balance_cost) 6729 - this_rq->max_idle_balance_cost = curr_cost; 6730 6724 6731 6725 out: 6732 6726 /* Is there a task of a high priority class? */
+4 -2
mm/filemap.c
··· 257 257 { 258 258 int ret = 0; 259 259 /* Check for outstanding write errors */ 260 - if (test_and_clear_bit(AS_ENOSPC, &mapping->flags)) 260 + if (test_bit(AS_ENOSPC, &mapping->flags) && 261 + test_and_clear_bit(AS_ENOSPC, &mapping->flags)) 261 262 ret = -ENOSPC; 262 - if (test_and_clear_bit(AS_EIO, &mapping->flags)) 263 + if (test_bit(AS_EIO, &mapping->flags) && 264 + test_and_clear_bit(AS_EIO, &mapping->flags)) 263 265 ret = -EIO; 264 266 return ret; 265 267 }
+1 -1
mm/madvise.c
··· 195 195 for (; start < end; start += PAGE_SIZE) { 196 196 index = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; 197 197 198 - page = find_get_page(mapping, index); 198 + page = find_get_entry(mapping, index); 199 199 if (!radix_tree_exceptional_entry(page)) { 200 200 if (page) 201 201 page_cache_release(page);
+14 -13
mm/memcontrol.c
··· 1077 1077 1078 1078 rcu_read_lock(); 1079 1079 do { 1080 - memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); 1081 - if (unlikely(!memcg)) 1080 + /* 1081 + * Page cache insertions can happen withou an 1082 + * actual mm context, e.g. during disk probing 1083 + * on boot, loopback IO, acct() writes etc. 1084 + */ 1085 + if (unlikely(!mm)) 1082 1086 memcg = root_mem_cgroup; 1087 + else { 1088 + memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); 1089 + if (unlikely(!memcg)) 1090 + memcg = root_mem_cgroup; 1091 + } 1083 1092 } while (!css_tryget(&memcg->css)); 1084 1093 rcu_read_unlock(); 1085 1094 return memcg; ··· 3967 3958 return 0; 3968 3959 } 3969 3960 3970 - /* 3971 - * Page cache insertions can happen without an actual mm 3972 - * context, e.g. during disk probing on boot. 3973 - */ 3974 - if (unlikely(!mm)) 3975 - memcg = root_mem_cgroup; 3976 - else { 3977 - memcg = mem_cgroup_try_charge_mm(mm, gfp_mask, 1, true); 3978 - if (!memcg) 3979 - return -ENOMEM; 3980 - } 3961 + memcg = mem_cgroup_try_charge_mm(mm, gfp_mask, 1, true); 3962 + if (!memcg) 3963 + return -ENOMEM; 3981 3964 __mem_cgroup_commit_charge(memcg, page, 1, type, false); 3982 3965 return 0; 3983 3966 }
+10 -7
mm/memory-failure.c
··· 1081 1081 return 0; 1082 1082 } else if (PageHuge(hpage)) { 1083 1083 /* 1084 - * Check "just unpoisoned", "filter hit", and 1085 - * "race with other subpage." 1084 + * Check "filter hit" and "race with other subpage." 1086 1085 */ 1087 1086 lock_page(hpage); 1088 - if (!PageHWPoison(hpage) 1089 - || (hwpoison_filter(p) && TestClearPageHWPoison(p)) 1090 - || (p != hpage && TestSetPageHWPoison(hpage))) { 1091 - atomic_long_sub(nr_pages, &num_poisoned_pages); 1092 - return 0; 1087 + if (PageHWPoison(hpage)) { 1088 + if ((hwpoison_filter(p) && TestClearPageHWPoison(p)) 1089 + || (p != hpage && TestSetPageHWPoison(hpage))) { 1090 + atomic_long_sub(nr_pages, &num_poisoned_pages); 1091 + unlock_page(hpage); 1092 + return 0; 1093 + } 1093 1094 } 1094 1095 set_page_hwpoison_huge_page(hpage); 1095 1096 res = dequeue_hwpoisoned_huge_page(hpage); ··· 1153 1152 */ 1154 1153 if (!PageHWPoison(p)) { 1155 1154 printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn); 1155 + atomic_long_sub(nr_pages, &num_poisoned_pages); 1156 + put_page(hpage); 1156 1157 res = 0; 1157 1158 goto out; 1158 1159 }
+1
net/8021q/vlan.c
··· 169 169 if (err < 0) 170 170 goto out_uninit_mvrp; 171 171 172 + vlan->nest_level = dev_get_nest_level(real_dev, is_vlan_dev) + 1; 172 173 err = register_netdevice(dev); 173 174 if (err < 0) 174 175 goto out_uninit_mvrp;
+9 -43
net/8021q/vlan_dev.c
··· 493 493 } 494 494 } 495 495 496 - static int vlan_calculate_locking_subclass(struct net_device *real_dev) 497 - { 498 - int subclass = 0; 499 - 500 - while (is_vlan_dev(real_dev)) { 501 - subclass++; 502 - real_dev = vlan_dev_priv(real_dev)->real_dev; 503 - } 504 - 505 - return subclass; 506 - } 507 - 508 - static void vlan_dev_mc_sync(struct net_device *to, struct net_device *from) 509 - { 510 - int err = 0, subclass; 511 - 512 - subclass = vlan_calculate_locking_subclass(to); 513 - 514 - spin_lock_nested(&to->addr_list_lock, subclass); 515 - err = __hw_addr_sync(&to->mc, &from->mc, to->addr_len); 516 - if (!err) 517 - __dev_set_rx_mode(to); 518 - spin_unlock(&to->addr_list_lock); 519 - } 520 - 521 - static void vlan_dev_uc_sync(struct net_device *to, struct net_device *from) 522 - { 523 - int err = 0, subclass; 524 - 525 - subclass = vlan_calculate_locking_subclass(to); 526 - 527 - spin_lock_nested(&to->addr_list_lock, subclass); 528 - err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len); 529 - if (!err) 530 - __dev_set_rx_mode(to); 531 - spin_unlock(&to->addr_list_lock); 532 - } 533 - 534 496 static void vlan_dev_set_rx_mode(struct net_device *vlan_dev) 535 497 { 536 - vlan_dev_mc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); 537 - vlan_dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); 498 + dev_mc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); 499 + dev_uc_sync(vlan_dev_priv(vlan_dev)->real_dev, vlan_dev); 538 500 } 539 501 540 502 /* ··· 522 560 &vlan_netdev_addr_lock_key, 523 561 subclass); 524 562 netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, &subclass); 563 + } 564 + 565 + static int vlan_dev_get_lock_subclass(struct net_device *dev) 566 + { 567 + return vlan_dev_priv(dev)->nest_level; 525 568 } 526 569 527 570 static const struct header_ops vlan_header_ops = { ··· 564 597 static int vlan_dev_init(struct net_device *dev) 565 598 { 566 599 struct net_device *real_dev = vlan_dev_priv(dev)->real_dev; 567 - int subclass = 0; 568 600 569 601 netif_carrier_off(dev); 570 602 ··· 612 646 613 647 SET_NETDEV_DEVTYPE(dev, &vlan_type); 614 648 615 - subclass = vlan_calculate_locking_subclass(dev); 616 - vlan_dev_set_lockdep_class(dev, subclass); 649 + vlan_dev_set_lockdep_class(dev, vlan_dev_get_lock_subclass(dev)); 617 650 618 651 vlan_dev_priv(dev)->vlan_pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); 619 652 if (!vlan_dev_priv(dev)->vlan_pcpu_stats) ··· 784 819 .ndo_netpoll_cleanup = vlan_dev_netpoll_cleanup, 785 820 #endif 786 821 .ndo_fix_features = vlan_dev_fix_features, 822 + .ndo_get_lock_subclass = vlan_dev_get_lock_subclass, 787 823 }; 788 824 789 825 void vlan_setup(struct net_device *dev)
+2
net/batman-adv/bat_iv_ogm.c
··· 1545 1545 if ((orig_neigh_node) && (!is_single_hop_neigh)) 1546 1546 batadv_orig_node_free_ref(orig_neigh_node); 1547 1547 out: 1548 + if (router_ifinfo) 1549 + batadv_neigh_ifinfo_free_ref(router_ifinfo); 1548 1550 if (router) 1549 1551 batadv_neigh_node_free_ref(router); 1550 1552 if (router_router)
+1 -2
net/batman-adv/distributed-arp-table.c
··· 940 940 * additional DAT answer may trigger kernel warnings about 941 941 * a packet coming from the wrong port. 942 942 */ 943 - if (batadv_is_my_client(bat_priv, dat_entry->mac_addr, 944 - BATADV_NO_FLAGS)) { 943 + if (batadv_is_my_client(bat_priv, dat_entry->mac_addr, vid)) { 945 944 ret = true; 946 945 goto out; 947 946 }
+8 -3
net/batman-adv/fragmentation.c
··· 418 418 struct batadv_neigh_node *neigh_node) 419 419 { 420 420 struct batadv_priv *bat_priv; 421 - struct batadv_hard_iface *primary_if; 421 + struct batadv_hard_iface *primary_if = NULL; 422 422 struct batadv_frag_packet frag_header; 423 423 struct sk_buff *skb_fragment; 424 424 unsigned mtu = neigh_node->if_incoming->net_dev->mtu; 425 425 unsigned header_size = sizeof(frag_header); 426 426 unsigned max_fragment_size, max_packet_size; 427 + bool ret = false; 427 428 428 429 /* To avoid merge and refragmentation at next-hops we never send 429 430 * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE ··· 484 483 skb->len + ETH_HLEN); 485 484 batadv_send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr); 486 485 487 - return true; 486 + ret = true; 487 + 488 488 out_err: 489 - return false; 489 + if (primary_if) 490 + batadv_hardif_free_ref(primary_if); 491 + 492 + return ret; 490 493 }
+10 -3
net/batman-adv/gateway_client.c
··· 42 42 43 43 static void batadv_gw_node_free_ref(struct batadv_gw_node *gw_node) 44 44 { 45 - if (atomic_dec_and_test(&gw_node->refcount)) 45 + if (atomic_dec_and_test(&gw_node->refcount)) { 46 + batadv_orig_node_free_ref(gw_node->orig_node); 46 47 kfree_rcu(gw_node, rcu); 48 + } 47 49 } 48 50 49 51 static struct batadv_gw_node * ··· 408 406 if (gateway->bandwidth_down == 0) 409 407 return; 410 408 411 - gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); 412 - if (!gw_node) 409 + if (!atomic_inc_not_zero(&orig_node->refcount)) 413 410 return; 411 + 412 + gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC); 413 + if (!gw_node) { 414 + batadv_orig_node_free_ref(orig_node); 415 + return; 416 + } 414 417 415 418 INIT_HLIST_NODE(&gw_node->list); 416 419 gw_node->orig_node = orig_node;
+1 -1
net/batman-adv/hard-interface.c
··· 83 83 return true; 84 84 85 85 /* no more parents..stop recursion */ 86 - if (net_dev->iflink == net_dev->ifindex) 86 + if (net_dev->iflink == 0 || net_dev->iflink == net_dev->ifindex) 87 87 return false; 88 88 89 89 /* recurse over the parent device */
+57 -5
net/batman-adv/originator.c
··· 501 501 static void batadv_orig_ifinfo_free_rcu(struct rcu_head *rcu) 502 502 { 503 503 struct batadv_orig_ifinfo *orig_ifinfo; 504 + struct batadv_neigh_node *router; 504 505 505 506 orig_ifinfo = container_of(rcu, struct batadv_orig_ifinfo, rcu); 506 507 507 508 if (orig_ifinfo->if_outgoing != BATADV_IF_DEFAULT) 508 509 batadv_hardif_free_ref_now(orig_ifinfo->if_outgoing); 509 510 511 + /* this is the last reference to this object */ 512 + router = rcu_dereference_protected(orig_ifinfo->router, true); 513 + if (router) 514 + batadv_neigh_node_free_ref_now(router); 510 515 kfree(orig_ifinfo); 511 516 } 512 517 ··· 707 702 } 708 703 709 704 /** 705 + * batadv_purge_neigh_ifinfo - purge obsolete ifinfo entries from neighbor 706 + * @bat_priv: the bat priv with all the soft interface information 707 + * @neigh: orig node which is to be checked 708 + */ 709 + static void 710 + batadv_purge_neigh_ifinfo(struct batadv_priv *bat_priv, 711 + struct batadv_neigh_node *neigh) 712 + { 713 + struct batadv_neigh_ifinfo *neigh_ifinfo; 714 + struct batadv_hard_iface *if_outgoing; 715 + struct hlist_node *node_tmp; 716 + 717 + spin_lock_bh(&neigh->ifinfo_lock); 718 + 719 + /* for all ifinfo objects for this neighinator */ 720 + hlist_for_each_entry_safe(neigh_ifinfo, node_tmp, 721 + &neigh->ifinfo_list, list) { 722 + if_outgoing = neigh_ifinfo->if_outgoing; 723 + 724 + /* always keep the default interface */ 725 + if (if_outgoing == BATADV_IF_DEFAULT) 726 + continue; 727 + 728 + /* don't purge if the interface is not (going) down */ 729 + if ((if_outgoing->if_status != BATADV_IF_INACTIVE) && 730 + (if_outgoing->if_status != BATADV_IF_NOT_IN_USE) && 731 + (if_outgoing->if_status != BATADV_IF_TO_BE_REMOVED)) 732 + continue; 733 + 734 + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, 735 + "neighbor/ifinfo purge: neighbor %pM, iface: %s\n", 736 + neigh->addr, if_outgoing->net_dev->name); 737 + 738 + hlist_del_rcu(&neigh_ifinfo->list); 739 + batadv_neigh_ifinfo_free_ref(neigh_ifinfo); 740 + } 741 + 742 + spin_unlock_bh(&neigh->ifinfo_lock); 743 + } 744 + 745 + /** 710 746 * batadv_purge_orig_ifinfo - purge obsolete ifinfo entries from originator 711 747 * @bat_priv: the bat priv with all the soft interface information 712 748 * @orig_node: orig node which is to be checked ··· 846 800 847 801 hlist_del_rcu(&neigh_node->list); 848 802 batadv_neigh_node_free_ref(neigh_node); 803 + } else { 804 + /* only necessary if not the whole neighbor is to be 805 + * deleted, but some interface has been removed. 806 + */ 807 + batadv_purge_neigh_ifinfo(bat_priv, neigh_node); 849 808 } 850 809 } 851 810 ··· 908 857 { 909 858 struct batadv_neigh_node *best_neigh_node; 910 859 struct batadv_hard_iface *hard_iface; 911 - bool changed; 860 + bool changed_ifinfo, changed_neigh; 912 861 913 862 if (batadv_has_timed_out(orig_node->last_seen, 914 863 2 * BATADV_PURGE_TIMEOUT)) { ··· 918 867 jiffies_to_msecs(orig_node->last_seen)); 919 868 return true; 920 869 } 921 - changed = batadv_purge_orig_ifinfo(bat_priv, orig_node); 922 - changed = changed || batadv_purge_orig_neighbors(bat_priv, orig_node); 870 + changed_ifinfo = batadv_purge_orig_ifinfo(bat_priv, orig_node); 871 + changed_neigh = batadv_purge_orig_neighbors(bat_priv, orig_node); 923 872 924 - if (!changed) 873 + if (!changed_ifinfo && !changed_neigh) 925 874 return false; 926 875 927 876 /* first for NULL ... */ ··· 1079 1028 bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq, hard_iface); 1080 1029 1081 1030 out: 1082 - batadv_hardif_free_ref(hard_iface); 1031 + if (hard_iface) 1032 + batadv_hardif_free_ref(hard_iface); 1083 1033 return 0; 1084 1034 } 1085 1035
+2 -2
net/bridge/br_netfilter.c
··· 859 859 return NF_STOLEN; 860 860 } 861 861 862 - #if IS_ENABLED(CONFIG_NF_CONNTRACK_IPV4) 862 + #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) 863 863 static int br_nf_dev_queue_xmit(struct sk_buff *skb) 864 864 { 865 865 int ret; 866 866 867 - if (skb->nfct != NULL && skb->protocol == htons(ETH_P_IP) && 867 + if (skb->protocol == htons(ETH_P_IP) && 868 868 skb->len + nf_bridge_mtu_reduction(skb) > skb->dev->mtu && 869 869 !skb_is_gso(skb)) { 870 870 if (br_parse_ip_options(skb))
+88 -14
net/core/dev.c
··· 2418 2418 * 2. No high memory really exists on this machine. 2419 2419 */ 2420 2420 2421 - static int illegal_highdma(const struct net_device *dev, struct sk_buff *skb) 2421 + static int illegal_highdma(struct net_device *dev, struct sk_buff *skb) 2422 2422 { 2423 2423 #ifdef CONFIG_HIGHMEM 2424 2424 int i; ··· 2493 2493 } 2494 2494 2495 2495 static netdev_features_t harmonize_features(struct sk_buff *skb, 2496 - const struct net_device *dev, 2497 - netdev_features_t features) 2496 + netdev_features_t features) 2498 2497 { 2499 2498 int tmp; 2500 2499 2501 2500 if (skb->ip_summed != CHECKSUM_NONE && 2502 2501 !can_checksum_protocol(features, skb_network_protocol(skb, &tmp))) { 2503 2502 features &= ~NETIF_F_ALL_CSUM; 2504 - } else if (illegal_highdma(dev, skb)) { 2503 + } else if (illegal_highdma(skb->dev, skb)) { 2505 2504 features &= ~NETIF_F_SG; 2506 2505 } 2507 2506 2508 2507 return features; 2509 2508 } 2510 2509 2511 - netdev_features_t netif_skb_dev_features(struct sk_buff *skb, 2512 - const struct net_device *dev) 2510 + netdev_features_t netif_skb_features(struct sk_buff *skb) 2513 2511 { 2514 2512 __be16 protocol = skb->protocol; 2515 - netdev_features_t features = dev->features; 2513 + netdev_features_t features = skb->dev->features; 2516 2514 2517 - if (skb_shinfo(skb)->gso_segs > dev->gso_max_segs) 2515 + if (skb_shinfo(skb)->gso_segs > skb->dev->gso_max_segs) 2518 2516 features &= ~NETIF_F_GSO_MASK; 2519 2517 2520 2518 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { 2521 2519 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 2522 2520 protocol = veh->h_vlan_encapsulated_proto; 2523 2521 } else if (!vlan_tx_tag_present(skb)) { 2524 - return harmonize_features(skb, dev, features); 2522 + return harmonize_features(skb, features); 2525 2523 } 2526 2524 2527 - features &= (dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | 2525 + features &= (skb->dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | 2528 2526 NETIF_F_HW_VLAN_STAG_TX); 2529 2527 2530 2528 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) ··· 2530 2532 NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX | 2531 2533 NETIF_F_HW_VLAN_STAG_TX; 2532 2534 2533 - return harmonize_features(skb, dev, features); 2535 + return harmonize_features(skb, features); 2534 2536 } 2535 - EXPORT_SYMBOL(netif_skb_dev_features); 2537 + EXPORT_SYMBOL(netif_skb_features); 2536 2538 2537 2539 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 2538 2540 struct netdev_queue *txq) ··· 3951 3953 } 3952 3954 NAPI_GRO_CB(skb)->count = 1; 3953 3955 NAPI_GRO_CB(skb)->age = jiffies; 3956 + NAPI_GRO_CB(skb)->last = skb; 3954 3957 skb_shinfo(skb)->gso_size = skb_gro_len(skb); 3955 3958 skb->next = napi->gro_list; 3956 3959 napi->gro_list = skb; ··· 4542 4543 EXPORT_SYMBOL(netdev_adjacent_get_private); 4543 4544 4544 4545 /** 4546 + * netdev_upper_get_next_dev_rcu - Get the next dev from upper list 4547 + * @dev: device 4548 + * @iter: list_head ** of the current position 4549 + * 4550 + * Gets the next device from the dev's upper list, starting from iter 4551 + * position. The caller must hold RCU read lock. 4552 + */ 4553 + struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev, 4554 + struct list_head **iter) 4555 + { 4556 + struct netdev_adjacent *upper; 4557 + 4558 + WARN_ON_ONCE(!rcu_read_lock_held() && !lockdep_rtnl_is_held()); 4559 + 4560 + upper = list_entry_rcu((*iter)->next, struct netdev_adjacent, list); 4561 + 4562 + if (&upper->list == &dev->adj_list.upper) 4563 + return NULL; 4564 + 4565 + *iter = &upper->list; 4566 + 4567 + return upper->dev; 4568 + } 4569 + EXPORT_SYMBOL(netdev_upper_get_next_dev_rcu); 4570 + 4571 + /** 4545 4572 * netdev_all_upper_get_next_dev_rcu - Get the next dev from upper list 4546 4573 * @dev: device 4547 4574 * @iter: list_head ** of the current position ··· 4647 4622 return lower->private; 4648 4623 } 4649 4624 EXPORT_SYMBOL(netdev_lower_get_next_private_rcu); 4625 + 4626 + /** 4627 + * netdev_lower_get_next - Get the next device from the lower neighbour 4628 + * list 4629 + * @dev: device 4630 + * @iter: list_head ** of the current position 4631 + * 4632 + * Gets the next netdev_adjacent from the dev's lower neighbour 4633 + * list, starting from iter position. The caller must hold RTNL lock or 4634 + * its own locking that guarantees that the neighbour lower 4635 + * list will remain unchainged. 4636 + */ 4637 + void *netdev_lower_get_next(struct net_device *dev, struct list_head **iter) 4638 + { 4639 + struct netdev_adjacent *lower; 4640 + 4641 + lower = list_entry((*iter)->next, struct netdev_adjacent, list); 4642 + 4643 + if (&lower->list == &dev->adj_list.lower) 4644 + return NULL; 4645 + 4646 + *iter = &lower->list; 4647 + 4648 + return lower->dev; 4649 + } 4650 + EXPORT_SYMBOL(netdev_lower_get_next); 4650 4651 4651 4652 /** 4652 4653 * netdev_lower_get_first_private_rcu - Get the first ->private from the ··· 5124 5073 } 5125 5074 EXPORT_SYMBOL(netdev_lower_dev_get_private); 5126 5075 5076 + 5077 + int dev_get_nest_level(struct net_device *dev, 5078 + bool (*type_check)(struct net_device *dev)) 5079 + { 5080 + struct net_device *lower = NULL; 5081 + struct list_head *iter; 5082 + int max_nest = -1; 5083 + int nest; 5084 + 5085 + ASSERT_RTNL(); 5086 + 5087 + netdev_for_each_lower_dev(dev, lower, iter) { 5088 + nest = dev_get_nest_level(lower, type_check); 5089 + if (max_nest < nest) 5090 + max_nest = nest; 5091 + } 5092 + 5093 + if (type_check(dev)) 5094 + max_nest++; 5095 + 5096 + return max_nest; 5097 + } 5098 + EXPORT_SYMBOL(dev_get_nest_level); 5099 + 5127 5100 static void dev_change_rx_flags(struct net_device *dev, int flags) 5128 5101 { 5129 5102 const struct net_device_ops *ops = dev->netdev_ops; ··· 5313 5238 if (ops->ndo_set_rx_mode) 5314 5239 ops->ndo_set_rx_mode(dev); 5315 5240 } 5316 - EXPORT_SYMBOL(__dev_set_rx_mode); 5317 5241 5318 5242 void dev_set_rx_mode(struct net_device *dev) 5319 5243 { ··· 5617 5543 5618 5544 /* Delayed registration/unregisteration */ 5619 5545 static LIST_HEAD(net_todo_list); 5620 - static DECLARE_WAIT_QUEUE_HEAD(netdev_unregistering_wq); 5546 + DECLARE_WAIT_QUEUE_HEAD(netdev_unregistering_wq); 5621 5547 5622 5548 static void net_set_todo(struct net_device *dev) 5623 5549 {
+2 -2
net/core/neighbour.c
··· 1248 1248 neigh->updated = jiffies; 1249 1249 if (!(neigh->nud_state & NUD_FAILED)) 1250 1250 return; 1251 - neigh->nud_state = NUD_PROBE; 1252 - atomic_set(&neigh->probes, NEIGH_VAR(neigh->parms, UCAST_PROBES)); 1251 + neigh->nud_state = NUD_INCOMPLETE; 1252 + atomic_set(&neigh->probes, neigh_max_probes(neigh)); 1253 1253 neigh_add_timer(neigh, 1254 1254 jiffies + NEIGH_VAR(neigh->parms, RETRANS_TIME)); 1255 1255 }
+1 -1
net/core/net_namespace.c
··· 24 24 25 25 static LIST_HEAD(pernet_list); 26 26 static struct list_head *first_device = &pernet_list; 27 - static DEFINE_MUTEX(net_mutex); 27 + DEFINE_MUTEX(net_mutex); 28 28 29 29 LIST_HEAD(net_namespace_list); 30 30 EXPORT_SYMBOL_GPL(net_namespace_list);
+32 -1
net/core/rtnetlink.c
··· 353 353 } 354 354 EXPORT_SYMBOL_GPL(__rtnl_link_unregister); 355 355 356 + /* Return with the rtnl_lock held when there are no network 357 + * devices unregistering in any network namespace. 358 + */ 359 + static void rtnl_lock_unregistering_all(void) 360 + { 361 + struct net *net; 362 + bool unregistering; 363 + DEFINE_WAIT(wait); 364 + 365 + for (;;) { 366 + prepare_to_wait(&netdev_unregistering_wq, &wait, 367 + TASK_UNINTERRUPTIBLE); 368 + unregistering = false; 369 + rtnl_lock(); 370 + for_each_net(net) { 371 + if (net->dev_unreg_count > 0) { 372 + unregistering = true; 373 + break; 374 + } 375 + } 376 + if (!unregistering) 377 + break; 378 + __rtnl_unlock(); 379 + schedule(); 380 + } 381 + finish_wait(&netdev_unregistering_wq, &wait); 382 + } 383 + 356 384 /** 357 385 * rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink. 358 386 * @ops: struct rtnl_link_ops * to unregister 359 387 */ 360 388 void rtnl_link_unregister(struct rtnl_link_ops *ops) 361 389 { 362 - rtnl_lock(); 390 + /* Close the race with cleanup_net() */ 391 + mutex_lock(&net_mutex); 392 + rtnl_lock_unregistering_all(); 363 393 __rtnl_link_unregister(ops); 364 394 rtnl_unlock(); 395 + mutex_unlock(&net_mutex); 365 396 } 366 397 EXPORT_SYMBOL_GPL(rtnl_link_unregister); 367 398
+2 -2
net/core/skbuff.c
··· 3076 3076 if (unlikely(p->len + len >= 65536)) 3077 3077 return -E2BIG; 3078 3078 3079 - lp = NAPI_GRO_CB(p)->last ?: p; 3079 + lp = NAPI_GRO_CB(p)->last; 3080 3080 pinfo = skb_shinfo(lp); 3081 3081 3082 3082 if (headlen <= offset) { ··· 3192 3192 3193 3193 __skb_pull(skb, offset); 3194 3194 3195 - if (!NAPI_GRO_CB(p)->last) 3195 + if (NAPI_GRO_CB(p)->last == p) 3196 3196 skb_shinfo(p)->frag_list = skb; 3197 3197 else 3198 3198 NAPI_GRO_CB(p)->last->next = skb;
+4 -4
net/core/utils.c
··· 348 348 { 349 349 struct __net_random_once_work *work = 350 350 container_of(w, struct __net_random_once_work, work); 351 - if (!static_key_enabled(work->key)) 352 - static_key_slow_inc(work->key); 351 + BUG_ON(!static_key_enabled(work->key)); 352 + static_key_slow_dec(work->key); 353 353 kfree(work); 354 354 } 355 355 ··· 367 367 } 368 368 369 369 bool __net_get_random_once(void *buf, int nbytes, bool *done, 370 - struct static_key *done_key) 370 + struct static_key *once_key) 371 371 { 372 372 static DEFINE_SPINLOCK(lock); 373 373 unsigned long flags; ··· 382 382 *done = true; 383 383 spin_unlock_irqrestore(&lock, flags); 384 384 385 - __net_random_once_disable_jump(done_key); 385 + __net_random_once_disable_jump(once_key); 386 386 387 387 return true; 388 388 }
+2 -1
net/dsa/dsa.c
··· 406 406 goto out_free; 407 407 } 408 408 409 - chip_index = 0; 409 + chip_index = -1; 410 410 for_each_available_child_of_node(np, child) { 411 + chip_index++; 411 412 cd = &pd->chip[chip_index]; 412 413 413 414 cd->mii_bus = &mdio_bus->dev;
+36
net/ipv4/af_inet.c
··· 1650 1650 return register_pernet_subsys(&ipv4_mib_ops); 1651 1651 } 1652 1652 1653 + static __net_init int inet_init_net(struct net *net) 1654 + { 1655 + /* 1656 + * Set defaults for local port range 1657 + */ 1658 + seqlock_init(&net->ipv4.ip_local_ports.lock); 1659 + net->ipv4.ip_local_ports.range[0] = 32768; 1660 + net->ipv4.ip_local_ports.range[1] = 61000; 1661 + 1662 + seqlock_init(&net->ipv4.ping_group_range.lock); 1663 + /* 1664 + * Sane defaults - nobody may create ping sockets. 1665 + * Boot scripts should set this to distro-specific group. 1666 + */ 1667 + net->ipv4.ping_group_range.range[0] = make_kgid(&init_user_ns, 1); 1668 + net->ipv4.ping_group_range.range[1] = make_kgid(&init_user_ns, 0); 1669 + return 0; 1670 + } 1671 + 1672 + static __net_exit void inet_exit_net(struct net *net) 1673 + { 1674 + } 1675 + 1676 + static __net_initdata struct pernet_operations af_inet_ops = { 1677 + .init = inet_init_net, 1678 + .exit = inet_exit_net, 1679 + }; 1680 + 1681 + static int __init init_inet_pernet_ops(void) 1682 + { 1683 + return register_pernet_subsys(&af_inet_ops); 1684 + } 1685 + 1653 1686 static int ipv4_proc_init(void); 1654 1687 1655 1688 /* ··· 1827 1794 if (ip_mr_init()) 1828 1795 pr_crit("%s: Cannot init ipv4 mroute\n", __func__); 1829 1796 #endif 1797 + 1798 + if (init_inet_pernet_ops()) 1799 + pr_crit("%s: Cannot init ipv4 inet pernet ops\n", __func__); 1830 1800 /* 1831 1801 * Initialise per-cpu ipv4 mibs 1832 1802 */
+1 -1
net/ipv4/fib_semantics.c
··· 821 821 fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); 822 822 if (fi == NULL) 823 823 goto failure; 824 + fib_info_cnt++; 824 825 if (cfg->fc_mx) { 825 826 fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL); 826 827 if (!fi->fib_metrics) 827 828 goto failure; 828 829 } else 829 830 fi->fib_metrics = (u32 *) dst_default_metrics; 830 - fib_info_cnt++; 831 831 832 832 fi->fib_net = hold_net(net); 833 833 fi->fib_protocol = cfg->fc_protocol;
+4 -4
net/ipv4/inet_connection_sock.c
··· 37 37 unsigned int seq; 38 38 39 39 do { 40 - seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock); 40 + seq = read_seqbegin(&net->ipv4.ip_local_ports.lock); 41 41 42 - *low = net->ipv4.sysctl_local_ports.range[0]; 43 - *high = net->ipv4.sysctl_local_ports.range[1]; 44 - } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq)); 42 + *low = net->ipv4.ip_local_ports.range[0]; 43 + *high = net->ipv4.ip_local_ports.range[1]; 44 + } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq)); 45 45 } 46 46 EXPORT_SYMBOL(inet_get_local_port_range); 47 47
+2 -52
net/ipv4/ip_forward.c
··· 42 42 static bool ip_may_fragment(const struct sk_buff *skb) 43 43 { 44 44 return unlikely((ip_hdr(skb)->frag_off & htons(IP_DF)) == 0) || 45 - !skb->local_df; 45 + skb->local_df; 46 46 } 47 47 48 48 static bool ip_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu) 49 49 { 50 - if (skb->len <= mtu || skb->local_df) 50 + if (skb->len <= mtu) 51 51 return false; 52 52 53 53 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu) ··· 56 56 return true; 57 57 } 58 58 59 - static bool ip_gso_exceeds_dst_mtu(const struct sk_buff *skb) 60 - { 61 - unsigned int mtu; 62 - 63 - if (skb->local_df || !skb_is_gso(skb)) 64 - return false; 65 - 66 - mtu = ip_dst_mtu_maybe_forward(skb_dst(skb), true); 67 - 68 - /* if seglen > mtu, do software segmentation for IP fragmentation on 69 - * output. DF bit cannot be set since ip_forward would have sent 70 - * icmp error. 71 - */ 72 - return skb_gso_network_seglen(skb) > mtu; 73 - } 74 - 75 - /* called if GSO skb needs to be fragmented on forward */ 76 - static int ip_forward_finish_gso(struct sk_buff *skb) 77 - { 78 - struct dst_entry *dst = skb_dst(skb); 79 - netdev_features_t features; 80 - struct sk_buff *segs; 81 - int ret = 0; 82 - 83 - features = netif_skb_dev_features(skb, dst->dev); 84 - segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); 85 - if (IS_ERR(segs)) { 86 - kfree_skb(skb); 87 - return -ENOMEM; 88 - } 89 - 90 - consume_skb(skb); 91 - 92 - do { 93 - struct sk_buff *nskb = segs->next; 94 - int err; 95 - 96 - segs->next = NULL; 97 - err = dst_output(segs); 98 - 99 - if (err && ret == 0) 100 - ret = err; 101 - segs = nskb; 102 - } while (segs); 103 - 104 - return ret; 105 - } 106 59 107 60 static int ip_forward_finish(struct sk_buff *skb) 108 61 { ··· 66 113 67 114 if (unlikely(opt->optlen)) 68 115 ip_forward_options(skb); 69 - 70 - if (ip_gso_exceeds_dst_mtu(skb)) 71 - return ip_forward_finish_gso(skb); 72 116 73 117 return dst_output(skb); 74 118 }
+3 -2
net/ipv4/ip_fragment.c
··· 232 232 * "Fragment Reassembly Timeout" message, per RFC792. 233 233 */ 234 234 if (qp->user == IP_DEFRAG_AF_PACKET || 235 - (qp->user == IP_DEFRAG_CONNTRACK_IN && 236 - skb_rtable(head)->rt_type != RTN_LOCAL)) 235 + ((qp->user >= IP_DEFRAG_CONNTRACK_IN) && 236 + (qp->user <= __IP_DEFRAG_CONNTRACK_IN_END) && 237 + (skb_rtable(head)->rt_type != RTN_LOCAL))) 237 238 goto out_rcu_unlock; 238 239 239 240
+48 -3
net/ipv4/ip_output.c
··· 211 211 return -EINVAL; 212 212 } 213 213 214 + static int ip_finish_output_gso(struct sk_buff *skb) 215 + { 216 + netdev_features_t features; 217 + struct sk_buff *segs; 218 + int ret = 0; 219 + 220 + /* common case: locally created skb or seglen is <= mtu */ 221 + if (((IPCB(skb)->flags & IPSKB_FORWARDED) == 0) || 222 + skb_gso_network_seglen(skb) <= ip_skb_dst_mtu(skb)) 223 + return ip_finish_output2(skb); 224 + 225 + /* Slowpath - GSO segment length is exceeding the dst MTU. 226 + * 227 + * This can happen in two cases: 228 + * 1) TCP GRO packet, DF bit not set 229 + * 2) skb arrived via virtio-net, we thus get TSO/GSO skbs directly 230 + * from host network stack. 231 + */ 232 + features = netif_skb_features(skb); 233 + segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); 234 + if (IS_ERR(segs)) { 235 + kfree_skb(skb); 236 + return -ENOMEM; 237 + } 238 + 239 + consume_skb(skb); 240 + 241 + do { 242 + struct sk_buff *nskb = segs->next; 243 + int err; 244 + 245 + segs->next = NULL; 246 + err = ip_fragment(segs, ip_finish_output2); 247 + 248 + if (err && ret == 0) 249 + ret = err; 250 + segs = nskb; 251 + } while (segs); 252 + 253 + return ret; 254 + } 255 + 214 256 static int ip_finish_output(struct sk_buff *skb) 215 257 { 216 258 #if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM) ··· 262 220 return dst_output(skb); 263 221 } 264 222 #endif 265 - if (skb->len > ip_skb_dst_mtu(skb) && !skb_is_gso(skb)) 223 + if (skb_is_gso(skb)) 224 + return ip_finish_output_gso(skb); 225 + 226 + if (skb->len > ip_skb_dst_mtu(skb)) 266 227 return ip_fragment(skb, ip_finish_output2); 267 - else 268 - return ip_finish_output2(skb); 228 + 229 + return ip_finish_output2(skb); 269 230 } 270 231 271 232 int ip_mc_output(struct sock *sk, struct sk_buff *skb)
+3 -1
net/ipv4/ip_tunnel.c
··· 540 540 unsigned int max_headroom; /* The extra header space needed */ 541 541 __be32 dst; 542 542 int err; 543 - bool connected = true; 543 + bool connected; 544 544 545 545 inner_iph = (const struct iphdr *)skb_inner_network_header(skb); 546 + connected = (tunnel->parms.iph.daddr != 0); 546 547 547 548 dst = tnl_params->daddr; 548 549 if (dst == 0) { ··· 883 882 */ 884 883 if (!IS_ERR(itn->fb_tunnel_dev)) { 885 884 itn->fb_tunnel_dev->features |= NETIF_F_NETNS_LOCAL; 885 + itn->fb_tunnel_dev->mtu = ip_tunnel_bind_dev(itn->fb_tunnel_dev); 886 886 ip_tunnel_add(itn, netdev_priv(itn->fb_tunnel_dev)); 887 887 } 888 888 rtnl_unlock();
+4 -1
net/ipv4/ip_vti.c
··· 239 239 static int vti4_err(struct sk_buff *skb, u32 info) 240 240 { 241 241 __be32 spi; 242 + __u32 mark; 242 243 struct xfrm_state *x; 243 244 struct ip_tunnel *tunnel; 244 245 struct ip_esp_hdr *esph; ··· 254 253 iph->daddr, iph->saddr, 0); 255 254 if (!tunnel) 256 255 return -1; 256 + 257 + mark = be32_to_cpu(tunnel->parms.o_key); 257 258 258 259 switch (protocol) { 259 260 case IPPROTO_ESP: ··· 284 281 return 0; 285 282 } 286 283 287 - x = xfrm_state_lookup(net, skb->mark, (const xfrm_address_t *)&iph->daddr, 284 + x = xfrm_state_lookup(net, mark, (const xfrm_address_t *)&iph->daddr, 288 285 spi, protocol, AF_INET); 289 286 if (!x) 290 287 return 0;
+3 -2
net/ipv4/netfilter/nf_defrag_ipv4.c
··· 22 22 #endif 23 23 #include <net/netfilter/nf_conntrack_zones.h> 24 24 25 - /* Returns new sk_buff, or NULL */ 26 25 static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user) 27 26 { 28 27 int err; ··· 32 33 err = ip_defrag(skb, user); 33 34 local_bh_enable(); 34 35 35 - if (!err) 36 + if (!err) { 36 37 ip_send_check(ip_hdr(skb)); 38 + skb->local_df = 1; 39 + } 37 40 38 41 return err; 39 42 }
+3 -3
net/ipv4/ping.c
··· 236 236 static void inet_get_ping_group_range_net(struct net *net, kgid_t *low, 237 237 kgid_t *high) 238 238 { 239 - kgid_t *data = net->ipv4.sysctl_ping_group_range; 239 + kgid_t *data = net->ipv4.ping_group_range.range; 240 240 unsigned int seq; 241 241 242 242 do { 243 - seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock); 243 + seq = read_seqbegin(&net->ipv4.ping_group_range.lock); 244 244 245 245 *low = data[0]; 246 246 *high = data[1]; 247 - } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq)); 247 + } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq)); 248 248 } 249 249 250 250
+1 -1
net/ipv4/route.c
··· 1519 1519 struct in_device *out_dev; 1520 1520 unsigned int flags = 0; 1521 1521 bool do_cache; 1522 - u32 itag; 1522 + u32 itag = 0; 1523 1523 1524 1524 /* get a working reference to the output device */ 1525 1525 out_dev = __in_dev_get_rcu(FIB_RES_DEV(*res));
+14 -28
net/ipv4/sysctl_net_ipv4.c
··· 45 45 /* Update system visible IP port range */ 46 46 static void set_local_port_range(struct net *net, int range[2]) 47 47 { 48 - write_seqlock(&net->ipv4.sysctl_local_ports.lock); 49 - net->ipv4.sysctl_local_ports.range[0] = range[0]; 50 - net->ipv4.sysctl_local_ports.range[1] = range[1]; 51 - write_sequnlock(&net->ipv4.sysctl_local_ports.lock); 48 + write_seqlock(&net->ipv4.ip_local_ports.lock); 49 + net->ipv4.ip_local_ports.range[0] = range[0]; 50 + net->ipv4.ip_local_ports.range[1] = range[1]; 51 + write_sequnlock(&net->ipv4.ip_local_ports.lock); 52 52 } 53 53 54 54 /* Validate changes from /proc interface. */ ··· 57 57 size_t *lenp, loff_t *ppos) 58 58 { 59 59 struct net *net = 60 - container_of(table->data, struct net, ipv4.sysctl_local_ports.range); 60 + container_of(table->data, struct net, ipv4.ip_local_ports.range); 61 61 int ret; 62 62 int range[2]; 63 63 struct ctl_table tmp = { ··· 87 87 { 88 88 kgid_t *data = table->data; 89 89 struct net *net = 90 - container_of(table->data, struct net, ipv4.sysctl_ping_group_range); 90 + container_of(table->data, struct net, ipv4.ping_group_range.range); 91 91 unsigned int seq; 92 92 do { 93 - seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock); 93 + seq = read_seqbegin(&net->ipv4.ip_local_ports.lock); 94 94 95 95 *low = data[0]; 96 96 *high = data[1]; 97 - } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq)); 97 + } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq)); 98 98 } 99 99 100 100 /* Update system visible IP port range */ ··· 102 102 { 103 103 kgid_t *data = table->data; 104 104 struct net *net = 105 - container_of(table->data, struct net, ipv4.sysctl_ping_group_range); 106 - write_seqlock(&net->ipv4.sysctl_local_ports.lock); 105 + container_of(table->data, struct net, ipv4.ping_group_range.range); 106 + write_seqlock(&net->ipv4.ip_local_ports.lock); 107 107 data[0] = low; 108 108 data[1] = high; 109 - write_sequnlock(&net->ipv4.sysctl_local_ports.lock); 109 + write_sequnlock(&net->ipv4.ip_local_ports.lock); 110 110 } 111 111 112 112 /* Validate changes from /proc interface. */ ··· 805 805 }, 806 806 { 807 807 .procname = "ping_group_range", 808 - .data = &init_net.ipv4.sysctl_ping_group_range, 808 + .data = &init_net.ipv4.ping_group_range.range, 809 809 .maxlen = sizeof(gid_t)*2, 810 810 .mode = 0644, 811 811 .proc_handler = ipv4_ping_group_range, ··· 819 819 }, 820 820 { 821 821 .procname = "ip_local_port_range", 822 - .maxlen = sizeof(init_net.ipv4.sysctl_local_ports.range), 823 - .data = &init_net.ipv4.sysctl_local_ports.range, 822 + .maxlen = sizeof(init_net.ipv4.ip_local_ports.range), 823 + .data = &init_net.ipv4.ip_local_ports.range, 824 824 .mode = 0644, 825 825 .proc_handler = ipv4_local_port_range, 826 826 }, ··· 857 857 for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) 858 858 table[i].data += (void *)net - (void *)&init_net; 859 859 } 860 - 861 - /* 862 - * Sane defaults - nobody may create ping sockets. 863 - * Boot scripts should set this to distro-specific group. 864 - */ 865 - net->ipv4.sysctl_ping_group_range[0] = make_kgid(&init_user_ns, 1); 866 - net->ipv4.sysctl_ping_group_range[1] = make_kgid(&init_user_ns, 0); 867 - 868 - /* 869 - * Set defaults for local port range 870 - */ 871 - seqlock_init(&net->ipv4.sysctl_local_ports.lock); 872 - net->ipv4.sysctl_local_ports.range[0] = 32768; 873 - net->ipv4.sysctl_local_ports.range[1] = 61000; 874 860 875 861 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); 876 862 if (net->ipv4.ipv4_hdr == NULL)
+19 -15
net/ipv4/xfrm4_output.c
··· 62 62 if (err) 63 63 return err; 64 64 65 - memset(IPCB(skb), 0, sizeof(*IPCB(skb))); 66 - IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED; 67 - 68 - skb->protocol = htons(ETH_P_IP); 65 + IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE; 69 66 70 67 return x->outer_mode->output2(x, skb); 71 68 } ··· 70 73 71 74 int xfrm4_output_finish(struct sk_buff *skb) 72 75 { 73 - #ifdef CONFIG_NETFILTER 74 - if (!skb_dst(skb)->xfrm) { 75 - IPCB(skb)->flags |= IPSKB_REROUTED; 76 - return dst_output(skb); 77 - } 76 + memset(IPCB(skb), 0, sizeof(*IPCB(skb))); 77 + skb->protocol = htons(ETH_P_IP); 78 78 79 + #ifdef CONFIG_NETFILTER 79 80 IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED; 80 81 #endif 81 82 82 - skb->protocol = htons(ETH_P_IP); 83 83 return xfrm_output(skb); 84 + } 85 + 86 + static int __xfrm4_output(struct sk_buff *skb) 87 + { 88 + struct xfrm_state *x = skb_dst(skb)->xfrm; 89 + 90 + #ifdef CONFIG_NETFILTER 91 + if (!x) { 92 + IPCB(skb)->flags |= IPSKB_REROUTED; 93 + return dst_output(skb); 94 + } 95 + #endif 96 + 97 + return x->outer_mode->afinfo->output_finish(skb); 84 98 } 85 99 86 100 int xfrm4_output(struct sock *sk, struct sk_buff *skb) 87 101 { 88 - struct dst_entry *dst = skb_dst(skb); 89 - struct xfrm_state *x = dst->xfrm; 90 - 91 102 return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, 92 - NULL, dst->dev, 93 - x->outer_mode->afinfo->output_finish, 103 + NULL, skb_dst(skb)->dev, __xfrm4_output, 94 104 !(IPCB(skb)->flags & IPSKB_REROUTED)); 95 105 } 96 106
+17 -2
net/ipv4/xfrm4_protocol.c
··· 50 50 { 51 51 int ret; 52 52 struct xfrm4_protocol *handler; 53 + struct xfrm4_protocol __rcu **head = proto_handlers(protocol); 53 54 54 - for_each_protocol_rcu(*proto_handlers(protocol), handler) 55 + if (!head) 56 + return 0; 57 + 58 + for_each_protocol_rcu(*head, handler) 55 59 if ((ret = handler->cb_handler(skb, err)) <= 0) 56 60 return ret; 57 61 ··· 68 64 { 69 65 int ret; 70 66 struct xfrm4_protocol *handler; 67 + struct xfrm4_protocol __rcu **head = proto_handlers(nexthdr); 71 68 72 69 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = NULL; 73 70 XFRM_SPI_SKB_CB(skb)->family = AF_INET; 74 71 XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr); 75 72 76 - for_each_protocol_rcu(*proto_handlers(nexthdr), handler) 73 + if (!head) 74 + goto out; 75 + 76 + for_each_protocol_rcu(*head, handler) 77 77 if ((ret = handler->input_handler(skb, nexthdr, spi, encap_type)) != -EINVAL) 78 78 return ret; 79 79 80 + out: 80 81 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); 81 82 82 83 kfree_skb(skb); ··· 217 208 int ret = -EEXIST; 218 209 int priority = handler->priority; 219 210 211 + if (!proto_handlers(protocol) || !netproto(protocol)) 212 + return -EINVAL; 213 + 220 214 mutex_lock(&xfrm4_protocol_mutex); 221 215 222 216 if (!rcu_dereference_protected(*proto_handlers(protocol), ··· 261 249 struct xfrm4_protocol __rcu **pprev; 262 250 struct xfrm4_protocol *t; 263 251 int ret = -ENOENT; 252 + 253 + if (!proto_handlers(protocol) || !netproto(protocol)) 254 + return -EINVAL; 264 255 265 256 mutex_lock(&xfrm4_protocol_mutex); 266 257
+1 -5
net/ipv6/ip6_offload.c
··· 196 196 unsigned int off; 197 197 u16 flush = 1; 198 198 int proto; 199 - __wsum csum; 200 199 201 200 off = skb_gro_offset(skb); 202 201 hlen = off + sizeof(*iph); ··· 263 264 264 265 NAPI_GRO_CB(skb)->flush |= flush; 265 266 266 - csum = skb->csum; 267 - skb_postpull_rcsum(skb, iph, skb_network_header_len(skb)); 267 + skb_gro_postpull_rcsum(skb, iph, nlen); 268 268 269 269 pp = ops->callbacks.gro_receive(head, skb); 270 - 271 - skb->csum = csum; 272 270 273 271 out_unlock: 274 272 rcu_read_unlock();
+6 -2
net/ipv6/ip6_output.c
··· 344 344 345 345 static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu) 346 346 { 347 - if (skb->len <= mtu || skb->local_df) 347 + if (skb->len <= mtu) 348 348 return false; 349 349 350 + /* ipv6 conntrack defrag sets max_frag_size + local_df */ 350 351 if (IP6CB(skb)->frag_max_size && IP6CB(skb)->frag_max_size > mtu) 351 352 return true; 353 + 354 + if (skb->local_df) 355 + return false; 352 356 353 357 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu) 354 358 return false; ··· 1229 1225 unsigned int maxnonfragsize, headersize; 1230 1226 1231 1227 headersize = sizeof(struct ipv6hdr) + 1232 - (opt ? opt->tot_len : 0) + 1228 + (opt ? opt->opt_flen + opt->opt_nflen : 0) + 1233 1229 (dst_allfrag(&rt->dst) ? 1234 1230 sizeof(struct frag_hdr) : 0) + 1235 1231 rt->rt6i_nfheader_len;
+1 -1
net/ipv6/ip6_tunnel.c
··· 1557 1557 { 1558 1558 u8 proto; 1559 1559 1560 - if (!data) 1560 + if (!data || !data[IFLA_IPTUN_PROTO]) 1561 1561 return 0; 1562 1562 1563 1563 proto = nla_get_u8(data[IFLA_IPTUN_PROTO]);
+4 -4
net/ipv6/ip6_vti.c
··· 511 511 u8 type, u8 code, int offset, __be32 info) 512 512 { 513 513 __be32 spi; 514 + __u32 mark; 514 515 struct xfrm_state *x; 515 516 struct ip6_tnl *t; 516 517 struct ip_esp_hdr *esph; ··· 524 523 t = vti6_tnl_lookup(dev_net(skb->dev), &iph->daddr, &iph->saddr); 525 524 if (!t) 526 525 return -1; 526 + 527 + mark = be32_to_cpu(t->parms.o_key); 527 528 528 529 switch (protocol) { 529 530 case IPPROTO_ESP: ··· 548 545 type != NDISC_REDIRECT) 549 546 return 0; 550 547 551 - x = xfrm_state_lookup(net, skb->mark, (const xfrm_address_t *)&iph->daddr, 548 + x = xfrm_state_lookup(net, mark, (const xfrm_address_t *)&iph->daddr, 552 549 spi, protocol, AF_INET6); 553 550 if (!x) 554 551 return 0; ··· 1100 1097 1101 1098 err = xfrm6_protocol_register(&vti_esp6_protocol, IPPROTO_ESP); 1102 1099 if (err < 0) { 1103 - unregister_pernet_device(&vti6_net_ops); 1104 1100 pr_err("%s: can't register vti6 protocol\n", __func__); 1105 1101 1106 1102 goto out; ··· 1108 1106 err = xfrm6_protocol_register(&vti_ah6_protocol, IPPROTO_AH); 1109 1107 if (err < 0) { 1110 1108 xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP); 1111 - unregister_pernet_device(&vti6_net_ops); 1112 1109 pr_err("%s: can't register vti6 protocol\n", __func__); 1113 1110 1114 1111 goto out; ··· 1117 1116 if (err < 0) { 1118 1117 xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH); 1119 1118 xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP); 1120 - unregister_pernet_device(&vti6_net_ops); 1121 1119 pr_err("%s: can't register vti6 protocol\n", __func__); 1122 1120 1123 1121 goto out;
+2 -5
net/ipv6/ndisc.c
··· 851 851 static void ndisc_recv_na(struct sk_buff *skb) 852 852 { 853 853 struct nd_msg *msg = (struct nd_msg *)skb_transport_header(skb); 854 - const struct in6_addr *saddr = &ipv6_hdr(skb)->saddr; 854 + struct in6_addr *saddr = &ipv6_hdr(skb)->saddr; 855 855 const struct in6_addr *daddr = &ipv6_hdr(skb)->daddr; 856 856 u8 *lladdr = NULL; 857 857 u32 ndoptlen = skb_tail_pointer(skb) - (skb_transport_header(skb) + ··· 944 944 /* 945 945 * Change: router to host 946 946 */ 947 - struct rt6_info *rt; 948 - rt = rt6_get_dflt_router(saddr, dev); 949 - if (rt) 950 - ip6_del_rt(rt); 947 + rt6_clean_tohost(dev_net(dev), saddr); 951 948 } 952 949 953 950 out:
+4 -2
net/ipv6/netfilter.c
··· 30 30 .daddr = iph->daddr, 31 31 .saddr = iph->saddr, 32 32 }; 33 + int err; 33 34 34 35 dst = ip6_route_output(net, skb->sk, &fl6); 35 - if (dst->error) { 36 + err = dst->error; 37 + if (err) { 36 38 IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); 37 39 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n"); 38 40 dst_release(dst); 39 - return dst->error; 41 + return err; 40 42 } 41 43 42 44 /* Drop old route. */
+24
net/ipv6/route.c
··· 2234 2234 fib6_clean_all(net, fib6_remove_prefsrc, &adni); 2235 2235 } 2236 2236 2237 + #define RTF_RA_ROUTER (RTF_ADDRCONF | RTF_DEFAULT | RTF_GATEWAY) 2238 + #define RTF_CACHE_GATEWAY (RTF_GATEWAY | RTF_CACHE) 2239 + 2240 + /* Remove routers and update dst entries when gateway turn into host. */ 2241 + static int fib6_clean_tohost(struct rt6_info *rt, void *arg) 2242 + { 2243 + struct in6_addr *gateway = (struct in6_addr *)arg; 2244 + 2245 + if ((((rt->rt6i_flags & RTF_RA_ROUTER) == RTF_RA_ROUTER) || 2246 + ((rt->rt6i_flags & RTF_CACHE_GATEWAY) == RTF_CACHE_GATEWAY)) && 2247 + ipv6_addr_equal(gateway, &rt->rt6i_gateway)) { 2248 + return -1; 2249 + } 2250 + return 0; 2251 + } 2252 + 2253 + void rt6_clean_tohost(struct net *net, struct in6_addr *gateway) 2254 + { 2255 + fib6_clean_all(net, fib6_clean_tohost, gateway); 2256 + } 2257 + 2237 2258 struct arg_dev_net { 2238 2259 struct net_device *dev; 2239 2260 struct net *net; ··· 2729 2708 2730 2709 if (tb[RTA_OIF]) 2731 2710 oif = nla_get_u32(tb[RTA_OIF]); 2711 + 2712 + if (tb[RTA_MARK]) 2713 + fl6.flowi6_mark = nla_get_u32(tb[RTA_MARK]); 2732 2714 2733 2715 if (iif) { 2734 2716 struct net_device *dev;
+1 -1
net/ipv6/tcpv6_offload.c
··· 42 42 if (NAPI_GRO_CB(skb)->flush) 43 43 goto skip_csum; 44 44 45 - wsum = skb->csum; 45 + wsum = NAPI_GRO_CB(skb)->csum; 46 46 47 47 switch (skb->ip_summed) { 48 48 case CHECKSUM_NONE:
+13 -9
net/ipv6/xfrm6_output.c
··· 114 114 if (err) 115 115 return err; 116 116 117 - memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); 118 - #ifdef CONFIG_NETFILTER 119 - IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; 120 - #endif 121 - 122 - skb->protocol = htons(ETH_P_IPV6); 123 117 skb->local_df = 1; 124 118 125 119 return x->outer_mode->output2(x, skb); ··· 122 128 123 129 int xfrm6_output_finish(struct sk_buff *skb) 124 130 { 131 + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); 132 + skb->protocol = htons(ETH_P_IPV6); 133 + 125 134 #ifdef CONFIG_NETFILTER 126 135 IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; 127 136 #endif 128 137 129 - skb->protocol = htons(ETH_P_IPV6); 130 138 return xfrm_output(skb); 131 139 } 132 140 ··· 137 141 struct dst_entry *dst = skb_dst(skb); 138 142 struct xfrm_state *x = dst->xfrm; 139 143 int mtu; 144 + 145 + #ifdef CONFIG_NETFILTER 146 + if (!x) { 147 + IP6CB(skb)->flags |= IP6SKB_REROUTED; 148 + return dst_output(skb); 149 + } 150 + #endif 140 151 141 152 if (skb->protocol == htons(ETH_P_IPV6)) 142 153 mtu = ip6_skb_dst_mtu(skb); ··· 168 165 169 166 int xfrm6_output(struct sock *sk, struct sk_buff *skb) 170 167 { 171 - return NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL, 172 - skb_dst(skb)->dev, __xfrm6_output); 168 + return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, 169 + NULL, skb_dst(skb)->dev, __xfrm6_output, 170 + !(IP6CB(skb)->flags & IP6SKB_REROUTED)); 173 171 }
+10 -1
net/ipv6/xfrm6_protocol.c
··· 50 50 { 51 51 int ret; 52 52 struct xfrm6_protocol *handler; 53 + struct xfrm6_protocol __rcu **head = proto_handlers(protocol); 54 + 55 + if (!head) 56 + return 0; 53 57 54 58 for_each_protocol_rcu(*proto_handlers(protocol), handler) 55 59 if ((ret = handler->cb_handler(skb, err)) <= 0) ··· 188 184 struct xfrm6_protocol __rcu **pprev; 189 185 struct xfrm6_protocol *t; 190 186 bool add_netproto = false; 191 - 192 187 int ret = -EEXIST; 193 188 int priority = handler->priority; 189 + 190 + if (!proto_handlers(protocol) || !netproto(protocol)) 191 + return -EINVAL; 194 192 195 193 mutex_lock(&xfrm6_protocol_mutex); 196 194 ··· 235 229 struct xfrm6_protocol __rcu **pprev; 236 230 struct xfrm6_protocol *t; 237 231 int ret = -ENOENT; 232 + 233 + if (!proto_handlers(protocol) || !netproto(protocol)) 234 + return -EINVAL; 238 235 239 236 mutex_lock(&xfrm6_protocol_mutex); 240 237
+1 -1
net/iucv/af_iucv.c
··· 1830 1830 spin_lock_irqsave(&list->lock, flags); 1831 1831 1832 1832 while (list_skb != (struct sk_buff *)list) { 1833 - if (msg->tag != IUCV_SKB_CB(list_skb)->tag) { 1833 + if (msg->tag == IUCV_SKB_CB(list_skb)->tag) { 1834 1834 this = list_skb; 1835 1835 break; 1836 1836 }
+1
net/mac80211/ieee80211_i.h
··· 317 317 318 318 bool started, abort, hw_begun, notified; 319 319 bool to_be_freed; 320 + bool on_channel; 320 321 321 322 unsigned long hw_start_time; 322 323
+13 -7
net/mac80211/mlme.c
··· 3598 3598 3599 3599 sdata_lock(sdata); 3600 3600 3601 - if (ifmgd->auth_data) { 3601 + if (ifmgd->auth_data || ifmgd->assoc_data) { 3602 + const u8 *bssid = ifmgd->auth_data ? 3603 + ifmgd->auth_data->bss->bssid : 3604 + ifmgd->assoc_data->bss->bssid; 3605 + 3602 3606 /* 3603 - * If we are trying to authenticate while suspending, cfg80211 3604 - * won't know and won't actually abort those attempts, thus we 3605 - * need to do that ourselves. 3607 + * If we are trying to authenticate / associate while suspending, 3608 + * cfg80211 won't know and won't actually abort those attempts, 3609 + * thus we need to do that ourselves. 3606 3610 */ 3607 - ieee80211_send_deauth_disassoc(sdata, 3608 - ifmgd->auth_data->bss->bssid, 3611 + ieee80211_send_deauth_disassoc(sdata, bssid, 3609 3612 IEEE80211_STYPE_DEAUTH, 3610 3613 WLAN_REASON_DEAUTH_LEAVING, 3611 3614 false, frame_buf); 3612 - ieee80211_destroy_auth_data(sdata, false); 3615 + if (ifmgd->assoc_data) 3616 + ieee80211_destroy_assoc_data(sdata, false); 3617 + if (ifmgd->auth_data) 3618 + ieee80211_destroy_auth_data(sdata, false); 3613 3619 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, 3614 3620 IEEE80211_DEAUTH_FRAME_LEN); 3615 3621 }
+20 -7
net/mac80211/offchannel.c
··· 333 333 container_of(work, struct ieee80211_roc_work, work.work); 334 334 struct ieee80211_sub_if_data *sdata = roc->sdata; 335 335 struct ieee80211_local *local = sdata->local; 336 - bool started; 336 + bool started, on_channel; 337 337 338 338 mutex_lock(&local->mtx); 339 339 ··· 354 354 if (!roc->started) { 355 355 struct ieee80211_roc_work *dep; 356 356 357 - /* start this ROC */ 358 - ieee80211_offchannel_stop_vifs(local); 357 + WARN_ON(local->use_chanctx); 359 358 360 - /* switch channel etc */ 359 + /* If actually operating on the desired channel (with at least 360 + * 20 MHz channel width) don't stop all the operations but still 361 + * treat it as though the ROC operation started properly, so 362 + * other ROC operations won't interfere with this one. 363 + */ 364 + roc->on_channel = roc->chan == local->_oper_chandef.chan && 365 + local->_oper_chandef.width != NL80211_CHAN_WIDTH_5 && 366 + local->_oper_chandef.width != NL80211_CHAN_WIDTH_10; 367 + 368 + /* start this ROC */ 361 369 ieee80211_recalc_idle(local); 362 370 363 - local->tmp_channel = roc->chan; 364 - ieee80211_hw_config(local, 0); 371 + if (!roc->on_channel) { 372 + ieee80211_offchannel_stop_vifs(local); 373 + 374 + local->tmp_channel = roc->chan; 375 + ieee80211_hw_config(local, 0); 376 + } 365 377 366 378 /* tell userspace or send frame */ 367 379 ieee80211_handle_roc_started(roc); ··· 392 380 finish: 393 381 list_del(&roc->list); 394 382 started = roc->started; 383 + on_channel = roc->on_channel; 395 384 ieee80211_roc_notify_destroy(roc, !roc->abort); 396 385 397 - if (started) { 386 + if (started && !on_channel) { 398 387 ieee80211_flush_queues(local, NULL); 399 388 400 389 local->tmp_channel = NULL;
+2 -1
net/mac80211/rx.c
··· 1231 1231 if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) && 1232 1232 test_sta_flag(sta, WLAN_STA_AUTHORIZED)) { 1233 1233 sta->last_rx = jiffies; 1234 - if (ieee80211_is_data(hdr->frame_control)) { 1234 + if (ieee80211_is_data(hdr->frame_control) && 1235 + !is_multicast_ether_addr(hdr->addr1)) { 1235 1236 sta->last_rx_rate_idx = status->rate_idx; 1236 1237 sta->last_rx_rate_flag = status->flag; 1237 1238 sta->last_rx_rate_vht_flag = status->vht_flag;
+2 -1
net/mac80211/sta_info.c
··· 1148 1148 atomic_dec(&ps->num_sta_ps); 1149 1149 1150 1150 /* This station just woke up and isn't aware of our SMPS state */ 1151 - if (!ieee80211_smps_is_restrictive(sta->known_smps_mode, 1151 + if (!ieee80211_vif_is_mesh(&sdata->vif) && 1152 + !ieee80211_smps_is_restrictive(sta->known_smps_mode, 1152 1153 sdata->smps_mode) && 1153 1154 sta->known_smps_mode != sdata->bss->req_smps && 1154 1155 sta_info_tx_streams(sta) != 1) {
+2 -3
net/mac80211/status.c
··· 314 314 !is_multicast_ether_addr(hdr->addr1)) 315 315 txflags |= IEEE80211_RADIOTAP_F_TX_FAIL; 316 316 317 - if ((info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || 318 - (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) 317 + if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) 319 318 txflags |= IEEE80211_RADIOTAP_F_TX_CTS; 320 - else if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) 319 + if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) 321 320 txflags |= IEEE80211_RADIOTAP_F_TX_RTS; 322 321 323 322 put_unaligned_le16(txflags, pos);
+2 -2
net/mac80211/trace.h
··· 21 21 22 22 #define VIF_ENTRY __field(enum nl80211_iftype, vif_type) __field(void *, sdata) \ 23 23 __field(bool, p2p) \ 24 - __string(vif_name, sdata->dev ? sdata->dev->name : "<nodev>") 24 + __string(vif_name, sdata->name) 25 25 #define VIF_ASSIGN __entry->vif_type = sdata->vif.type; __entry->sdata = sdata; \ 26 26 __entry->p2p = sdata->vif.p2p; \ 27 - __assign_str(vif_name, sdata->dev ? sdata->dev->name : sdata->name) 27 + __assign_str(vif_name, sdata->name) 28 28 #define VIF_PR_FMT " vif:%s(%d%s)" 29 29 #define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" 30 30
+1 -1
net/mac80211/util.c
··· 1780 1780 mutex_unlock(&local->mtx); 1781 1781 1782 1782 if (sched_scan_stopped) 1783 - cfg80211_sched_scan_stopped(local->hw.wiphy); 1783 + cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy); 1784 1784 1785 1785 /* 1786 1786 * If this is for hw restart things are still running.
+6 -3
net/mac80211/vht.c
··· 129 129 if (!vht_cap_ie || !sband->vht_cap.vht_supported) 130 130 return; 131 131 132 - /* A VHT STA must support 40 MHz */ 133 - if (!(sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)) 134 - return; 132 + /* 133 + * A VHT STA must support 40 MHz, but if we verify that here 134 + * then we break a few things - some APs (e.g. Netgear R6300v2 135 + * and others based on the BCM4360 chipset) will unset this 136 + * capability bit when operating in 20 MHz. 137 + */ 135 138 136 139 vht_cap->vht_supported = true; 137 140
+3
net/netfilter/nf_conntrack_netlink.c
··· 1336 1336 #ifdef CONFIG_NF_NAT_NEEDED 1337 1337 int ret; 1338 1338 1339 + if (!cda[CTA_NAT_DST] && !cda[CTA_NAT_SRC]) 1340 + return 0; 1341 + 1339 1342 ret = ctnetlink_parse_nat_setup(ct, NF_NAT_MANIP_DST, 1340 1343 cda[CTA_NAT_DST]); 1341 1344 if (ret < 0)
+23 -26
net/netfilter/nf_tables_core.c
··· 66 66 int rulenum; 67 67 }; 68 68 69 - static inline void 70 - nft_chain_stats(const struct nft_chain *this, const struct nft_pktinfo *pkt, 71 - struct nft_jumpstack *jumpstack, unsigned int stackptr) 72 - { 73 - struct nft_stats __percpu *stats; 74 - const struct nft_chain *chain = stackptr ? jumpstack[0].chain : this; 75 - 76 - rcu_read_lock_bh(); 77 - stats = rcu_dereference(nft_base_chain(chain)->stats); 78 - __this_cpu_inc(stats->pkts); 79 - __this_cpu_add(stats->bytes, pkt->skb->len); 80 - rcu_read_unlock_bh(); 81 - } 82 - 83 69 enum nft_trace { 84 70 NFT_TRACE_RULE, 85 71 NFT_TRACE_RETURN, ··· 103 117 unsigned int 104 118 nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops) 105 119 { 106 - const struct nft_chain *chain = ops->priv; 120 + const struct nft_chain *chain = ops->priv, *basechain = chain; 107 121 const struct nft_rule *rule; 108 122 const struct nft_expr *expr, *last; 109 123 struct nft_data data[NFT_REG_MAX + 1]; 110 124 unsigned int stackptr = 0; 111 125 struct nft_jumpstack jumpstack[NFT_JUMP_STACK_SIZE]; 112 - int rulenum = 0; 126 + struct nft_stats __percpu *stats; 127 + int rulenum; 113 128 /* 114 129 * Cache cursor to avoid problems in case that the cursor is updated 115 130 * while traversing the ruleset. ··· 118 131 unsigned int gencursor = ACCESS_ONCE(chain->net->nft.gencursor); 119 132 120 133 do_chain: 134 + rulenum = 0; 121 135 rule = list_entry(&chain->rules, struct nft_rule, list); 122 136 next_rule: 123 137 data[NFT_REG_VERDICT].verdict = NFT_CONTINUE; ··· 144 156 switch (data[NFT_REG_VERDICT].verdict) { 145 157 case NFT_BREAK: 146 158 data[NFT_REG_VERDICT].verdict = NFT_CONTINUE; 147 - /* fall through */ 159 + continue; 148 160 case NFT_CONTINUE: 161 + if (unlikely(pkt->skb->nf_trace)) 162 + nft_trace_packet(pkt, chain, rulenum, NFT_TRACE_RULE); 149 163 continue; 150 164 } 151 165 break; ··· 173 183 jumpstack[stackptr].rule = rule; 174 184 jumpstack[stackptr].rulenum = rulenum; 175 185 stackptr++; 176 - /* fall through */ 186 + chain = data[NFT_REG_VERDICT].chain; 187 + goto do_chain; 177 188 case NFT_GOTO: 189 + if (unlikely(pkt->skb->nf_trace)) 190 + nft_trace_packet(pkt, chain, rulenum, NFT_TRACE_RULE); 191 + 178 192 chain = data[NFT_REG_VERDICT].chain; 179 193 goto do_chain; 180 194 case NFT_RETURN: 181 195 if (unlikely(pkt->skb->nf_trace)) 182 196 nft_trace_packet(pkt, chain, rulenum, NFT_TRACE_RETURN); 183 - 184 - /* fall through */ 197 + break; 185 198 case NFT_CONTINUE: 199 + if (unlikely(pkt->skb->nf_trace && !(chain->flags & NFT_BASE_CHAIN))) 200 + nft_trace_packet(pkt, chain, ++rulenum, NFT_TRACE_RETURN); 186 201 break; 187 202 default: 188 203 WARN_ON(1); 189 204 } 190 205 191 206 if (stackptr > 0) { 192 - if (unlikely(pkt->skb->nf_trace)) 193 - nft_trace_packet(pkt, chain, ++rulenum, NFT_TRACE_RETURN); 194 - 195 207 stackptr--; 196 208 chain = jumpstack[stackptr].chain; 197 209 rule = jumpstack[stackptr].rule; 198 210 rulenum = jumpstack[stackptr].rulenum; 199 211 goto next_rule; 200 212 } 201 - nft_chain_stats(chain, pkt, jumpstack, stackptr); 202 213 203 214 if (unlikely(pkt->skb->nf_trace)) 204 - nft_trace_packet(pkt, chain, ++rulenum, NFT_TRACE_POLICY); 215 + nft_trace_packet(pkt, basechain, -1, NFT_TRACE_POLICY); 205 216 206 - return nft_base_chain(chain)->policy; 217 + rcu_read_lock_bh(); 218 + stats = rcu_dereference(nft_base_chain(basechain)->stats); 219 + __this_cpu_inc(stats->pkts); 220 + __this_cpu_add(stats->bytes, pkt->skb->len); 221 + rcu_read_unlock_bh(); 222 + 223 + return nft_base_chain(basechain)->policy; 207 224 } 208 225 EXPORT_SYMBOL_GPL(nft_do_chain); 209 226
+4 -4
net/netfilter/nfnetlink.c
··· 256 256 #endif 257 257 { 258 258 nfnl_unlock(subsys_id); 259 - kfree_skb(nskb); 260 - return netlink_ack(skb, nlh, -EOPNOTSUPP); 259 + netlink_ack(skb, nlh, -EOPNOTSUPP); 260 + return kfree_skb(nskb); 261 261 } 262 262 } 263 263 264 264 if (!ss->commit || !ss->abort) { 265 265 nfnl_unlock(subsys_id); 266 - kfree_skb(nskb); 267 - return netlink_ack(skb, nlh, -EOPNOTSUPP); 266 + netlink_ack(skb, nlh, -EOPNOTSUPP); 267 + return kfree_skb(skb); 268 268 } 269 269 270 270 while (skb->len >= nlmsg_total_size(0)) {
+1 -1
net/rxrpc/ar-key.c
··· 99 99 _debug("tktlen: %x", tktlen); 100 100 if (tktlen > AFSTOKEN_RK_TIX_MAX) 101 101 return -EKEYREJECTED; 102 - if (8 * 4 + tktlen != toklen) 102 + if (toklen < 8 * 4 + tktlen) 103 103 return -EKEYREJECTED; 104 104 105 105 plen = sizeof(*token) + sizeof(*token->kad) + tktlen;
+20 -10
net/sched/cls_tcindex.c
··· 188 188 [TCA_TCINDEX_CLASSID] = { .type = NLA_U32 }, 189 189 }; 190 190 191 + static void tcindex_filter_result_init(struct tcindex_filter_result *r) 192 + { 193 + memset(r, 0, sizeof(*r)); 194 + tcf_exts_init(&r->exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE); 195 + } 196 + 191 197 static int 192 198 tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, 193 199 u32 handle, struct tcindex_data *p, ··· 213 207 return err; 214 208 215 209 memcpy(&cp, p, sizeof(cp)); 216 - memset(&new_filter_result, 0, sizeof(new_filter_result)); 217 - tcf_exts_init(&new_filter_result.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE); 210 + tcindex_filter_result_init(&new_filter_result); 218 211 212 + tcindex_filter_result_init(&cr); 219 213 if (old_r) 220 - memcpy(&cr, r, sizeof(cr)); 221 - else { 222 - memset(&cr, 0, sizeof(cr)); 223 - tcf_exts_init(&cr.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE); 224 - } 214 + cr.res = r->res; 225 215 226 216 if (tb[TCA_TCINDEX_HASH]) 227 217 cp.hash = nla_get_u32(tb[TCA_TCINDEX_HASH]); ··· 269 267 err = -ENOMEM; 270 268 if (!cp.perfect && !cp.h) { 271 269 if (valid_perfect_hash(&cp)) { 270 + int i; 271 + 272 272 cp.perfect = kcalloc(cp.hash, sizeof(*r), GFP_KERNEL); 273 273 if (!cp.perfect) 274 274 goto errout; 275 + for (i = 0; i < cp.hash; i++) 276 + tcf_exts_init(&cp.perfect[i].exts, TCA_TCINDEX_ACT, 277 + TCA_TCINDEX_POLICE); 275 278 balloc = 1; 276 279 } else { 277 280 cp.h = kcalloc(cp.hash, sizeof(f), GFP_KERNEL); ··· 302 295 tcf_bind_filter(tp, &cr.res, base); 303 296 } 304 297 305 - tcf_exts_change(tp, &cr.exts, &e); 298 + if (old_r) 299 + tcf_exts_change(tp, &r->exts, &e); 300 + else 301 + tcf_exts_change(tp, &cr.exts, &e); 306 302 307 303 tcf_tree_lock(tp); 308 304 if (old_r && old_r != r) 309 - memset(old_r, 0, sizeof(*old_r)); 305 + tcindex_filter_result_init(old_r); 310 306 311 307 memcpy(p, &cp, sizeof(cp)); 312 - memcpy(r, &cr, sizeof(cr)); 308 + r->res = cr.res; 313 309 314 310 if (r == &new_filter_result) { 315 311 struct tcindex_filter **fp;
+10 -2
net/wireless/scan.c
··· 284 284 } 285 285 EXPORT_SYMBOL(cfg80211_sched_scan_results); 286 286 287 - void cfg80211_sched_scan_stopped(struct wiphy *wiphy) 287 + void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy) 288 288 { 289 289 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 290 290 291 + ASSERT_RTNL(); 292 + 291 293 trace_cfg80211_sched_scan_stopped(wiphy); 292 294 293 - rtnl_lock(); 294 295 __cfg80211_stop_sched_scan(rdev, true); 296 + } 297 + EXPORT_SYMBOL(cfg80211_sched_scan_stopped_rtnl); 298 + 299 + void cfg80211_sched_scan_stopped(struct wiphy *wiphy) 300 + { 301 + rtnl_lock(); 302 + cfg80211_sched_scan_stopped_rtnl(wiphy); 295 303 rtnl_unlock(); 296 304 } 297 305 EXPORT_SYMBOL(cfg80211_sched_scan_stopped);
+1 -1
net/wireless/sme.c
··· 234 234 NULL, 0, NULL, 0, 235 235 WLAN_STATUS_UNSPECIFIED_FAILURE, 236 236 false, NULL); 237 - cfg80211_sme_free(wdev); 238 237 } 239 238 wdev_unlock(wdev); 240 239 } ··· 647 648 cfg80211_unhold_bss(bss_from_pub(bss)); 648 649 cfg80211_put_bss(wdev->wiphy, bss); 649 650 } 651 + cfg80211_sme_free(wdev); 650 652 return; 651 653 } 652 654
+6
tools/Makefile
··· 44 44 cgroup firewire hv guest usb virtio vm net: FORCE 45 45 $(call descend,$@) 46 46 47 + liblockdep: FORCE 48 + $(call descend,lib/lockdep) 49 + 47 50 libapikfs: FORCE 48 51 $(call descend,lib/api) 49 52 ··· 93 90 94 91 cgroup_clean hv_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean: 95 92 $(call descend,$(@:_clean=),clean) 93 + 94 + liblockdep_clean: 95 + $(call descend,lib/lockdep,clean) 96 96 97 97 libapikfs_clean: 98 98 $(call descend,lib/api,clean)
+2 -3
tools/lib/lockdep/Makefile
··· 1 1 # file format version 2 2 FILE_VERSION = 1 3 3 4 - MAKEFLAGS += --no-print-directory 5 - LIBLOCKDEP_VERSION=$(shell make -sC ../../.. kernelversion) 4 + LIBLOCKDEP_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion) 6 5 7 6 # Makefiles suck: This macro sets a default value of $(2) for the 8 7 # variable named by $(1), unless the variable has been set by ··· 230 231 install: install_lib 231 232 232 233 clean: 233 - $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d 234 + $(RM) *.o *~ $(TARGETS) *.a *liblockdep*.so* $(VERSION_FILES) .*.d 234 235 $(RM) tags TAGS 235 236 236 237 endif # skip-makefile