···6666route/max_size - INTEGER6767 Maximum number of routes allowed in the kernel. Increase6868 this when using large numbers of interfaces and/or routes.6969+ From linux kernel 3.6 onwards, this is deprecated for ipv47070+ as route cache is no longer used.69717072neigh/default/gc_thresh1 - INTEGER7173 Minimum number of entries to keep. Garbage collector will not
···3344Written by Amit Daniel Kachhap <amit.kachhap@linaro.org>5566-Updated: 12 May 201266+Updated: 6 Jan 20157788Copyright (c) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com)99···25252626 clip_cpus: cpumask of cpus where the frequency constraints will happen.27272828-1.1.2 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)2828+1.1.2 struct thermal_cooling_device *of_cpufreq_cooling_register(2929+ struct device_node *np, const struct cpumask *clip_cpus)3030+3131+ This interface function registers the cpufreq cooling device with3232+ the name "thermal-cpufreq-%x" linking it with a device tree node, in3333+ order to bind it via the thermal DT code. This api can support multiple3434+ instances of cpufreq cooling devices.3535+3636+ np: pointer to the cooling device device tree node3737+ clip_cpus: cpumask of cpus where the frequency constraints will happen.3838+3939+1.1.3 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)29403041 This interface function unregisters the "thermal-cpufreq-%x" cooling device.3142
+19-8
MAINTAINERS
···724724F: drivers/char/apm-emulation.c725725726726APPLE BCM5974 MULTITOUCH DRIVER727727-M: Henrik Rydberg <rydberg@euromail.se>727727+M: Henrik Rydberg <rydberg@bitmath.org>728728L: linux-input@vger.kernel.org729729-S: Maintained729729+S: Odd fixes730730F: drivers/input/mouse/bcm5974.c731731732732APPLE SMC DRIVER733733-M: Henrik Rydberg <rydberg@euromail.se>733733+M: Henrik Rydberg <rydberg@bitmath.org>734734L: lm-sensors@lm-sensors.org735735-S: Maintained735735+S: Odd fixes736736F: drivers/hwmon/applesmc.c737737738738APPLETALK NETWORK LAYER···22592259BTRFS FILE SYSTEM22602260M: Chris Mason <clm@fb.com>22612261M: Josef Bacik <jbacik@fb.com>22622262+M: David Sterba <dsterba@suse.cz>22622263L: linux-btrfs@vger.kernel.org22632264W: http://btrfs.wiki.kernel.org/22642265Q: http://patchwork.kernel.org/project/linux-btrfs/list/···47494748F: drivers/scsi/ipr.*4750474947514750IBM Power Virtual Ethernet Device Driver47524752-M: Santiago Leon <santil@linux.vnet.ibm.com>47514751+M: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>47534752L: netdev@vger.kernel.org47544753S: Supported47554754F: drivers/net/ethernet/ibm/ibmveth.*···49414940F: include/linux/input/4942494149434942INPUT MULTITOUCH (MT) PROTOCOL49444944-M: Henrik Rydberg <rydberg@euromail.se>49434943+M: Henrik Rydberg <rydberg@bitmath.org>49454944L: linux-input@vger.kernel.org49464945T: git git://git.kernel.org/pub/scm/linux/kernel/git/rydberg/input-mt.git49474947-S: Maintained49464946+S: Odd fixes49484947F: Documentation/input/multi-touch-protocol.txt49494948F: drivers/input/input-mt.c49504949K: \b(ABS|SYN)_MT_···52795278W: www.open-iscsi.org52805279Q: http://patchwork.kernel.org/project/linux-rdma/list/52815280F: drivers/infiniband/ulp/iser/52815281+52825282+ISCSI EXTENSIONS FOR RDMA (ISER) TARGET52835283+M: Sagi Grimberg <sagig@mellanox.com>52845284+T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master52855285+L: linux-rdma@vger.kernel.org52865286+L: target-devel@vger.kernel.org52875287+S: Supported52885288+W: http://www.linux-iscsi.org52895289+F: drivers/infiniband/ulp/isert5282529052835291ISDN SUBSYSTEM52845292M: Karsten Keil <isdn@linux-pingi.de>···95439533TI BANDGAP AND THERMAL DRIVER95449534M: Eduardo Valentin <edubezval@gmail.com>95459535L: linux-pm@vger.kernel.org95469546-S: Supported95369536+L: linux-omap@vger.kernel.org95379537+S: Maintained95479538F: drivers/thermal/ti-soc-thermal/9548953995499540TI CLOCK DRIVER
+2-1
Makefile
···11VERSION = 322PATCHLEVEL = 1933SUBLEVEL = 044-EXTRAVERSION = -rc344+EXTRAVERSION = -rc455NAME = Diseased Newt6677# *DOCUMENTATION*···391391# Needed to be compatible with the O= option392392LINUXINCLUDE := \393393 -I$(srctree)/arch/$(hdr-arch)/include \394394+ -Iarch/$(hdr-arch)/include/generated/uapi \394395 -Iarch/$(hdr-arch)/include/generated \395396 $(if $(KBUILD_SRC), -I$(srctree)/include) \396397 -Iinclude \
···413413#define __NR_getrandom (__NR_SYSCALL_BASE+384)414414#define __NR_memfd_create (__NR_SYSCALL_BASE+385)415415#define __NR_bpf (__NR_SYSCALL_BASE+386)416416+#define __NR_execveat (__NR_SYSCALL_BASE+387)416417417418/*418419 * The following SWIs are ARM private.
···31313232#include <asm/fpsimd.h>3333#include <asm/hw_breakpoint.h>3434+#include <asm/pgtable-hwdef.h>3435#include <asm/ptrace.h>3536#include <asm/types.h>3637···123122124123/* Free all resources held by a thread. */125124extern void release_thread(struct task_struct *);126126-127127-/* Prepare to copy thread state - unlazy all lazy status */128128-#define prepare_to_copy(tsk) do { } while (0)129125130126unsigned long get_wchan(struct task_struct *p);131127
···147147 * If we have AArch32, we care about 32-bit features for compat. These148148 * registers should be RES0 otherwise.149149 */150150+ diff |= CHECK(id_dfr0, boot, cur, cpu);150151 diff |= CHECK(id_isar0, boot, cur, cpu);151152 diff |= CHECK(id_isar1, boot, cur, cpu);152153 diff |= CHECK(id_isar2, boot, cur, cpu);···165164 diff |= CHECK(id_mmfr3, boot, cur, cpu);166165 diff |= CHECK(id_pfr0, boot, cur, cpu);167166 diff |= CHECK(id_pfr1, boot, cur, cpu);167167+168168+ diff |= CHECK(mvfr0, boot, cur, cpu);169169+ diff |= CHECK(mvfr1, boot, cur, cpu);170170+ diff |= CHECK(mvfr2, boot, cur, cpu);168171169172 /*170173 * Mismatched CPU features are a recipe for disaster. Don't even···194189 info->reg_id_aa64pfr0 = read_cpuid(ID_AA64PFR0_EL1);195190 info->reg_id_aa64pfr1 = read_cpuid(ID_AA64PFR1_EL1);196191192192+ info->reg_id_dfr0 = read_cpuid(ID_DFR0_EL1);197193 info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1);198194 info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1);199195 info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1);···207201 info->reg_id_mmfr3 = read_cpuid(ID_MMFR3_EL1);208202 info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1);209203 info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1);204204+205205+ info->reg_mvfr0 = read_cpuid(MVFR0_EL1);206206+ info->reg_mvfr1 = read_cpuid(MVFR1_EL1);207207+ info->reg_mvfr2 = read_cpuid(MVFR2_EL1);210208211209 cpuinfo_detect_icache_policy(info);212210
+1-1
arch/arm64/kernel/efi.c
···326326327327 /* boot time idmap_pg_dir is incomplete, so fill in missing parts */328328 efi_setup_idmap();329329+ early_memunmap(memmap.map, memmap.map_end - memmap.map);329330}330331331332static int __init remap_region(efi_memory_desc_t *md, void **new)···381380 }382381383382 mapsize = memmap.map_end - memmap.map;384384- early_memunmap(memmap.map, mapsize);385383386384 if (efi_runtime_disabled()) {387385 pr_info("EFI runtime services will be disabled.\n");
···10141014 * Instead, we invalidate Stage-2 for this IPA, and the10151015 * whole of Stage-1. Weep...10161016 */10171017+ lsr x1, x1, #1210171018 tlbi ipas2e1is, x110181019 /*10191020 * We have to ensure completion of the invalidation at Stage-2,
···231231struct dbfs_d2fc_hdr {232232 u64 len; /* Length of d2fc buffer without header */233233 u16 version; /* Version of header */234234- char tod_ext[16]; /* TOD clock for d2fc */234234+ char tod_ext[STORE_CLOCK_EXT_SIZE]; /* TOD clock for d2fc */235235 u64 count; /* Number of VM guests in d2fc buffer */236236 char reserved[30];237237} __attribute__ ((packed));
+1-1
arch/s390/include/asm/irqflags.h
···36363737static inline notrace unsigned long arch_local_save_flags(void)3838{3939- return __arch_local_irq_stosm(0x00);3939+ return __arch_local_irq_stnsm(0xff);4040}41414242static inline notrace unsigned long arch_local_irq_save(void)
···289289#define __NR_bpf 351290290#define __NR_s390_pci_mmio_write 352291291#define __NR_s390_pci_mmio_read 353292292-#define NR_syscalls 354292292+#define __NR_execveat 354293293+#define NR_syscalls 355293294294295/* 295296 * There are some system calls that are not present on 64 bit, some
···80808181 /*8282 * Load per CPU data from GDT. LSL is faster than RDTSCP and8383- * works on all CPUs.8383+ * works on all CPUs. This is volatile so that it orders8484+ * correctly wrt barrier() and to keep gcc from cleverly8585+ * hoisting it out of the calling function.8486 */8585- asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));8787+ asm volatile ("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));86888789 return p;8890}
+4-5
arch/x86/kernel/acpi/boot.c
···750750}751751752752/* wrapper to silence section mismatch warning */753753-int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)753753+int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)754754{755755 return _acpi_map_lsapic(handle, physid, pcpu);756756}757757-EXPORT_SYMBOL(acpi_map_lsapic);757757+EXPORT_SYMBOL(acpi_map_cpu);758758759759-int acpi_unmap_lsapic(int cpu)759759+int acpi_unmap_cpu(int cpu)760760{761761#ifdef CONFIG_ACPI_NUMA762762 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);···768768769769 return (0);770770}771771-772772-EXPORT_SYMBOL(acpi_unmap_lsapic);771771+EXPORT_SYMBOL(acpi_unmap_cpu);773772#endif /* CONFIG_ACPI_HOTPLUG_CPU */774773775774int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
···891891enum {892892 SNBEP_PCI_QPI_PORT0_FILTER,893893 SNBEP_PCI_QPI_PORT1_FILTER,894894+ HSWEP_PCI_PCU_3,894895};895896896897static int snbep_qpi_hw_config(struct intel_uncore_box *box, struct perf_event *event)···20272026{20282027 if (hswep_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)20292028 hswep_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;20292029+20302030+ /* Detect 6-8 core systems with only two SBOXes */20312031+ if (uncore_extra_pci_dev[0][HSWEP_PCI_PCU_3]) {20322032+ u32 capid4;20332033+20342034+ pci_read_config_dword(uncore_extra_pci_dev[0][HSWEP_PCI_PCU_3],20352035+ 0x94, &capid4);20362036+ if (((capid4 >> 6) & 0x3) == 0)20372037+ hswep_uncore_sbox.num_boxes = 2;20382038+ }20392039+20302040 uncore_msr_uncores = hswep_msr_uncores;20312041}20322042···22982286 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2f96),22992287 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,23002288 SNBEP_PCI_QPI_PORT1_FILTER),22892289+ },22902290+ { /* PCU.3 (for Capability registers) */22912291+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2fc0),22922292+ .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,22932293+ HSWEP_PCI_PCU_3),23012294 },23022295 { /* end: all zeroes */ }23032296};
+90
arch/x86/kernel/perf_regs.c
···7878{7979 return PERF_SAMPLE_REGS_ABI_32;8080}8181+8282+void perf_get_regs_user(struct perf_regs *regs_user,8383+ struct pt_regs *regs,8484+ struct pt_regs *regs_user_copy)8585+{8686+ regs_user->regs = task_pt_regs(current);8787+ regs_user->abi = perf_reg_abi(current);8888+}8189#else /* CONFIG_X86_64 */8290#define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \8391 (1ULL << PERF_REG_X86_ES) | \···109101 return PERF_SAMPLE_REGS_ABI_32;110102 else111103 return PERF_SAMPLE_REGS_ABI_64;104104+}105105+106106+void perf_get_regs_user(struct perf_regs *regs_user,107107+ struct pt_regs *regs,108108+ struct pt_regs *regs_user_copy)109109+{110110+ struct pt_regs *user_regs = task_pt_regs(current);111111+112112+ /*113113+ * If we're in an NMI that interrupted task_pt_regs setup, then114114+ * we can't sample user regs at all. This check isn't really115115+ * sufficient, though, as we could be in an NMI inside an interrupt116116+ * that happened during task_pt_regs setup.117117+ */118118+ if (regs->sp > (unsigned long)&user_regs->r11 &&119119+ regs->sp <= (unsigned long)(user_regs + 1)) {120120+ regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE;121121+ regs_user->regs = NULL;122122+ return;123123+ }124124+125125+ /*126126+ * RIP, flags, and the argument registers are usually saved.127127+ * orig_ax is probably okay, too.128128+ */129129+ regs_user_copy->ip = user_regs->ip;130130+ regs_user_copy->cx = user_regs->cx;131131+ regs_user_copy->dx = user_regs->dx;132132+ regs_user_copy->si = user_regs->si;133133+ regs_user_copy->di = user_regs->di;134134+ regs_user_copy->r8 = user_regs->r8;135135+ regs_user_copy->r9 = user_regs->r9;136136+ regs_user_copy->r10 = user_regs->r10;137137+ regs_user_copy->r11 = user_regs->r11;138138+ regs_user_copy->orig_ax = user_regs->orig_ax;139139+ regs_user_copy->flags = user_regs->flags;140140+141141+ /*142142+ * Don't even try to report the "rest" regs.143143+ */144144+ regs_user_copy->bx = -1;145145+ regs_user_copy->bp = -1;146146+ regs_user_copy->r12 = -1;147147+ regs_user_copy->r13 = -1;148148+ regs_user_copy->r14 = -1;149149+ regs_user_copy->r15 = -1;150150+151151+ /*152152+ * For this to be at all useful, we need a reasonable guess for153153+ * sp and the ABI. Be careful: we're in NMI context, and we're154154+ * considering current to be the current task, so we should155155+ * be careful not to look at any other percpu variables that might156156+ * change during context switches.157157+ */158158+ if (IS_ENABLED(CONFIG_IA32_EMULATION) &&159159+ task_thread_info(current)->status & TS_COMPAT) {160160+ /* Easy case: we're in a compat syscall. */161161+ regs_user->abi = PERF_SAMPLE_REGS_ABI_32;162162+ regs_user_copy->sp = user_regs->sp;163163+ regs_user_copy->cs = user_regs->cs;164164+ regs_user_copy->ss = user_regs->ss;165165+ } else if (user_regs->orig_ax != -1) {166166+ /*167167+ * We're probably in a 64-bit syscall.168168+ * Warning: this code is severely racy. At least it's better169169+ * than just blindly copying user_regs.170170+ */171171+ regs_user->abi = PERF_SAMPLE_REGS_ABI_64;172172+ regs_user_copy->sp = this_cpu_read(old_rsp);173173+ regs_user_copy->cs = __USER_CS;174174+ regs_user_copy->ss = __USER_DS;175175+ regs_user_copy->cx = -1; /* usually contains garbage */176176+ } else {177177+ /* We're probably in an interrupt or exception. */178178+ regs_user->abi = user_64bit_mode(user_regs) ?179179+ PERF_SAMPLE_REGS_ABI_64 : PERF_SAMPLE_REGS_ABI_32;180180+ regs_user_copy->sp = user_regs->sp;181181+ regs_user_copy->cs = user_regs->cs;182182+ regs_user_copy->ss = user_regs->ss;183183+ }184184+185185+ regs_user->regs = regs_user_copy;112186}113187#endif /* CONFIG_X86_32 */
+1-1
arch/x86/lib/insn.c
···28282929/* Verify next sizeof(t) bytes can be on the same instruction */3030#define validate_next(t, insn, n) \3131- ((insn)->next_byte + sizeof(t) + n < (insn)->end_kaddr)3131+ ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr)32323333#define __get_next(t, insn) \3434 ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; })
+17-20
arch/x86/mm/init.c
···438438static unsigned long __init get_new_step_size(unsigned long step_size)439439{440440 /*441441- * Explain why we shift by 5 and why we don't have to worry about442442- * 'step_size << 5' overflowing:443443- *444444- * initial mapped size is PMD_SIZE (2M).441441+ * Initial mapped size is PMD_SIZE (2M).445442 * We can not set step_size to be PUD_SIZE (1G) yet.446443 * In worse case, when we cross the 1G boundary, and447444 * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k)448448- * to map 1G range with PTE. Use 5 as shift for now.445445+ * to map 1G range with PTE. Hence we use one less than the446446+ * difference of page table level shifts.449447 *450450- * Don't need to worry about overflow, on 32bit, when step_size451451- * is 0, round_down() returns 0 for start, and that turns it452452- * into 0x100000000ULL.448448+ * Don't need to worry about overflow in the top-down case, on 32bit,449449+ * when step_size is 0, round_down() returns 0 for start, and that450450+ * turns it into 0x100000000ULL.451451+ * In the bottom-up case, round_up(x, 0) returns 0 though too, which452452+ * needs to be taken into consideration by the code below.453453 */454454- return step_size << 5;454454+ return step_size << (PMD_SHIFT - PAGE_SHIFT - 1);455455}456456457457/**···471471 unsigned long step_size;472472 unsigned long addr;473473 unsigned long mapped_ram_size = 0;474474- unsigned long new_mapped_ram_size;475474476475 /* xen has big range in reserved near end of ram, skip it at first.*/477476 addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE);···495496 start = map_start;496497 } else497498 start = map_start;498498- new_mapped_ram_size = init_range_memory_mapping(start,499499+ mapped_ram_size += init_range_memory_mapping(start,499500 last_start);500501 last_start = start;501502 min_pfn_mapped = last_start >> PAGE_SHIFT;502502- /* only increase step_size after big range get mapped */503503- if (new_mapped_ram_size > mapped_ram_size)503503+ if (mapped_ram_size >= step_size)504504 step_size = get_new_step_size(step_size);505505- mapped_ram_size += new_mapped_ram_size;506505 }507506508507 if (real_end < map_end)···521524static void __init memory_map_bottom_up(unsigned long map_start,522525 unsigned long map_end)523526{524524- unsigned long next, new_mapped_ram_size, start;527527+ unsigned long next, start;525528 unsigned long mapped_ram_size = 0;526529 /* step_size need to be small so pgt_buf from BRK could cover it */527530 unsigned long step_size = PMD_SIZE;···536539 * for page table.537540 */538541 while (start < map_end) {539539- if (map_end - start > step_size) {542542+ if (step_size && map_end - start > step_size) {540543 next = round_up(start + 1, step_size);541544 if (next > map_end)542545 next = map_end;543543- } else546546+ } else {544547 next = map_end;548548+ }545549546546- new_mapped_ram_size = init_range_memory_mapping(start, next);550550+ mapped_ram_size += init_range_memory_mapping(start, next);547551 start = next;548552549549- if (new_mapped_ram_size > mapped_ram_size)553553+ if (mapped_ram_size >= step_size)550554 step_size = get_new_step_size(step_size);551551- mapped_ram_size += new_mapped_ram_size;552555 }553556}554557
+29-16
arch/x86/vdso/vma.c
···41414242struct linux_binprm;43434444-/* Put the vdso above the (randomized) stack with another randomized offset.4545- This way there is no hole in the middle of address space.4646- To save memory make sure it is still in the same PTE as the stack top.4747- This doesn't give that many random bits.4848-4949- Only used for the 64-bit and x32 vdsos. */4444+/*4545+ * Put the vdso above the (randomized) stack with another randomized4646+ * offset. This way there is no hole in the middle of address space.4747+ * To save memory make sure it is still in the same PTE as the stack4848+ * top. This doesn't give that many random bits.4949+ *5050+ * Note that this algorithm is imperfect: the distribution of the vdso5151+ * start address within a PMD is biased toward the end.5252+ *5353+ * Only used for the 64-bit and x32 vdsos.5454+ */5055static unsigned long vdso_addr(unsigned long start, unsigned len)5156{5257#ifdef CONFIG_X86_32···5954#else6055 unsigned long addr, end;6156 unsigned offset;6262- end = (start + PMD_SIZE - 1) & PMD_MASK;5757+5858+ /*5959+ * Round up the start address. It can start out unaligned as a result6060+ * of stack start randomization.6161+ */6262+ start = PAGE_ALIGN(start);6363+6464+ /* Round the lowest possible end address up to a PMD boundary. */6565+ end = (start + len + PMD_SIZE - 1) & PMD_MASK;6366 if (end >= TASK_SIZE_MAX)6467 end = TASK_SIZE_MAX;6568 end -= len;6666- /* This loses some more bits than a modulo, but is cheaper */6767- offset = get_random_int() & (PTRS_PER_PTE - 1);6868- addr = start + (offset << PAGE_SHIFT);6969- if (addr >= end)7070- addr = end;6969+7070+ if (end > start) {7171+ offset = get_random_int() % (((end - start) >> PAGE_SHIFT) + 1);7272+ addr = start + (offset << PAGE_SHIFT);7373+ } else {7474+ addr = start;7575+ }71767277 /*7373- * page-align it here so that get_unmapped_area doesn't7474- * align it wrongfully again to the next page. addr can come in 4K7575- * unaligned here as a result of stack start randomization.7878+ * Forcibly align the final address in case we have a hardware7979+ * issue that requires alignment for performance reasons.7680 */7777- addr = PAGE_ALIGN(addr);7881 addr = align_vdso_addr(addr);79828083 return addr;
+21-1
arch/x86/xen/enlighten.c
···4040#include <xen/interface/physdev.h>4141#include <xen/interface/vcpu.h>4242#include <xen/interface/memory.h>4343+#include <xen/interface/nmi.h>4344#include <xen/interface/xen-mca.h>4445#include <xen/features.h>4546#include <xen/page.h>···6766#include <asm/reboot.h>6867#include <asm/stackprotector.h>6968#include <asm/hypervisor.h>6969+#include <asm/mach_traps.h>7070#include <asm/mwait.h>7171#include <asm/pci_x86.h>7272#include <asm/pat.h>···13531351 .emergency_restart = xen_emergency_restart,13541352};1355135313541354+static unsigned char xen_get_nmi_reason(void)13551355+{13561356+ unsigned char reason = 0;13571357+13581358+ /* Construct a value which looks like it came from port 0x61. */13591359+ if (test_bit(_XEN_NMIREASON_io_error,13601360+ &HYPERVISOR_shared_info->arch.nmi_reason))13611361+ reason |= NMI_REASON_IOCHK;13621362+ if (test_bit(_XEN_NMIREASON_pci_serr,13631363+ &HYPERVISOR_shared_info->arch.nmi_reason))13641364+ reason |= NMI_REASON_SERR;13651365+13661366+ return reason;13671367+}13681368+13561369static void __init xen_boot_params_init_edd(void)13571370{13581371#if IS_ENABLED(CONFIG_EDD)···15521535 pv_info = xen_info;15531536 pv_init_ops = xen_init_ops;15541537 pv_apic_ops = xen_apic_ops;15551555- if (!xen_pvh_domain())15381538+ if (!xen_pvh_domain()) {15561539 pv_cpu_ops = xen_cpu_ops;15401540+15411541+ x86_platform.get_nmi_reason = xen_get_nmi_reason;15421542+ }1557154315581544 if (xen_feature(XENFEAT_auto_translated_physmap))15591545 x86_init.resources.memory_setup = xen_auto_xlated_memory_setup;
+10-10
arch/x86/xen/p2m.c
···167167 return (void *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);168168}169169170170-/* Only to be called in case of a race for a page just allocated! */171171-static void free_p2m_page(void *p)170170+static void __ref free_p2m_page(void *p)172171{173173- BUG_ON(!slab_is_available());172172+ if (unlikely(!slab_is_available())) {173173+ free_bootmem((unsigned long)p, PAGE_SIZE);174174+ return;175175+ }176176+174177 free_page((unsigned long)p);175178}176179···378375 p2m_missing_pte : p2m_identity_pte;379376 for (i = 0; i < PMDS_PER_MID_PAGE; i++) {380377 pmdp = populate_extra_pmd(381381- (unsigned long)(p2m + pfn + i * PTRS_PER_PTE));378378+ (unsigned long)(p2m + pfn) + i * PMD_SIZE);382379 set_pmd(pmdp, __pmd(__pa(ptep) | _KERNPG_TABLE));383380 }384381 }···439436 * a new pmd is to replace p2m_missing_pte or p2m_identity_pte by a individual440437 * pmd. In case of PAE/x86-32 there are multiple pmds to allocate!441438 */442442-static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg)439439+static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *pte_pg)443440{444441 pte_t *ptechk;445445- pte_t *pteret = ptep;446442 pte_t *pte_newpg[PMDS_PER_MID_PAGE];447443 pmd_t *pmdp;448444 unsigned int level;···475473 if (ptechk == pte_pg) {476474 set_pmd(pmdp,477475 __pmd(__pa(pte_newpg[i]) | _KERNPG_TABLE));478478- if (vaddr == (addr & ~(PMD_SIZE - 1)))479479- pteret = pte_offset_kernel(pmdp, addr);480476 pte_newpg[i] = NULL;481477 }482478···488488 vaddr += PMD_SIZE;489489 }490490491491- return pteret;491491+ return lookup_address(addr, &level);492492}493493494494/*···517517518518 if (pte_pg == p2m_missing_pte || pte_pg == p2m_identity_pte) {519519 /* PMD level is missing, allocate a new one */520520- ptep = alloc_p2m_pmd(addr, ptep, pte_pg);520520+ ptep = alloc_p2m_pmd(addr, pte_pg);521521 if (!ptep)522522 return false;523523 }
+20-22
arch/x86/xen/setup.c
···140140unsigned long __ref xen_chk_extra_mem(unsigned long pfn)141141{142142 int i;143143- unsigned long addr = PFN_PHYS(pfn);143143+ phys_addr_t addr = PFN_PHYS(pfn);144144145145 for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {146146 if (addr >= xen_extra_mem[i].start &&···160160 int i;161161162162 for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {163163+ if (!xen_extra_mem[i].size)164164+ continue;163165 pfn_s = PFN_DOWN(xen_extra_mem[i].start);164166 pfn_e = PFN_UP(xen_extra_mem[i].start + xen_extra_mem[i].size);165167 for (pfn = pfn_s; pfn < pfn_e; pfn++)···231229 * as a fallback if the remapping fails.232230 */233231static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn,234234- unsigned long end_pfn, unsigned long nr_pages, unsigned long *identity,235235- unsigned long *released)232232+ unsigned long end_pfn, unsigned long nr_pages, unsigned long *released)236233{237237- unsigned long len = 0;238234 unsigned long pfn, end;239235 int ret;240236241237 WARN_ON(start_pfn > end_pfn);242238239239+ /* Release pages first. */243240 end = min(end_pfn, nr_pages);244241 for (pfn = start_pfn; pfn < end; pfn++) {245242 unsigned long mfn = pfn_to_mfn(pfn);···251250 WARN(ret != 1, "Failed to release pfn %lx err=%d\n", pfn, ret);252251253252 if (ret == 1) {253253+ (*released)++;254254 if (!__set_phys_to_machine(pfn, INVALID_P2M_ENTRY))255255 break;256256- len++;257256 } else258257 break;259258 }260259261261- /* Need to release pages first */262262- *released += len;263263- *identity += set_phys_range_identity(start_pfn, end_pfn);260260+ set_phys_range_identity(start_pfn, end_pfn);264261}265262266263/*···286287 }287288288289 /* Update kernel mapping, but not for highmem. */289289- if ((pfn << PAGE_SHIFT) >= __pa(high_memory))290290+ if (pfn >= PFN_UP(__pa(high_memory - 1)))290291 return;291292292293 if (HYPERVISOR_update_va_mapping((unsigned long)__va(pfn << PAGE_SHIFT),···317318 unsigned long ident_pfn_iter, remap_pfn_iter;318319 unsigned long ident_end_pfn = start_pfn + size;319320 unsigned long left = size;320320- unsigned long ident_cnt = 0;321321 unsigned int i, chunk;322322323323 WARN_ON(size == 0);···345347 xen_remap_mfn = mfn;346348347349 /* Set identity map */348348- ident_cnt += set_phys_range_identity(ident_pfn_iter,349349- ident_pfn_iter + chunk);350350+ set_phys_range_identity(ident_pfn_iter, ident_pfn_iter + chunk);350351351352 left -= chunk;352353 }···368371static unsigned long __init xen_set_identity_and_remap_chunk(369372 const struct e820entry *list, size_t map_size, unsigned long start_pfn,370373 unsigned long end_pfn, unsigned long nr_pages, unsigned long remap_pfn,371371- unsigned long *identity, unsigned long *released)374374+ unsigned long *released, unsigned long *remapped)372375{373376 unsigned long pfn;374377 unsigned long i = 0;···383386 /* Do not remap pages beyond the current allocation */384387 if (cur_pfn >= nr_pages) {385388 /* Identity map remaining pages */386386- *identity += set_phys_range_identity(cur_pfn,387387- cur_pfn + size);389389+ set_phys_range_identity(cur_pfn, cur_pfn + size);388390 break;389391 }390392 if (cur_pfn + size > nr_pages)···394398 if (!remap_range_size) {395399 pr_warning("Unable to find available pfn range, not remapping identity pages\n");396400 xen_set_identity_and_release_chunk(cur_pfn,397397- cur_pfn + left, nr_pages, identity, released);401401+ cur_pfn + left, nr_pages, released);398402 break;399403 }400404 /* Adjust size to fit in current e820 RAM region */···406410 /* Update variables to reflect new mappings. */407411 i += size;408412 remap_pfn += size;409409- *identity += size;413413+ *remapped += size;410414 }411415412416 /*···423427424428static void __init xen_set_identity_and_remap(425429 const struct e820entry *list, size_t map_size, unsigned long nr_pages,426426- unsigned long *released)430430+ unsigned long *released, unsigned long *remapped)427431{428432 phys_addr_t start = 0;429429- unsigned long identity = 0;430433 unsigned long last_pfn = nr_pages;431434 const struct e820entry *entry;432435 unsigned long num_released = 0;436436+ unsigned long num_remapped = 0;433437 int i;434438435439 /*···456460 last_pfn = xen_set_identity_and_remap_chunk(457461 list, map_size, start_pfn,458462 end_pfn, nr_pages, last_pfn,459459- &identity, &num_released);463463+ &num_released, &num_remapped);460464 start = end;461465 }462466 }463467464468 *released = num_released;469469+ *remapped = num_remapped;465470466466- pr_info("Set %ld page(s) to 1-1 mapping\n", identity);467471 pr_info("Released %ld page(s)\n", num_released);468472}469473···582586 struct xen_memory_map memmap;583587 unsigned long max_pages;584588 unsigned long extra_pages = 0;589589+ unsigned long remapped_pages;585590 int i;586591 int op;587592···632635 * underlying RAM.633636 */634637 xen_set_identity_and_remap(map, memmap.nr_entries, max_pfn,635635- &xen_released_pages);638638+ &xen_released_pages, &remapped_pages);636639637640 extra_pages += xen_released_pages;641641+ extra_pages += remapped_pages;638642639643 /*640644 * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
···473473}474474EXPORT_SYMBOL_GPL(blk_queue_bypass_end);475475476476+void blk_set_queue_dying(struct request_queue *q)477477+{478478+ queue_flag_set_unlocked(QUEUE_FLAG_DYING, q);479479+480480+ if (q->mq_ops)481481+ blk_mq_wake_waiters(q);482482+ else {483483+ struct request_list *rl;484484+485485+ blk_queue_for_each_rl(rl, q) {486486+ if (rl->rq_pool) {487487+ wake_up(&rl->wait[BLK_RW_SYNC]);488488+ wake_up(&rl->wait[BLK_RW_ASYNC]);489489+ }490490+ }491491+ }492492+}493493+EXPORT_SYMBOL_GPL(blk_set_queue_dying);494494+476495/**477496 * blk_cleanup_queue - shutdown a request queue478497 * @q: request queue to shutdown···505486506487 /* mark @q DYING, no new request or merges will be allowed afterwards */507488 mutex_lock(&q->sysfs_lock);508508- queue_flag_set_unlocked(QUEUE_FLAG_DYING, q);489489+ blk_set_queue_dying(q);509490 spin_lock_irq(lock);510491511492 /*
+10-4
block/blk-mq-tag.c
···6868}69697070/*7171- * Wakeup all potentially sleeping on normal (non-reserved) tags7171+ * Wakeup all potentially sleeping on tags7272 */7373-static void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags)7373+void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool include_reserve)7474{7575 struct blk_mq_bitmap_tags *bt;7676 int i, wake_index;···8484 wake_up(&bs->wait);85858686 wake_index = bt_index_inc(wake_index);8787+ }8888+8989+ if (include_reserve) {9090+ bt = &tags->breserved_tags;9191+ if (waitqueue_active(&bt->bs[0].wait))9292+ wake_up(&bt->bs[0].wait);8793 }8894}8995···106100107101 atomic_dec(&tags->active_queues);108102109109- blk_mq_tag_wakeup_all(tags);103103+ blk_mq_tag_wakeup_all(tags, false);110104}111105112106/*···590584 * static and should never need resizing.591585 */592586 bt_update_count(&tags->bitmap_tags, tdepth);593593- blk_mq_tag_wakeup_all(tags);587587+ blk_mq_tag_wakeup_all(tags, false);594588 return 0;595589}596590
+1
block/blk-mq-tag.h
···5454extern ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page);5555extern void blk_mq_tag_init_last_tag(struct blk_mq_tags *tags, unsigned int *last_tag);5656extern int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int depth);5757+extern void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool);57585859enum {5960 BLK_MQ_TAG_CACHE_MIN = 1,
+69-6
block/blk-mq.c
···107107 wake_up_all(&q->mq_freeze_wq);108108}109109110110-static void blk_mq_freeze_queue_start(struct request_queue *q)110110+void blk_mq_freeze_queue_start(struct request_queue *q)111111{112112 bool freeze;113113···120120 blk_mq_run_queues(q, false);121121 }122122}123123+EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_start);123124124125static void blk_mq_freeze_queue_wait(struct request_queue *q)125126{···137136 blk_mq_freeze_queue_wait(q);138137}139138140140-static void blk_mq_unfreeze_queue(struct request_queue *q)139139+void blk_mq_unfreeze_queue(struct request_queue *q)141140{142141 bool wake;143142···149148 percpu_ref_reinit(&q->mq_usage_counter);150149 wake_up_all(&q->mq_freeze_wq);151150 }151151+}152152+EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);153153+154154+void blk_mq_wake_waiters(struct request_queue *q)155155+{156156+ struct blk_mq_hw_ctx *hctx;157157+ unsigned int i;158158+159159+ queue_for_each_hw_ctx(q, hctx, i)160160+ if (blk_mq_hw_queue_mapped(hctx))161161+ blk_mq_tag_wakeup_all(hctx->tags, true);162162+163163+ /*164164+ * If we are called because the queue has now been marked as165165+ * dying, we need to ensure that processes currently waiting on166166+ * the queue are notified as well.167167+ */168168+ wake_up_all(&q->mq_freeze_wq);152169}153170154171bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx)···277258 ctx = alloc_data.ctx;278259 }279260 blk_mq_put_ctx(ctx);280280- if (!rq)261261+ if (!rq) {262262+ blk_mq_queue_exit(q);281263 return ERR_PTR(-EWOULDBLOCK);264264+ }282265 return rq;283266}284267EXPORT_SYMBOL(blk_mq_alloc_request);···404383}405384EXPORT_SYMBOL(blk_mq_complete_request);406385386386+int blk_mq_request_started(struct request *rq)387387+{388388+ return test_bit(REQ_ATOM_STARTED, &rq->atomic_flags);389389+}390390+EXPORT_SYMBOL_GPL(blk_mq_request_started);391391+407392void blk_mq_start_request(struct request *rq)408393{409394 struct request_queue *q = rq->q;···527500}528501EXPORT_SYMBOL(blk_mq_add_to_requeue_list);529502503503+void blk_mq_cancel_requeue_work(struct request_queue *q)504504+{505505+ cancel_work_sync(&q->requeue_work);506506+}507507+EXPORT_SYMBOL_GPL(blk_mq_cancel_requeue_work);508508+530509void blk_mq_kick_requeue_list(struct request_queue *q)531510{532511 kblockd_schedule_work(&q->requeue_work);533512}534513EXPORT_SYMBOL(blk_mq_kick_requeue_list);514514+515515+void blk_mq_abort_requeue_list(struct request_queue *q)516516+{517517+ unsigned long flags;518518+ LIST_HEAD(rq_list);519519+520520+ spin_lock_irqsave(&q->requeue_lock, flags);521521+ list_splice_init(&q->requeue_list, &rq_list);522522+ spin_unlock_irqrestore(&q->requeue_lock, flags);523523+524524+ while (!list_empty(&rq_list)) {525525+ struct request *rq;526526+527527+ rq = list_first_entry(&rq_list, struct request, queuelist);528528+ list_del_init(&rq->queuelist);529529+ rq->errors = -EIO;530530+ blk_mq_end_request(rq, rq->errors);531531+ }532532+}533533+EXPORT_SYMBOL(blk_mq_abort_requeue_list);535534536535static inline bool is_flush_request(struct request *rq,537536 struct blk_flush_queue *fq, unsigned int tag)···619566 break;620567 }621568}622622-569569+623570static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,624571 struct request *rq, void *priv, bool reserved)625572{626573 struct blk_mq_timeout_data *data = priv;627574628628- if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags))575575+ if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags)) {576576+ /*577577+ * If a request wasn't started before the queue was578578+ * marked dying, kill it here or it'll go unnoticed.579579+ */580580+ if (unlikely(blk_queue_dying(rq->q))) {581581+ rq->errors = -EIO;582582+ blk_mq_complete_request(rq);583583+ }584584+ return;585585+ }586586+ if (rq->cmd_flags & REQ_NO_TIMEOUT)629587 return;630588631589 if (time_after_eq(jiffies, rq->deadline)) {···16651601 hctx->queue = q;16661602 hctx->queue_num = hctx_idx;16671603 hctx->flags = set->flags;16681668- hctx->cmd_size = set->cmd_size;1669160416701605 blk_mq_init_cpu_notifier(&hctx->cpu_notifier,16711606 blk_mq_hctx_notify, hctx);
+1
block/blk-mq.h
···3232void blk_mq_clone_flush_request(struct request *flush_rq,3333 struct request *orig_rq);3434int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr);3535+void blk_mq_wake_waiters(struct request_queue *q);35363637/*3738 * CPU hotplug helpers
+3
block/blk-timeout.c
···190190 struct request_queue *q = req->q;191191 unsigned long expiry;192192193193+ if (req->cmd_flags & REQ_NO_TIMEOUT)194194+ return;195195+193196 /* blk-mq has its own handler, so we don't need ->rq_timed_out_fn */194197 if (!q->mq_ops && !q->rq_timed_out_fn)195198 return;
+4-2
drivers/Makefile
···5050obj-y += tty/5151obj-y += char/52525353-# gpu/ comes after char for AGP vs DRM startup5353+# iommu/ comes before gpu as gpu are using iommu controllers5454+obj-$(CONFIG_IOMMU_SUPPORT) += iommu/5555+5656+# gpu/ comes after char for AGP vs DRM startup and after iommu5457obj-y += gpu/55585659obj-$(CONFIG_CONNECTOR) += connector/···144141145142obj-$(CONFIG_MAILBOX) += mailbox/146143obj-$(CONFIG_HWSPINLOCK) += hwspinlock/147147-obj-$(CONFIG_IOMMU_SUPPORT) += iommu/148144obj-$(CONFIG_REMOTEPROC) += remoteproc/149145obj-$(CONFIG_RPMSG) += rpmsg/150146
+14-11
drivers/acpi/acpi_processor.c
···170170 acpi_status status;171171 int ret;172172173173- if (pr->apic_id == -1)173173+ if (pr->phys_id == -1)174174 return -ENODEV;175175176176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);···180180 cpu_maps_update_begin();181181 cpu_hotplug_begin();182182183183- ret = acpi_map_lsapic(pr->handle, pr->apic_id, &pr->id);183183+ ret = acpi_map_cpu(pr->handle, pr->phys_id, &pr->id);184184 if (ret)185185 goto out;186186187187 ret = arch_register_cpu(pr->id);188188 if (ret) {189189- acpi_unmap_lsapic(pr->id);189189+ acpi_unmap_cpu(pr->id);190190 goto out;191191 }192192···215215 union acpi_object object = { 0 };216216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };217217 struct acpi_processor *pr = acpi_driver_data(device);218218- int apic_id, cpu_index, device_declaration = 0;218218+ int phys_id, cpu_index, device_declaration = 0;219219 acpi_status status = AE_OK;220220 static int cpu0_initialized;221221 unsigned long long value;···262262 pr->acpi_id = value;263263 }264264265265- apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);266266- if (apic_id < 0)267267- acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");268268- pr->apic_id = apic_id;265265+ phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);266266+ if (phys_id < 0)267267+ acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");268268+ pr->phys_id = phys_id;269269270270- cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);270270+ cpu_index = acpi_map_cpuid(pr->phys_id, pr->acpi_id);271271 if (!cpu0_initialized && !acpi_has_cpu_in_madt()) {272272 cpu0_initialized = 1;273273- /* Handle UP system running SMP kernel, with no LAPIC in MADT */273273+ /*274274+ * Handle UP system running SMP kernel, with no CPU275275+ * entry in MADT276276+ */274277 if ((cpu_index == -1) && (num_online_cpus() == 1))275278 cpu_index = 0;276279 }···461458462459 /* Remove the CPU. */463460 arch_unregister_cpu(pr->id);464464- acpi_unmap_lsapic(pr->id);461461+ acpi_unmap_cpu(pr->id);465462466463 cpu_hotplug_done();467464 cpu_maps_update_done();
+1-1
drivers/acpi/device_pm.c
···257257258258 device->power.state = ACPI_STATE_UNKNOWN;259259 if (!acpi_device_is_present(device))260260- return 0;260260+ return -ENXIO;261261262262 result = acpi_device_get_power(device, &state);263263 if (result)
···463463 bool is_32bit_user_mode;464464};465465466466+/**467467+ * Ioctl function type.468468+ *469469+ * \param filep pointer to file structure.470470+ * \param p amdkfd process pointer.471471+ * \param data pointer to arg that was copied from user.472472+ */473473+typedef int amdkfd_ioctl_t(struct file *filep, struct kfd_process *p,474474+ void *data);475475+476476+struct amdkfd_ioctl_desc {477477+ unsigned int cmd;478478+ int flags;479479+ amdkfd_ioctl_t *func;480480+ unsigned int cmd_drv;481481+ const char *name;482482+};483483+466484void kfd_process_create_wq(void);467485void kfd_process_destroy_wq(void);468486struct kfd_process *kfd_create_process(const struct task_struct *);
+1-1
drivers/gpu/drm/amd/amdkfd/kfd_topology.c
···921921 uint32_t i = 0;922922923923 list_for_each_entry(dev, &topology_device_list, list) {924924- ret = kfd_build_sysfs_node_entry(dev, 0);924924+ ret = kfd_build_sysfs_node_entry(dev, i);925925 if (ret < 0)926926 return ret;927927 i++;
···37253725 if ((iir & flip_pending) == 0)37263726 goto check_page_flip;3727372737283728- intel_prepare_page_flip(dev, plane);37293729-37303728 /* We detect FlipDone by looking for the change in PendingFlip from '1'37313729 * to '0' on the following vblank, i.e. IIR has the Pendingflip37323730 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence···37343736 if (I915_READ16(ISR) & flip_pending)37353737 goto check_page_flip;3736373837393739+ intel_prepare_page_flip(dev, plane);37373740 intel_finish_page_flip(dev, pipe);37383741 return true;37393742···39063907 if ((iir & flip_pending) == 0)39073908 goto check_page_flip;3908390939093909- intel_prepare_page_flip(dev, plane);39103910-39113910 /* We detect FlipDone by looking for the change in PendingFlip from '1'39123911 * to '0' on the following vblank, i.e. IIR has the Pendingflip39133912 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence···39153918 if (I915_READ(ISR) & flip_pending)39163919 goto check_page_flip;3917392039213921+ intel_prepare_page_flip(dev, plane);39183922 intel_finish_page_flip(dev, pipe);39193923 return true;39203924
+1-7
drivers/gpu/drm/i915/intel_display.c
···1305713057 vga_put(dev->pdev, VGA_RSRC_LEGACY_IO);1305813058 udelay(300);13059130591306013060- /*1306113061- * Fujitsu-Siemens Lifebook S6010 (830) has problems resuming1306213062- * from S3 without preserving (some of?) the other bits.1306313063- */1306413064- I915_WRITE(vga_reg, dev_priv->bios_vgacntr | VGA_DISP_DISABLE);1306013060+ I915_WRITE(vga_reg, VGA_DISP_DISABLE);1306513061 POSTING_READ(vga_reg);1306613062}1306713063···13142131461314313147 intel_shared_dpll_init(dev);13144131481314513145- /* save the BIOS value before clobbering it */1314613146- dev_priv->bios_vgacntr = I915_READ(i915_vgacntrl_reg(dev));1314713149 /* Just disable it once at startup */1314813150 i915_disable_vga(dev);1314913151 intel_setup_outputs(dev);
···15721572 * so use the DMA API for them.15731573 */15741574 if (!nv_device_is_cpu_coherent(device) &&15751575- ttm->caching_state == tt_uncached)15751575+ ttm->caching_state == tt_uncached) {15761576 ttm_dma_unpopulate(ttm_dma, dev->dev);15771577+ return;15781578+ }1577157915781580#if __OS_HAS_AGP15791581 if (drm->agp.stat == ENABLED) {
+31-6
drivers/gpu/drm/nouveau/nouveau_gem.c
···3636nouveau_gem_object_del(struct drm_gem_object *gem)3737{3838 struct nouveau_bo *nvbo = nouveau_gem_object(gem);3939+ struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);3940 struct ttm_buffer_object *bo = &nvbo->bo;4141+ struct device *dev = drm->dev->dev;4242+ int ret;4343+4444+ ret = pm_runtime_get_sync(dev);4545+ if (WARN_ON(ret < 0 && ret != -EACCES))4646+ return;40474148 if (gem->import_attach)4249 drm_prime_gem_destroy(gem, nvbo->bo.sg);···5346 /* reset filp so nouveau_bo_del_ttm() can test for it */5447 gem->filp = NULL;5548 ttm_bo_unref(&bo);4949+5050+ pm_runtime_mark_last_busy(dev);5151+ pm_runtime_put_autosuspend(dev);5652}57535854int···6353{6454 struct nouveau_cli *cli = nouveau_cli(file_priv);6555 struct nouveau_bo *nvbo = nouveau_gem_object(gem);5656+ struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);6657 struct nouveau_vma *vma;5858+ struct device *dev = drm->dev->dev;6759 int ret;68606961 if (!cli->vm)···8371 goto out;8472 }85738686- ret = nouveau_bo_vma_add(nvbo, cli->vm, vma);8787- if (ret) {8888- kfree(vma);7474+ ret = pm_runtime_get_sync(dev);7575+ if (ret < 0 && ret != -EACCES)8976 goto out;9090- }7777+7878+ ret = nouveau_bo_vma_add(nvbo, cli->vm, vma);7979+ if (ret)8080+ kfree(vma);8181+8282+ pm_runtime_mark_last_busy(dev);8383+ pm_runtime_put_autosuspend(dev);9184 } else {9285 vma->refcount++;9386 }···146129{147130 struct nouveau_cli *cli = nouveau_cli(file_priv);148131 struct nouveau_bo *nvbo = nouveau_gem_object(gem);132132+ struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);133133+ struct device *dev = drm->dev->dev;149134 struct nouveau_vma *vma;150135 int ret;151136···160141161142 vma = nouveau_bo_vma_find(nvbo, cli->vm);162143 if (vma) {163163- if (--vma->refcount == 0)164164- nouveau_gem_object_unmap(nvbo, vma);144144+ if (--vma->refcount == 0) {145145+ ret = pm_runtime_get_sync(dev);146146+ if (!WARN_ON(ret < 0 && ret != -EACCES)) {147147+ nouveau_gem_object_unmap(nvbo, vma);148148+ pm_runtime_mark_last_busy(dev);149149+ pm_runtime_put_autosuspend(dev);150150+ }151151+ }165152 }166153 ttm_bo_unreserve(&nvbo->bo);167154}
+4-4
drivers/gpu/drm/radeon/atombios_crtc.c
···18511851 return pll;18521852 }18531853 /* otherwise, pick one of the plls */18541854- if ((rdev->family == CHIP_KAVERI) ||18551855- (rdev->family == CHIP_KABINI) ||18541854+ if ((rdev->family == CHIP_KABINI) ||18561855 (rdev->family == CHIP_MULLINS)) {18571857- /* KB/KV/ML has PPLL1 and PPLL2 */18561856+ /* KB/ML has PPLL1 and PPLL2 */18581857 pll_in_use = radeon_get_pll_use_mask(crtc);18591858 if (!(pll_in_use & (1 << ATOM_PPLL2)))18601859 return ATOM_PPLL2;···18621863 DRM_ERROR("unable to allocate a PPLL\n");18631864 return ATOM_PPLL_INVALID;18641865 } else {18651865- /* CI has PPLL0, PPLL1, and PPLL2 */18661866+ /* CI/KV has PPLL0, PPLL1, and PPLL2 */18661867 pll_in_use = radeon_get_pll_use_mask(crtc);18671868 if (!(pll_in_use & (1 << ATOM_PPLL2)))18681869 return ATOM_PPLL2;···21542155 case ATOM_PPLL0:21552156 /* disable the ppll */21562157 if ((rdev->family == CHIP_ARUBA) ||21582158+ (rdev->family == CHIP_KAVERI) ||21572159 (rdev->family == CHIP_BONAIRE) ||21582160 (rdev->family == CHIP_HAWAII))21592161 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
+4
drivers/gpu/drm/radeon/atombios_dp.c
···492492 struct radeon_connector_atom_dig *dig_connector;493493 int dp_clock;494494495495+ if ((mode->clock > 340000) &&496496+ (!radeon_connector_is_dp12_capable(connector)))497497+ return MODE_CLOCK_HIGH;498498+495499 if (!radeon_connector->con_priv)496500 return MODE_CLOCK_HIGH;497501 dig_connector = radeon_connector->con_priv;
···40294029 if (action != BUS_NOTIFY_REMOVED_DEVICE)40304030 return 0;4031403140324032- /*40334033- * If the device is still attached to a device driver we can't40344034- * tear down the domain yet as DMA mappings may still be in use.40354035- * Wait for the BUS_NOTIFY_UNBOUND_DRIVER event to do that.40364036- */40374037- if (action == BUS_NOTIFY_DEL_DEVICE && dev->driver != NULL)40384038- return 0;40394039-40404032 domain = find_domain(dev);40414033 if (!domain)40424034 return 0;···44204428 domain_remove_one_dev_info(old_domain, dev);44214429 else44224430 domain_remove_dev_info(old_domain);44314431+44324432+ if (!domain_type_is_vm_or_si(old_domain) &&44334433+ list_empty(&old_domain->devices))44344434+ domain_exit(old_domain);44234435 }44244436 }44254437
+3-3
drivers/iommu/ipmmu-vmsa.c
···558558559559static u64 ipmmu_page_prot(unsigned int prot, u64 type)560560{561561- u64 pgprot = ARM_VMSA_PTE_XN | ARM_VMSA_PTE_nG | ARM_VMSA_PTE_AF561561+ u64 pgprot = ARM_VMSA_PTE_nG | ARM_VMSA_PTE_AF562562 | ARM_VMSA_PTE_SH_IS | ARM_VMSA_PTE_AP_UNPRIV563563 | ARM_VMSA_PTE_NS | type;564564···568568 if (prot & IOMMU_CACHE)569569 pgprot |= IMMAIR_ATTR_IDX_WBRWA << ARM_VMSA_PTE_ATTRINDX_SHIFT;570570571571- if (prot & IOMMU_EXEC)572572- pgprot &= ~ARM_VMSA_PTE_XN;571571+ if (prot & IOMMU_NOEXEC)572572+ pgprot |= ARM_VMSA_PTE_XN;573573 else if (!(prot & (IOMMU_READ | IOMMU_WRITE)))574574 /* If no access create a faulting entry to avoid TLB fills. */575575 pgprot &= ~ARM_VMSA_PTE_PAGE;
···330330 led_dat->sata = 0;331331 led_dat->cdev.brightness = LED_OFF;332332 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;333333- /*334334- * If available, expose the SATA activity blink capability through335335- * a "sata" sysfs attribute.336336- */337337- if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE)338338- led_dat->cdev.groups = netxbig_led_groups;339333 led_dat->mode_addr = template->mode_addr;340334 led_dat->mode_val = template->mode_val;341335 led_dat->bright_addr = template->bright_addr;342336 led_dat->bright_max = (1 << pdata->gpio_ext->num_data) - 1;343337 led_dat->timer = pdata->timer;344338 led_dat->num_timer = pdata->num_timer;339339+ /*340340+ * If available, expose the SATA activity blink capability through341341+ * a "sata" sysfs attribute.342342+ */343343+ if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE)344344+ led_dat->cdev.groups = netxbig_led_groups;345345346346 return led_classdev_register(&pdev->dev, &led_dat->cdev);347347}
+63-19
drivers/misc/cxl/context.c
···100100 return 0;101101}102102103103+static int cxl_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)104104+{105105+ struct cxl_context *ctx = vma->vm_file->private_data;106106+ unsigned long address = (unsigned long)vmf->virtual_address;107107+ u64 area, offset;108108+109109+ offset = vmf->pgoff << PAGE_SHIFT;110110+111111+ pr_devel("%s: pe: %i address: 0x%lx offset: 0x%llx\n",112112+ __func__, ctx->pe, address, offset);113113+114114+ if (ctx->afu->current_mode == CXL_MODE_DEDICATED) {115115+ area = ctx->afu->psn_phys;116116+ if (offset > ctx->afu->adapter->ps_size)117117+ return VM_FAULT_SIGBUS;118118+ } else {119119+ area = ctx->psn_phys;120120+ if (offset > ctx->psn_size)121121+ return VM_FAULT_SIGBUS;122122+ }123123+124124+ mutex_lock(&ctx->status_mutex);125125+126126+ if (ctx->status != STARTED) {127127+ mutex_unlock(&ctx->status_mutex);128128+ pr_devel("%s: Context not started, failing problem state access\n", __func__);129129+ return VM_FAULT_SIGBUS;130130+ }131131+132132+ vm_insert_pfn(vma, address, (area + offset) >> PAGE_SHIFT);133133+134134+ mutex_unlock(&ctx->status_mutex);135135+136136+ return VM_FAULT_NOPAGE;137137+}138138+139139+static const struct vm_operations_struct cxl_mmap_vmops = {140140+ .fault = cxl_mmap_fault,141141+};142142+103143/*104144 * Map a per-context mmio space into the given vma.105145 */···148108 u64 len = vma->vm_end - vma->vm_start;149109 len = min(len, ctx->psn_size);150110151151- if (ctx->afu->current_mode == CXL_MODE_DEDICATED) {152152- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);153153- return vm_iomap_memory(vma, ctx->afu->psn_phys, ctx->afu->adapter->ps_size);154154- }111111+ if (ctx->afu->current_mode != CXL_MODE_DEDICATED) {112112+ /* make sure there is a valid per process space for this AFU */113113+ if ((ctx->master && !ctx->afu->psa) || (!ctx->afu->pp_psa)) {114114+ pr_devel("AFU doesn't support mmio space\n");115115+ return -EINVAL;116116+ }155117156156- /* make sure there is a valid per process space for this AFU */157157- if ((ctx->master && !ctx->afu->psa) || (!ctx->afu->pp_psa)) {158158- pr_devel("AFU doesn't support mmio space\n");159159- return -EINVAL;118118+ /* Can't mmap until the AFU is enabled */119119+ if (!ctx->afu->enabled)120120+ return -EBUSY;160121 }161161-162162- /* Can't mmap until the AFU is enabled */163163- if (!ctx->afu->enabled)164164- return -EBUSY;165122166123 pr_devel("%s: mmio physical: %llx pe: %i master:%i\n", __func__,167124 ctx->psn_phys, ctx->pe , ctx->master);168125126126+ vma->vm_flags |= VM_IO | VM_PFNMAP;169127 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);170170- return vm_iomap_memory(vma, ctx->psn_phys, len);128128+ vma->vm_ops = &cxl_mmap_vmops;129129+ return 0;171130}172131173132/*···189150 afu_release_irqs(ctx);190151 flush_work(&ctx->fault_work); /* Only needed for dedicated process */191152 wake_up_all(&ctx->wq);192192-193193- /* Release Problem State Area mapping */194194- mutex_lock(&ctx->mapping_lock);195195- if (ctx->mapping)196196- unmap_mapping_range(ctx->mapping, 0, 0, 1);197197- mutex_unlock(&ctx->mapping_lock);198153}199154200155/*···217184 * created and torn down after the IDR removed218185 */219186 __detach_context(ctx);187187+188188+ /*189189+ * We are force detaching - remove any active PSA mappings so190190+ * userspace cannot interfere with the card if it comes back.191191+ * Easiest way to exercise this is to unbind and rebind the192192+ * driver via sysfs while it is in use.193193+ */194194+ mutex_lock(&ctx->mapping_lock);195195+ if (ctx->mapping)196196+ unmap_mapping_range(ctx->mapping, 0, 0, 1);197197+ mutex_unlock(&ctx->mapping_lock);220198 }221199 mutex_unlock(&afu->contexts_lock);222200}
+8-6
drivers/misc/cxl/file.c
···140140141141 pr_devel("%s: pe: %i\n", __func__, ctx->pe);142142143143- mutex_lock(&ctx->status_mutex);144144- if (ctx->status != OPENED) {145145- rc = -EIO;146146- goto out;147147- }148148-143143+ /* Do this outside the status_mutex to avoid a circular dependency with144144+ * the locking in cxl_mmap_fault() */149145 if (copy_from_user(&work, uwork,150146 sizeof(struct cxl_ioctl_start_work))) {151147 rc = -EFAULT;148148+ goto out;149149+ }150150+151151+ mutex_lock(&ctx->status_mutex);152152+ if (ctx->status != OPENED) {153153+ rc = -EIO;152154 goto out;153155 }154156
···300300 if (IS_ERR(host))301301 return PTR_ERR(host);302302303303- if (of_device_is_compatible(np, "marvell,armada-380-sdhci")) {304304- ret = mv_conf_mbus_windows(pdev, mv_mbus_dram_info());305305- if (ret < 0)306306- goto err_mbus_win;307307- }308308-309309-310303 pltfm_host = sdhci_priv(host);311304 pltfm_host->priv = pxa;312305···317324 pxa->clk_core = devm_clk_get(dev, "core");318325 if (!IS_ERR(pxa->clk_core))319326 clk_prepare_enable(pxa->clk_core);327327+328328+ if (of_device_is_compatible(np, "marvell,armada-380-sdhci")) {329329+ ret = mv_conf_mbus_windows(pdev, mv_mbus_dram_info());330330+ if (ret < 0)331331+ goto err_mbus_win;332332+ }320333321334 /* enable 1/8V DDR capable */322335 host->mmc->caps |= MMC_CAP_1_8V_DDR;···395396 pm_runtime_disable(&pdev->dev);396397err_of_parse:397398err_cd_req:399399+err_mbus_win:398400 clk_disable_unprepare(pxa->clk_io);399401 if (!IS_ERR(pxa->clk_core))400402 clk_disable_unprepare(pxa->clk_core);401403err_clk_get:402402-err_mbus_win:403404 sdhci_pltfm_free(pdev);404405 return ret;405406}
+54-26
drivers/mmc/host/sdhci.c
···259259260260 del_timer_sync(&host->tuning_timer);261261 host->flags &= ~SDHCI_NEEDS_RETUNING;262262- host->mmc->max_blk_count =263263- (host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535;264262 }265263 sdhci_enable_card_detection(host);266264}···12711273 spin_unlock_irq(&host->lock);12721274 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);12731275 spin_lock_irq(&host->lock);12761276+12771277+ if (mode != MMC_POWER_OFF)12781278+ sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);12791279+ else12801280+ sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);12811281+12741282 return;12751283 }12761284···1357135313581354 sdhci_runtime_pm_get(host);1359135513561356+ present = mmc_gpio_get_cd(host->mmc);13571357+13601358 spin_lock_irqsave(&host->lock, flags);1361135913621360 WARN_ON(host->mrq != NULL);···13871381 * zero: cd-gpio is used, and card is removed13881382 * one: cd-gpio is used, and card is present13891383 */13901390- present = mmc_gpio_get_cd(host->mmc);13911384 if (present < 0) {13921385 /* If polling, assume that the card is always present. */13931386 if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)···18851880 return !(present_state & SDHCI_DATA_LVL_MASK);18861881}1887188218831883+static int sdhci_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)18841884+{18851885+ struct sdhci_host *host = mmc_priv(mmc);18861886+ unsigned long flags;18871887+18881888+ spin_lock_irqsave(&host->lock, flags);18891889+ host->flags |= SDHCI_HS400_TUNING;18901890+ spin_unlock_irqrestore(&host->lock, flags);18911891+18921892+ return 0;18931893+}18941894+18881895static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)18891896{18901897 struct sdhci_host *host = mmc_priv(mmc);···19041887 int tuning_loop_counter = MAX_TUNING_LOOP;19051888 int err = 0;19061889 unsigned long flags;18901890+ unsigned int tuning_count = 0;18911891+ bool hs400_tuning;1907189219081893 sdhci_runtime_pm_get(host);19091894 spin_lock_irqsave(&host->lock, flags);18951895+18961896+ hs400_tuning = host->flags & SDHCI_HS400_TUNING;18971897+ host->flags &= ~SDHCI_HS400_TUNING;18981898+18991899+ if (host->tuning_mode == SDHCI_TUNING_MODE_1)19001900+ tuning_count = host->tuning_count;1910190119111902 /*19121903 * The Host Controller needs tuning only in case of SDR104 mode···19241899 * tuning function has to be executed.19251900 */19261901 switch (host->timing) {19021902+ /* HS400 tuning is done in HS200 mode */19271903 case MMC_TIMING_MMC_HS400:19041904+ err = -EINVAL;19051905+ goto out_unlock;19061906+19281907 case MMC_TIMING_MMC_HS200:19081908+ /*19091909+ * Periodic re-tuning for HS400 is not expected to be needed, so19101910+ * disable it here.19111911+ */19121912+ if (hs400_tuning)19131913+ tuning_count = 0;19141914+ break;19151915+19291916 case MMC_TIMING_UHS_SDR104:19301917 break;19311918···19481911 /* FALLTHROUGH */1949191219501913 default:19511951- spin_unlock_irqrestore(&host->lock, flags);19521952- sdhci_runtime_pm_put(host);19531953- return 0;19141914+ goto out_unlock;19541915 }1955191619561917 if (host->ops->platform_execute_tuning) {···20722037 }2073203820742039out:20752075- /*20762076- * If this is the very first time we are here, we start the retuning20772077- * timer. Since only during the first time, SDHCI_NEEDS_RETUNING20782078- * flag won't be set, we check this condition before actually starting20792079- * the timer.20802080- */20812081- if (!(host->flags & SDHCI_NEEDS_RETUNING) && host->tuning_count &&20822082- (host->tuning_mode == SDHCI_TUNING_MODE_1)) {20402040+ host->flags &= ~SDHCI_NEEDS_RETUNING;20412041+20422042+ if (tuning_count) {20832043 host->flags |= SDHCI_USING_RETUNING_TIMER;20842084- mod_timer(&host->tuning_timer, jiffies +20852085- host->tuning_count * HZ);20862086- /* Tuning mode 1 limits the maximum data length to 4MB */20872087- mmc->max_blk_count = (4 * 1024 * 1024) / mmc->max_blk_size;20882088- } else if (host->flags & SDHCI_USING_RETUNING_TIMER) {20892089- host->flags &= ~SDHCI_NEEDS_RETUNING;20902090- /* Reload the new initial value for timer */20912091- mod_timer(&host->tuning_timer, jiffies +20922092- host->tuning_count * HZ);20442044+ mod_timer(&host->tuning_timer, jiffies + tuning_count * HZ);20932045 }2094204620952047 /*···2092207020932071 sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);20942072 sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);20732073+out_unlock:20952074 spin_unlock_irqrestore(&host->lock, flags);20962075 sdhci_runtime_pm_put(host);20972076···21332110{21342111 struct sdhci_host *host = mmc_priv(mmc);21352112 unsigned long flags;21132113+ int present;2136211421372115 /* First check if client has provided their own card event */21382116 if (host->ops->card_event)21392117 host->ops->card_event(host);2140211821192119+ present = sdhci_do_get_cd(host);21202120+21412121 spin_lock_irqsave(&host->lock, flags);2142212221432123 /* Check host->mrq first in case we are runtime suspended */21442144- if (host->mrq && !sdhci_do_get_cd(host)) {21242124+ if (host->mrq && !present) {21452125 pr_err("%s: Card removed during transfer!\n",21462126 mmc_hostname(host->mmc));21472127 pr_err("%s: Resetting controller.\n",···21682142 .hw_reset = sdhci_hw_reset,21692143 .enable_sdio_irq = sdhci_enable_sdio_irq,21702144 .start_signal_voltage_switch = sdhci_start_signal_voltage_switch,21452145+ .prepare_hs400_tuning = sdhci_prepare_hs400_tuning,21712146 .execute_tuning = sdhci_execute_tuning,21722147 .card_event = sdhci_card_event,21732148 .card_busy = sdhci_card_busy,···32873260 mmc->max_segs = SDHCI_MAX_SEGS;3288326132893262 /*32903290- * Maximum number of sectors in one transfer. Limited by DMA boundary32913291- * size (512KiB).32633263+ * Maximum number of sectors in one transfer. Limited by SDMA boundary32643264+ * size (512KiB). Note some tuning modes impose a 4MiB limit, but this32653265+ * is less anyway.32923266 */32933267 mmc->max_req_size = 524288;32943268
+3-1
drivers/net/ethernet/allwinner/sun4i-emac.c
···850850 }851851852852 db->clk = devm_clk_get(&pdev->dev, NULL);853853- if (IS_ERR(db->clk))853853+ if (IS_ERR(db->clk)) {854854+ ret = PTR_ERR(db->clk);854855 goto out;856856+ }855857856858 clk_prepare_enable(db->clk);857859
+6-9
drivers/net/ethernet/altera/altera_tse_main.c
···11701170init_error:11711171 free_skbufs(dev);11721172alloc_skbuf_error:11731173- if (priv->phydev) {11741174- phy_disconnect(priv->phydev);11751175- priv->phydev = NULL;11761176- }11771173phy_error:11781174 return ret;11791175}···11821186 int ret;11831187 unsigned long int flags;1184118811851185- /* Stop and disconnect the PHY */11861186- if (priv->phydev) {11891189+ /* Stop the PHY */11901190+ if (priv->phydev)11871191 phy_stop(priv->phydev);11881188- phy_disconnect(priv->phydev);11891189- priv->phydev = NULL;11901190- }1191119211921193 netif_stop_queue(dev);11931194 napi_disable(&priv->napi);···15181525static int altera_tse_remove(struct platform_device *pdev)15191526{15201527 struct net_device *ndev = platform_get_drvdata(pdev);15281528+ struct altera_tse_private *priv = netdev_priv(ndev);15291529+15301530+ if (priv->phydev)15311531+ phy_disconnect(priv->phydev);1521153215221533 platform_set_drvdata(pdev, NULL);15231534 altera_tse_mdio_destroy(ndev);
+13-11
drivers/net/ethernet/atheros/alx/main.c
···184184 schedule_work(&alx->reset_wk);185185}186186187187-static bool alx_clean_rx_irq(struct alx_priv *alx, int budget)187187+static int alx_clean_rx_irq(struct alx_priv *alx, int budget)188188{189189 struct alx_rx_queue *rxq = &alx->rxq;190190 struct alx_rrd *rrd;191191 struct alx_buffer *rxb;192192 struct sk_buff *skb;193193 u16 length, rfd_cleaned = 0;194194+ int work = 0;194195195195- while (budget > 0) {196196+ while (work < budget) {196197 rrd = &rxq->rrd[rxq->rrd_read_idx];197198 if (!(rrd->word3 & cpu_to_le32(1 << RRD_UPDATED_SHIFT)))198199 break;···204203 ALX_GET_FIELD(le32_to_cpu(rrd->word0),205204 RRD_NOR) != 1) {206205 alx_schedule_reset(alx);207207- return 0;206206+ return work;208207 }209208210209 rxb = &rxq->bufs[rxq->read_idx];···244243 }245244246245 napi_gro_receive(&alx->napi, skb);247247- budget--;246246+ work++;248247249248next_pkt:250249 if (++rxq->read_idx == alx->rx_ringsz)···259258 if (rfd_cleaned)260259 alx_refill_rx_ring(alx, GFP_ATOMIC);261260262262- return budget > 0;261261+ return work;263262}264263265264static int alx_poll(struct napi_struct *napi, int budget)266265{267266 struct alx_priv *alx = container_of(napi, struct alx_priv, napi);268267 struct alx_hw *hw = &alx->hw;269269- bool complete = true;270268 unsigned long flags;269269+ bool tx_complete;270270+ int work;271271272272- complete = alx_clean_tx_irq(alx) &&273273- alx_clean_rx_irq(alx, budget);272272+ tx_complete = alx_clean_tx_irq(alx);273273+ work = alx_clean_rx_irq(alx, budget);274274275275- if (!complete)276276- return 1;275275+ if (!tx_complete || work == budget)276276+ return budget;277277278278 napi_complete(&alx->napi);279279···286284287285 alx_post_write(hw);288286289289- return 0;287287+ return work;290288}291289292290static irqreturn_t alx_intr_handle(struct alx_priv *alx, u32 intr)
···24302430 */24312431 n10g = 0;24322432 for_each_port(adapter, pidx)24332433- n10g += is_10g_port(&adap2pinfo(adapter, pidx)->link_cfg);24332433+ n10g += is_x_10g_port(&adap2pinfo(adapter, pidx)->link_cfg);2434243424352435 /*24362436 * We default to 1 queue per non-10G port and up to # of cores queues
···16161616 if (vnic_rq_desc_used(&enic->rq[i]) == 0) {16171617 netdev_err(netdev, "Unable to alloc receive buffers\n");16181618 err = -ENOMEM;16191619- goto err_out_notify_unset;16191619+ goto err_out_free_rq;16201620 }16211621 }16221622···1649164916501650 return 0;1651165116521652-err_out_notify_unset:16521652+err_out_free_rq:16531653+ for (i = 0; i < enic->rq_count; i++)16541654+ vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);16531655 enic_dev_notify_unset(enic);16541656err_out_free_intr:16551657 enic_free_intr(enic);
+5-13
drivers/net/ethernet/dnet.c
···398398 * break out of while loop if there are no more399399 * packets waiting400400 */401401- if (!(dnet_readl(bp, RX_FIFO_WCNT) >> 16)) {402402- napi_complete(napi);403403- int_enable = dnet_readl(bp, INTR_ENB);404404- int_enable |= DNET_INTR_SRC_RX_CMDFIFOAF;405405- dnet_writel(bp, int_enable, INTR_ENB);406406- return 0;407407- }401401+ if (!(dnet_readl(bp, RX_FIFO_WCNT) >> 16))402402+ break;408403409404 cmd_word = dnet_readl(bp, RX_LEN_FIFO);410405 pkt_len = cmd_word & 0xFFFF;···428433 "size %u.\n", dev->name, pkt_len);429434 }430435431431- budget -= npackets;432432-433436 if (npackets < budget) {434437 /* We processed all packets available. Tell NAPI it can435435- * stop polling then re-enable rx interrupts */438438+ * stop polling then re-enable rx interrupts.439439+ */436440 napi_complete(napi);437441 int_enable = dnet_readl(bp, INTR_ENB);438442 int_enable |= DNET_INTR_SRC_RX_CMDFIFOAF;439443 dnet_writel(bp, int_enable, INTR_ENB);440440- return 0;441444 }442445443443- /* There are still packets waiting */444444- return 1;446446+ return npackets;445447}446448447449static irqreturn_t dnet_interrupt(int irq, void *dev_id)
+2
drivers/net/ethernet/freescale/fec.h
···424424 * (40ns * 6).425425 */426426#define FEC_QUIRK_BUG_CAPTURE (1 << 10)427427+/* Controller has only one MDIO bus */428428+#define FEC_QUIRK_SINGLE_MDIO (1 << 11)427429428430struct fec_enet_priv_tx_q {429431 int index;
+6-4
drivers/net/ethernet/freescale/fec_main.c
···9191 .driver_data = 0,9292 }, {9393 .name = "imx28-fec",9494- .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME,9494+ .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |9595+ FEC_QUIRK_SINGLE_MDIO,9596 }, {9697 .name = "imx6q-fec",9798 .driver_data = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |···19381937 int err = -ENXIO, i;1939193819401939 /*19411941- * The dual fec interfaces are not equivalent with enet-mac.19401940+ * The i.MX28 dual fec interfaces are not equal.19421941 * Here are the differences:19431942 *19441943 * - fec0 supports MII & RMII modes while fec1 only supports RMII···19531952 * mdio interface in board design, and need to be configured by19541953 * fec0 mii_bus.19551954 */19561956- if ((fep->quirks & FEC_QUIRK_ENET_MAC) && fep->dev_id > 0) {19551955+ if ((fep->quirks & FEC_QUIRK_SINGLE_MDIO) && fep->dev_id > 0) {19571956 /* fec1 uses fec0 mii_bus */19581957 if (mii_cnt && fec0_mii_bus) {19591958 fep->mii_bus = fec0_mii_bus;···20162015 mii_cnt++;2017201620182017 /* save fec0 mii_bus */20192019- if (fep->quirks & FEC_QUIRK_ENET_MAC)20182018+ if (fep->quirks & FEC_QUIRK_SINGLE_MDIO)20202019 fec0_mii_bus = fep->mii_bus;2021202020222021 return 0;···31303129 pdev->id_entry = of_id->data;31313130 fep->quirks = pdev->id_entry->driver_data;3132313131323132+ fep->netdev = ndev;31333133 fep->num_rx_queues = num_rx_qs;31343134 fep->num_tx_queues = num_tx_qs;31353135
+11
drivers/net/ethernet/intel/Kconfig
···281281282282 If unsure, say N.283283284284+config I40E_FCOE285285+ bool "Fibre Channel over Ethernet (FCoE)"286286+ default n287287+ depends on I40E && DCB && FCOE288288+ ---help---289289+ Say Y here if you want to use Fibre Channel over Ethernet (FCoE)290290+ in the driver. This will create new netdev for exclusive FCoE291291+ use with XL710 FCoE offloads enabled.292292+293293+ If unsure, say N.294294+284295config I40EVF285296 tristate "Intel(R) XL710 X710 Virtual Function Ethernet support"286297 depends on PCI_MSI
···7878} while (0)79798080typedef enum i40e_status_code i40e_status;8181-#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)8181+#ifdef CONFIG_I40E_FCOE8282#define I40E_FCOE8383-#endif /* CONFIG_FCOE or CONFIG_FCOE_MODULE */8383+#endif8484#endif /* _I40E_OSDEP_H_ */
+72-32
drivers/net/ethernet/intel/i40e/i40e_txrx.c
···658658 return le32_to_cpu(*(volatile __le32 *)head);659659}660660661661+#define WB_STRIDE 0x3662662+661663/**662664 * i40e_clean_tx_irq - Reclaim resources after transmit completes663665 * @tx_ring: tx ring to clean···761759 tx_ring->q_vector->tx.total_bytes += total_bytes;762760 tx_ring->q_vector->tx.total_packets += total_packets;763761762762+ /* check to see if there are any non-cache aligned descriptors763763+ * waiting to be written back, and kick the hardware to force764764+ * them to be written back in case of napi polling765765+ */766766+ if (budget &&767767+ !((i & WB_STRIDE) == WB_STRIDE) &&768768+ !test_bit(__I40E_DOWN, &tx_ring->vsi->state) &&769769+ (I40E_DESC_UNUSED(tx_ring) != tx_ring->count))770770+ tx_ring->arm_wb = true;771771+ else772772+ tx_ring->arm_wb = false;773773+764774 if (check_for_tx_hang(tx_ring) && i40e_check_tx_hang(tx_ring)) {765775 /* schedule immediate reset if we believe we hung */766776 dev_info(tx_ring->dev, "Detected Tx Unit Hang\n"···791777 netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);792778793779 dev_info(tx_ring->dev,794794- "tx hang detected on queue %d, resetting adapter\n",780780+ "tx hang detected on queue %d, reset requested\n",795781 tx_ring->queue_index);796782797797- tx_ring->netdev->netdev_ops->ndo_tx_timeout(tx_ring->netdev);783783+ /* do not fire the reset immediately, wait for the stack to784784+ * decide we are truly stuck, also prevents every queue from785785+ * simultaneously requesting a reset786786+ */798787799799- /* the adapter is about to reset, no point in enabling stuff */800800- return true;788788+ /* the adapter is about to reset, no point in enabling polling */789789+ budget = 1;801790 }802791803792 netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev,···823806 }824807 }825808826826- return budget > 0;809809+ return !!budget;810810+}811811+812812+/**813813+ * i40e_force_wb - Arm hardware to do a wb on noncache aligned descriptors814814+ * @vsi: the VSI we care about815815+ * @q_vector: the vector on which to force writeback816816+ *817817+ **/818818+static void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector)819819+{820820+ u32 val = I40E_PFINT_DYN_CTLN_INTENA_MASK |821821+ I40E_PFINT_DYN_CTLN_SWINT_TRIG_MASK |822822+ I40E_PFINT_DYN_CTLN_SW_ITR_INDX_ENA_MASK823823+ /* allow 00 to be written to the index */;824824+825825+ wr32(&vsi->back->hw,826826+ I40E_PFINT_DYN_CTLN(q_vector->v_idx + vsi->base_vector - 1),827827+ val);827828}828829829830/**···13251290 * so the total length of IPv4 header is IHL*4 bytes13261291 * The UDP_0 bit *may* bet set if the *inner* header is UDP13271292 */13281328- if (ipv4_tunnel &&13291329- (decoded.inner_prot != I40E_RX_PTYPE_INNER_PROT_UDP) &&13301330- !(rx_status & (1 << I40E_RX_DESC_STATUS_UDP_0_SHIFT))) {12931293+ if (ipv4_tunnel) {13311294 skb->transport_header = skb->mac_header +13321295 sizeof(struct ethhdr) +13331296 (ip_hdr(skb)->ihl * 4);···13351302 skb->protocol == htons(ETH_P_8021AD))13361303 ? VLAN_HLEN : 0;1337130413381338- rx_udp_csum = udp_csum(skb);13391339- iph = ip_hdr(skb);13401340- csum = csum_tcpudp_magic(13411341- iph->saddr, iph->daddr,13421342- (skb->len - skb_transport_offset(skb)),13431343- IPPROTO_UDP, rx_udp_csum);13051305+ if ((ip_hdr(skb)->protocol == IPPROTO_UDP) &&13061306+ (udp_hdr(skb)->check != 0)) {13071307+ rx_udp_csum = udp_csum(skb);13081308+ iph = ip_hdr(skb);13091309+ csum = csum_tcpudp_magic(13101310+ iph->saddr, iph->daddr,13111311+ (skb->len - skb_transport_offset(skb)),13121312+ IPPROTO_UDP, rx_udp_csum);1344131313451345- if (udp_hdr(skb)->check != csum)13461346- goto checksum_fail;13141314+ if (udp_hdr(skb)->check != csum)13151315+ goto checksum_fail;13161316+13171317+ } /* else its GRE and so no outer UDP header */13471318 }1348131913491320 skb->ip_summed = CHECKSUM_UNNECESSARY;···16181581 struct i40e_vsi *vsi = q_vector->vsi;16191582 struct i40e_ring *ring;16201583 bool clean_complete = true;15841584+ bool arm_wb = false;16211585 int budget_per_ring;1622158616231587 if (test_bit(__I40E_DOWN, &vsi->state)) {···16291591 /* Since the actual Tx work is minimal, we can give the Tx a larger16301592 * budget and be more aggressive about cleaning up the Tx descriptors.16311593 */16321632- i40e_for_each_ring(ring, q_vector->tx)15941594+ i40e_for_each_ring(ring, q_vector->tx) {16331595 clean_complete &= i40e_clean_tx_irq(ring, vsi->work_limit);15961596+ arm_wb |= ring->arm_wb;15971597+ }1634159816351599 /* We attempt to distribute budget to each Rx queue fairly, but don't16361600 * allow the budget to go below 1 because that would exit polling early.···16431603 clean_complete &= i40e_clean_rx_irq(ring, budget_per_ring);1644160416451605 /* If work not completed, return budget and polling will return */16461646- if (!clean_complete)16061606+ if (!clean_complete) {16071607+ if (arm_wb)16081608+ i40e_force_wb(vsi, q_vector);16471609 return budget;16101610+ }1648161116491612 /* Work is done so exit the polling mode and re-enable the interrupt */16501613 napi_complete(napi);···18831840 if (err < 0)18841841 return err;1885184218861886- if (protocol == htons(ETH_P_IP)) {18871887- iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);18431843+ iph = skb->encapsulation ? inner_ip_hdr(skb) : ip_hdr(skb);18441844+ ipv6h = skb->encapsulation ? inner_ipv6_hdr(skb) : ipv6_hdr(skb);18451845+18461846+ if (iph->version == 4) {18881847 tcph = skb->encapsulation ? inner_tcp_hdr(skb) : tcp_hdr(skb);18891848 iph->tot_len = 0;18901849 iph->check = 0;18911850 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,18921851 0, IPPROTO_TCP, 0);18931893- } else if (skb_is_gso_v6(skb)) {18941894-18951895- ipv6h = skb->encapsulation ? inner_ipv6_hdr(skb)18961896- : ipv6_hdr(skb);18521852+ } else if (ipv6h->version == 6) {18971853 tcph = skb->encapsulation ? inner_tcp_hdr(skb) : tcp_hdr(skb);18981854 ipv6h->payload_len = 0;18991855 tcph->check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr,···19881946 I40E_TX_CTX_EXT_IP_IPV4_NO_CSUM;19891947 }19901948 } else if (tx_flags & I40E_TX_FLAGS_IPV6) {19911991- if (tx_flags & I40E_TX_FLAGS_TSO) {19921992- *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;19491949+ *cd_tunneling |= I40E_TX_CTX_EXT_IP_IPV6;19501950+ if (tx_flags & I40E_TX_FLAGS_TSO)19931951 ip_hdr(skb)->check = 0;19941994- } else {19951995- *cd_tunneling |=19961996- I40E_TX_CTX_EXT_IP_IPV4_NO_CSUM;19971997- }19981952 }1999195320001954 /* Now set the ctx descriptor fields */···20001962 ((skb_inner_network_offset(skb) -20011963 skb_transport_offset(skb)) >> 1) <<20021964 I40E_TXD_CTX_QW0_NATLEN_SHIFT;20032003-19651965+ if (this_ip_hdr->version == 6) {19661966+ tx_flags &= ~I40E_TX_FLAGS_IPV4;19671967+ tx_flags |= I40E_TX_FLAGS_IPV6;19681968+ }20041969 } else {20051970 network_hdr_len = skb_network_header_len(skb);20061971 this_ip_hdr = ip_hdr(skb);···22392198 /* Place RS bit on last descriptor of any packet that spans across the22402199 * 4th descriptor (WB_STRIDE aka 0x3) in a 64B cacheline.22412200 */22422242-#define WB_STRIDE 0x322432201 if (((i & WB_STRIDE) != WB_STRIDE) &&22442202 (first <= &tx_ring->tx_bi[i]) &&22452203 (first >= &tx_ring->tx_bi[i & ~WB_STRIDE])) {
+1
drivers/net/ethernet/intel/i40e/i40e_txrx.h
···241241 unsigned long last_rx_timestamp;242242243243 bool ring_active; /* is ring online or not */244244+ bool arm_wb; /* do something to arm write back */244245245246 /* stats structs */246247 struct i40e_queue_stats stats;
+1-1
drivers/net/ethernet/intel/igb/e1000_82575.c
···11251125 u32 swmask = mask;11261126 u32 fwmask = mask << 16;11271127 s32 ret_val = 0;11281128- s32 i = 0, timeout = 200; /* FIXME: find real value to use here */11281128+ s32 i = 0, timeout = 200;1129112911301130 while (i < timeout) {11311131 if (igb_get_hw_semaphore(hw)) {
···40334033 (void)pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));40344034 mgp->cmd = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->cmd),40354035 &mgp->cmd_bus, GFP_KERNEL);40364036- if (mgp->cmd == NULL)40364036+ if (!mgp->cmd) {40374037+ status = -ENOMEM;40374038 goto abort_with_enabled;40394039+ }4038404040394041 mgp->board_span = pci_resource_len(pdev, 0);40404042 mgp->iomem_base = pci_resource_start(pdev, 0);
+3-5
drivers/net/ethernet/qlogic/qla3xxx.c
···146146{147147 int i = 0;148148149149- while (i < 10) {150150- if (i)151151- ssleep(1);152152-149149+ do {153150 if (ql_sem_lock(qdev,154151 QL_DRVR_SEM_MASK,155152 (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index)···155158 "driver lock acquired\n");156159 return 1;157160 }158158- }161161+ ssleep(1);162162+ } while (++i < 10);159163160164 netdev_err(qdev->ndev, "Timed out waiting for driver lock...\n");161165 return 0;
···369369 DESC_I_RINT1 = 0x0001,370370};371371372372+#define DEFAULT_TRSCER_ERR_MASK (DESC_I_RINT8 | DESC_I_RINT5 | DESC_I_TINT2)373373+372374/* RPADIR */373375enum RPADIR_BIT {374376 RPADIR_PADS1 = 0x20000, RPADIR_PADS0 = 0x10000,···471469 /* interrupt checking mask */472470 unsigned long tx_check;473471 unsigned long eesr_err_check;472472+473473+ /* Error mask */474474+ unsigned long trscer_err_mask;474475475476 /* hardware features */476477 unsigned long irq_flags; /* IRQ configuration flags */
+17-13
drivers/net/ethernet/ti/cpsw.c
···610610611611 /* Clear all mcast from ALE */612612 cpsw_ale_flush_multicast(ale, ALE_ALL_PORTS <<613613- priv->host_port);613613+ priv->host_port, -1);614614615615 /* Flood All Unicast Packets to Host port */616616 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1);···634634static void cpsw_ndo_set_rx_mode(struct net_device *ndev)635635{636636 struct cpsw_priv *priv = netdev_priv(ndev);637637+ int vid;638638+639639+ if (priv->data.dual_emac)640640+ vid = priv->slaves[priv->emac_port].port_vlan;641641+ else642642+ vid = priv->data.default_vlan;637643638644 if (ndev->flags & IFF_PROMISC) {639645 /* Enable promiscuous mode */···655649 cpsw_ale_set_allmulti(priv->ale, priv->ndev->flags & IFF_ALLMULTI);656650657651 /* Clear all mcast from ALE */658658- cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS << priv->host_port);652652+ cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS << priv->host_port,653653+ vid);659654660655 if (!netdev_mc_empty(ndev)) {661656 struct netdev_hw_addr *ha;···764757static irqreturn_t cpsw_interrupt(int irq, void *dev_id)765758{766759 struct cpsw_priv *priv = dev_id;760760+ int value = irq - priv->irqs_table[0];761761+762762+ /* NOTICE: Ending IRQ here. The trick with the 'value' variable above763763+ * is to make sure we will always write the correct value to the EOI764764+ * register. Namely 0 for RX_THRESH Interrupt, 1 for RX Interrupt, 2765765+ * for TX Interrupt and 3 for MISC Interrupt.766766+ */767767+ cpdma_ctlr_eoi(priv->dma, value);767768768769 cpsw_intr_disable(priv);769770 if (priv->irq_enabled == true) {···801786 int num_tx, num_rx;802787803788 num_tx = cpdma_chan_process(priv->txch, 128);804804- if (num_tx)805805- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);806789807790 num_rx = cpdma_chan_process(priv->rxch, budget);808791 if (num_rx < budget) {···808795809796 napi_complete(napi);810797 cpsw_intr_enable(priv);811811- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);812798 prim_cpsw = cpsw_get_slave_priv(priv, 0);813799 if (prim_cpsw->irq_enabled == false) {814800 prim_cpsw->irq_enabled = true;···13221310 napi_enable(&priv->napi);13231311 cpdma_ctlr_start(priv->dma);13241312 cpsw_intr_enable(priv);13251325- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);13261326- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);1327131313281314 prim_cpsw = cpsw_get_slave_priv(priv, 0);13291315 if (prim_cpsw->irq_enabled == false) {···15881578 cpdma_chan_start(priv->txch);15891579 cpdma_ctlr_int_ctrl(priv->dma, true);15901580 cpsw_intr_enable(priv);15911591- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);15921592- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);15931593-15941581}1595158215961583static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p)···16271620 cpsw_interrupt(ndev->irq, priv);16281621 cpdma_ctlr_int_ctrl(priv->dma, true);16291622 cpsw_intr_enable(priv);16301630- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);16311631- cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);16321632-16331623}16341624#endif16351625
+9-1
drivers/net/ethernet/ti/cpsw_ale.c
···234234 cpsw_ale_set_entry_type(ale_entry, ALE_TYPE_FREE);235235}236236237237-int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask)237237+int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)238238{239239 u32 ale_entry[ALE_ENTRY_WORDS];240240 int ret, idx;···243243 cpsw_ale_read(ale, idx, ale_entry);244244 ret = cpsw_ale_get_entry_type(ale_entry);245245 if (ret != ALE_TYPE_ADDR && ret != ALE_TYPE_VLAN_ADDR)246246+ continue;247247+248248+ /* if vid passed is -1 then remove all multicast entry from249249+ * the table irrespective of vlan id, if a valid vlan id is250250+ * passed then remove only multicast added to that vlan id.251251+ * if vlan id doesn't match then move on to next entry.252252+ */253253+ if (vid != -1 && cpsw_ale_get_vlan_id(ale_entry) != vid)246254 continue;247255248256 if (cpsw_ale_get_mcast(ale_entry)) {
+1-1
drivers/net/ethernet/ti/cpsw_ale.h
···92929393int cpsw_ale_set_ageout(struct cpsw_ale *ale, int ageout);9494int cpsw_ale_flush(struct cpsw_ale *ale, int port_mask);9595-int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask);9595+int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid);9696int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,9797 int flags, u16 vid);9898int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
···629629static void team_notify_peers_work(struct work_struct *work)630630{631631 struct team *team;632632+ int val;632633633634 team = container_of(work, struct team, notify_peers.dw.work);634635···637636 schedule_delayed_work(&team->notify_peers.dw, 0);638637 return;639638 }639639+ val = atomic_dec_if_positive(&team->notify_peers.count_pending);640640+ if (val < 0) {641641+ rtnl_unlock();642642+ return;643643+ }640644 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, team->dev);641645 rtnl_unlock();642642- if (!atomic_dec_and_test(&team->notify_peers.count_pending))646646+ if (val)643647 schedule_delayed_work(&team->notify_peers.dw,644648 msecs_to_jiffies(team->notify_peers.interval));645649}···675669static void team_mcast_rejoin_work(struct work_struct *work)676670{677671 struct team *team;672672+ int val;678673679674 team = container_of(work, struct team, mcast_rejoin.dw.work);680675···683676 schedule_delayed_work(&team->mcast_rejoin.dw, 0);684677 return;685678 }679679+ val = atomic_dec_if_positive(&team->mcast_rejoin.count_pending);680680+ if (val < 0) {681681+ rtnl_unlock();682682+ return;683683+ }686684 call_netdevice_notifiers(NETDEV_RESEND_IGMP, team->dev);687685 rtnl_unlock();688688- if (!atomic_dec_and_test(&team->mcast_rejoin.count_pending))686686+ if (val)689687 schedule_delayed_work(&team->mcast_rejoin.dw,690688 msecs_to_jiffies(team->mcast_rejoin.interval));691689}
+1-1
drivers/net/usb/kaweth.c
···12761276 awd.done = 0;1277127712781278 urb->context = &awd;12791279- status = usb_submit_urb(urb, GFP_NOIO);12791279+ status = usb_submit_urb(urb, GFP_ATOMIC);12801280 if (status) {12811281 // something went wrong12821282 usb_free_urb(urb);
+7-3
drivers/net/usb/qmi_wwan.c
···5656/* default ethernet address used by the modem */5757static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};58585959+static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};6060+5961/* Make up an ethernet header if the packet doesn't have one.6062 *6163 * A firmware bug common among several devices cause them to send raw···334332 usb_driver_release_interface(driver, info->data);335333 }336334337337- /* Never use the same address on both ends of the link, even338338- * if the buggy firmware told us to.335335+ /* Never use the same address on both ends of the link, even if the336336+ * buggy firmware told us to. Or, if device is assigned the well-known337337+ * buggy firmware MAC address, replace it with a random address,339338 */340340- if (ether_addr_equal(dev->net->dev_addr, default_modem_addr))339339+ if (ether_addr_equal(dev->net->dev_addr, default_modem_addr) ||340340+ ether_addr_equal(dev->net->dev_addr, buggy_fw_addr))341341 eth_hw_addr_random(dev->net);342342343343 /* make MAC addr easily distinguishable from an IP header */
···6969#include "iwl-agn-hw.h"70707171/* Highest firmware API version supported */7272-#define IWL7260_UCODE_API_MAX 107373-#define IWL3160_UCODE_API_MAX 107272+#define IWL7260_UCODE_API_MAX 127373+#define IWL3160_UCODE_API_MAX 1274747575/* Oldest version we won't warn about */7676#define IWL7260_UCODE_API_OK 10···105105#define IWL7265_MODULE_FIRMWARE(api) IWL7265_FW_PRE __stringify(api) ".ucode"106106107107#define IWL7265D_FW_PRE "iwlwifi-7265D-"108108-#define IWL7265D_MODULE_FIRMWARE(api) IWL7265_FW_PRE __stringify(api) ".ucode"108108+#define IWL7265D_MODULE_FIRMWARE(api) IWL7265D_FW_PRE __stringify(api) ".ucode"109109110110#define NVM_HW_SECTION_NUM_FAMILY_7000 0111111
+1-1
drivers/net/wireless/iwlwifi/iwl-8000.c
···6969#include "iwl-agn-hw.h"70707171/* Highest firmware API version supported */7272-#define IWL8000_UCODE_API_MAX 107272+#define IWL8000_UCODE_API_MAX 1273737474/* Oldest version we won't warn about */7575#define IWL8000_UCODE_API_OK 10
+4
drivers/net/wireless/iwlwifi/iwl-fw-file.h
···243243 * @IWL_UCODE_TLV_API_SF_NO_DUMMY_NOTIF: ucode supports disabling dummy notif.244244 * @IWL_UCODE_TLV_API_FRAGMENTED_SCAN: This ucode supports active dwell time245245 * longer than the passive one, which is essential for fragmented scan.246246+ * @IWL_UCODE_TLV_API_BASIC_DWELL: use only basic dwell time in scan command,247247+ * regardless of the band or the number of the probes. FW will calculate248248+ * the actual dwell time.246249 */247250enum iwl_ucode_tlv_api {248251 IWL_UCODE_TLV_API_WOWLAN_CONFIG_TID = BIT(0),···256253 IWL_UCODE_TLV_API_LMAC_SCAN = BIT(6),257254 IWL_UCODE_TLV_API_SF_NO_DUMMY_NOTIF = BIT(7),258255 IWL_UCODE_TLV_API_FRAGMENTED_SCAN = BIT(8),256256+ IWL_UCODE_TLV_API_BASIC_DWELL = BIT(13),259257};260258261259/**
+2
drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
···672672 * @IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented673673 * @IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED: insert WFA vendor-specific TPC report674674 * and DS parameter set IEs into probe requests.675675+ * @IWL_MVM_LMAC_SCAN_FLAG_MATCH: Send match found notification on matches675676 */676677enum iwl_mvm_lmac_scan_flags {677678 IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL = BIT(0),···682681 IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS = BIT(4),683682 IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED = BIT(5),684683 IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED = BIT(6),684684+ IWL_MVM_LMAC_SCAN_FLAG_MATCH = BIT(9),685685};686686687687enum iwl_scan_priority {
+14-5
drivers/net/wireless/iwlwifi/mvm/scan.c
···171171 * already included in the probe template, so we need to set only172172 * req->n_ssids - 1 bits in addition to the first bit.173173 */174174-static u16 iwl_mvm_get_active_dwell(enum ieee80211_band band, int n_ssids)174174+static u16 iwl_mvm_get_active_dwell(struct iwl_mvm *mvm,175175+ enum ieee80211_band band, int n_ssids)175176{177177+ if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BASIC_DWELL)178178+ return 10;176179 if (band == IEEE80211_BAND_2GHZ)177180 return 20 + 3 * (n_ssids + 1);178181 return 10 + 2 * (n_ssids + 1);179182}180183181181-static u16 iwl_mvm_get_passive_dwell(enum ieee80211_band band)184184+static u16 iwl_mvm_get_passive_dwell(struct iwl_mvm *mvm,185185+ enum ieee80211_band band)182186{187187+ if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_BASIC_DWELL)188188+ return 110;183189 return band == IEEE80211_BAND_2GHZ ? 100 + 20 : 100 + 10;184190}185191···337331 */338332 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {339333 u32 passive_dwell =340340- iwl_mvm_get_passive_dwell(IEEE80211_BAND_2GHZ);334334+ iwl_mvm_get_passive_dwell(mvm,335335+ IEEE80211_BAND_2GHZ);341336 params->max_out_time = passive_dwell;342337 } else {343338 params->passive_fragmented = true;···355348 params->dwell[band].passive = frag_passive_dwell;356349 else357350 params->dwell[band].passive =358358- iwl_mvm_get_passive_dwell(band);359359- params->dwell[band].active = iwl_mvm_get_active_dwell(band,351351+ iwl_mvm_get_passive_dwell(mvm, band);352352+ params->dwell[band].active = iwl_mvm_get_active_dwell(mvm, band,360353 n_ssids);361354 }362355}···1455144814561449 if (iwl_mvm_scan_pass_all(mvm, req))14571450 flags |= IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL;14511451+ else14521452+ flags |= IWL_MVM_LMAC_SCAN_FLAG_MATCH;1458145314591454 if (req->n_ssids == 1 && req->ssids[0].ssid_len != 0)14601455 flags |= IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION;
+6-2
drivers/net/wireless/iwlwifi/mvm/tx.c
···108108 tx_flags &= ~TX_CMD_FLG_SEQ_CTL;109109 }110110111111- /* tid_tspec will default to 0 = BE when QOS isn't enabled */112112- ac = tid_to_mac80211_ac[tx_cmd->tid_tspec];111111+ /* Default to 0 (BE) when tid_spec is set to IWL_TID_NON_QOS */112112+ if (tx_cmd->tid_tspec < IWL_MAX_TID_COUNT)113113+ ac = tid_to_mac80211_ac[tx_cmd->tid_tspec];114114+ else115115+ ac = tid_to_mac80211_ac[0];116116+113117 tx_flags |= iwl_mvm_bt_coex_tx_prio(mvm, hdr, info, ac) <<114118 TX_CMD_FLG_BT_PRIO_POS;115119
+1-1
drivers/net/wireless/iwlwifi/mvm/utils.c
···665665 if (num_of_ant(mvm->fw->valid_rx_ant) == 1)666666 return false;667667668668- if (!mvm->cfg->rx_with_siso_diversity)668668+ if (mvm->cfg->rx_with_siso_diversity)669669 return false;670670671671 ieee80211_iterate_active_interfaces_atomic(
···11631163 */11641164static inline int ap_test_config_domain(unsigned int domain)11651165{11661166- if (!ap_configuration)11671167- return 1;11681168- return ap_test_config(ap_configuration->aqm, domain);11661166+ if (!ap_configuration) /* QCI not supported */11671167+ if (domain < 16)11681168+ return 1; /* then domains 0...15 are configured */11691169+ else11701170+ return 0;11711171+ else11721172+ return ap_test_config(ap_configuration->aqm, domain);11691173}1170117411711175/**
+3-1
drivers/scsi/qla2xxx/qla_os.c
···734734 * Return target busy if we've received a non-zero retry_delay_timer735735 * in a FCP_RSP.736736 */737737- if (time_after(jiffies, fcport->retry_delay_timestamp))737737+ if (fcport->retry_delay_timestamp == 0) {738738+ /* retry delay not set */739739+ } else if (time_after(jiffies, fcport->retry_delay_timestamp))738740 fcport->retry_delay_timestamp = 0;739741 else740742 goto qc24_target_busy;
+6-6
drivers/target/iscsi/iscsi_target.c
···20272027 goto reject;20282028 }20292029 if (!strncmp("=All", text_ptr, 4)) {20302030- cmd->cmd_flags |= IFC_SENDTARGETS_ALL;20302030+ cmd->cmd_flags |= ICF_SENDTARGETS_ALL;20312031 } else if (!strncmp("=iqn.", text_ptr, 5) ||20322032 !strncmp("=eui.", text_ptr, 5)) {20332033- cmd->cmd_flags |= IFC_SENDTARGETS_SINGLE;20332033+ cmd->cmd_flags |= ICF_SENDTARGETS_SINGLE;20342034 } else {20352035 pr_err("Unable to locate valid SendTargets=%s value\n", text_ptr);20362036 goto reject;···34153415 return -ENOMEM;34163416 }34173417 /*34183418- * Locate pointer to iqn./eui. string for IFC_SENDTARGETS_SINGLE34183418+ * Locate pointer to iqn./eui. string for ICF_SENDTARGETS_SINGLE34193419 * explicit case..34203420 */34213421- if (cmd->cmd_flags & IFC_SENDTARGETS_SINGLE) {34213421+ if (cmd->cmd_flags & ICF_SENDTARGETS_SINGLE) {34223422 text_ptr = strchr(text_in, '=');34233423 if (!text_ptr) {34243424 pr_err("Unable to locate '=' string in text_in:"···3434343434353435 spin_lock(&tiqn_lock);34363436 list_for_each_entry(tiqn, &g_tiqn_list, tiqn_list) {34373437- if ((cmd->cmd_flags & IFC_SENDTARGETS_SINGLE) &&34373437+ if ((cmd->cmd_flags & ICF_SENDTARGETS_SINGLE) &&34383438 strcmp(tiqn->tiqn, text_ptr)) {34393439 continue;34403440 }···35123512 if (end_of_buf)35133513 break;3514351435153515- if (cmd->cmd_flags & IFC_SENDTARGETS_SINGLE)35153515+ if (cmd->cmd_flags & ICF_SENDTARGETS_SINGLE)35163516 break;35173517 }35183518 spin_unlock(&tiqn_lock);
···11031103}11041104EXPORT_SYMBOL(se_dev_set_queue_depth);1105110511061106-int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors)11071107-{11081108- int block_size = dev->dev_attrib.block_size;11091109-11101110- if (dev->export_count) {11111111- pr_err("dev[%p]: Unable to change SE Device"11121112- " fabric_max_sectors while export_count is %d\n",11131113- dev, dev->export_count);11141114- return -EINVAL;11151115- }11161116- if (!fabric_max_sectors) {11171117- pr_err("dev[%p]: Illegal ZERO value for"11181118- " fabric_max_sectors\n", dev);11191119- return -EINVAL;11201120- }11211121- if (fabric_max_sectors < DA_STATUS_MAX_SECTORS_MIN) {11221122- pr_err("dev[%p]: Passed fabric_max_sectors: %u less than"11231123- " DA_STATUS_MAX_SECTORS_MIN: %u\n", dev, fabric_max_sectors,11241124- DA_STATUS_MAX_SECTORS_MIN);11251125- return -EINVAL;11261126- }11271127- if (fabric_max_sectors > DA_STATUS_MAX_SECTORS_MAX) {11281128- pr_err("dev[%p]: Passed fabric_max_sectors: %u"11291129- " greater than DA_STATUS_MAX_SECTORS_MAX:"11301130- " %u\n", dev, fabric_max_sectors,11311131- DA_STATUS_MAX_SECTORS_MAX);11321132- return -EINVAL;11331133- }11341134- /*11351135- * Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks()11361136- */11371137- if (!block_size) {11381138- block_size = 512;11391139- pr_warn("Defaulting to 512 for zero block_size\n");11401140- }11411141- fabric_max_sectors = se_dev_align_max_sectors(fabric_max_sectors,11421142- block_size);11431143-11441144- dev->dev_attrib.fabric_max_sectors = fabric_max_sectors;11451145- pr_debug("dev[%p]: SE Device max_sectors changed to %u\n",11461146- dev, fabric_max_sectors);11471147- return 0;11481148-}11491149-EXPORT_SYMBOL(se_dev_set_fabric_max_sectors);11501150-11511106int se_dev_set_optimal_sectors(struct se_device *dev, u32 optimal_sectors)11521107{11531108 if (dev->export_count) {···11111156 dev, dev->export_count);11121157 return -EINVAL;11131158 }11141114- if (optimal_sectors > dev->dev_attrib.fabric_max_sectors) {11591159+ if (optimal_sectors > dev->dev_attrib.hw_max_sectors) {11151160 pr_err("dev[%p]: Passed optimal_sectors %u cannot be"11161116- " greater than fabric_max_sectors: %u\n", dev,11171117- optimal_sectors, dev->dev_attrib.fabric_max_sectors);11611161+ " greater than hw_max_sectors: %u\n", dev,11621162+ optimal_sectors, dev->dev_attrib.hw_max_sectors);11181163 return -EINVAL;11191164 }11201165···15081553 dev->dev_attrib.unmap_granularity_alignment =15091554 DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT;15101555 dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN;15111511- dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS;15121512- dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS;1513155615141557 xcopy_lun = &dev->xcopy_lun;15151558 xcopy_lun->lun_se_dev = dev;···15481595 dev->dev_attrib.hw_max_sectors =15491596 se_dev_align_max_sectors(dev->dev_attrib.hw_max_sectors,15501597 dev->dev_attrib.hw_block_size);15981598+ dev->dev_attrib.optimal_sectors = dev->dev_attrib.hw_max_sectors;1551159915521600 dev->dev_index = scsi_get_new_index(SCSI_DEVICE_INDEX);15531601 dev->creation_time = get_jiffies_64();
+10-2
drivers/target/target_core_file.c
···621621 struct fd_prot fd_prot;622622 sense_reason_t rc;623623 int ret = 0;624624-624624+ /*625625+ * We are currently limited by the number of iovecs (2048) per626626+ * single vfs_[writev,readv] call.627627+ */628628+ if (cmd->data_length > FD_MAX_BYTES) {629629+ pr_err("FILEIO: Not able to process I/O of %u bytes due to"630630+ "FD_MAX_BYTES: %u iovec count limitiation\n",631631+ cmd->data_length, FD_MAX_BYTES);632632+ return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;633633+ }625634 /*626635 * Call vectorized fileio functions to map struct scatterlist627636 * physical memory addresses to struct iovec virtual memory.···968959 &fileio_dev_attrib_hw_block_size.attr,969960 &fileio_dev_attrib_block_size.attr,970961 &fileio_dev_attrib_hw_max_sectors.attr,971971- &fileio_dev_attrib_fabric_max_sectors.attr,972962 &fileio_dev_attrib_optimal_sectors.attr,973963 &fileio_dev_attrib_hw_queue_depth.attr,974964 &fileio_dev_attrib_queue_depth.attr,
···119119 continue;120120121121 result = acpi_bus_get_device(trt->source, &adev);122122- if (!result)123123- acpi_create_platform_device(adev);124124- else122122+ if (result)125123 pr_warn("Failed to get source ACPI device\n");126124127125 result = acpi_bus_get_device(trt->target, &adev);128128- if (!result)129129- acpi_create_platform_device(adev);130130- else126126+ if (result)131127 pr_warn("Failed to get target ACPI device\n");132128 }133129···202206203207 if (art->source) {204208 result = acpi_bus_get_device(art->source, &adev);205205- if (!result)206206- acpi_create_platform_device(adev);207207- else209209+ if (result)208210 pr_warn("Failed to get source ACPI device\n");209211 }210212 if (art->target) {211213 result = acpi_bus_get_device(art->target, &adev);212212- if (!result)213213- acpi_create_platform_device(adev);214214- else214214+ if (result)215215 pr_warn("Failed to get source ACPI device\n");216216 }217217 }
···130130 int ret;131131132132 adev = ACPI_COMPANION(dev);133133+ if (!adev)134134+ return -ENODEV;133135134136 status = acpi_evaluate_object(adev->handle, "PPCC", NULL, &buf);135137 if (ACPI_FAILURE(status))
···636636 err = broadsheet_spiflash_read_range(par, start_sector_addr,637637 data_start_addr, sector_buffer);638638 if (err)639639- return err;639639+ goto out;640640 }641641642642 /* now we copy our data into the right place in the sector buffer */···657657 err = broadsheet_spiflash_read_range(par, tail_start_addr,658658 tail_len, sector_buffer + tail_start_addr);659659 if (err)660660- return err;660660+ goto out;661661 }662662663663 /* if we got here we have the full sector that we want to rewrite. */···665665 /* first erase the sector */666666 err = broadsheet_spiflash_erase_sector(par, start_sector_addr);667667 if (err)668668- return err;668668+ goto out;669669670670 /* now write it */671671 err = broadsheet_spiflash_write_sector(par, start_sector_addr,672672 sector_buffer, sector_size);673673+out:674674+ kfree(sector_buffer);673675 return err;674676}675677
+1-1
drivers/video/fbdev/simplefb.c
···402402 if (ret)403403 return ret;404404405405- if (IS_ENABLED(CONFIG_OF) && of_chosen) {405405+ if (IS_ENABLED(CONFIG_OF_ADDRESS) && of_chosen) {406406 for_each_child_of_node(of_chosen, np) {407407 if (of_device_is_compatible(np, "simple-framebuffer"))408408 of_platform_device_create(np, NULL, NULL);
+1-9
drivers/virtio/virtio_pci_common.c
···282282283283 vp_free_vectors(vdev);284284 kfree(vp_dev->vqs);285285+ vp_dev->vqs = NULL;285286}286287287288static int vp_try_to_find_vqs(struct virtio_device *vdev, unsigned nvqs,···420419 }421420 }422421 return 0;423423-}424424-425425-void virtio_pci_release_dev(struct device *_d)426426-{427427- /*428428- * No need for a release method as we allocate/free429429- * all devices together with the pci devices.430430- * Provide an empty one to avoid getting a warning from core.431431- */432422}433423434424#ifdef CONFIG_PM_SLEEP
-1
drivers/virtio/virtio_pci_common.h
···126126 * - ignore the affinity request if we're using INTX127127 */128128int vp_set_vq_affinity(struct virtqueue *vq, int cpu);129129-void virtio_pci_release_dev(struct device *);130129131130int virtio_pci_legacy_probe(struct pci_dev *pci_dev,132131 const struct pci_device_id *id);
+11-1
drivers/virtio/virtio_pci_legacy.c
···211211 .set_vq_affinity = vp_set_vq_affinity,212212};213213214214+static void virtio_pci_release_dev(struct device *_d)215215+{216216+ struct virtio_device *vdev = dev_to_virtio(_d);217217+ struct virtio_pci_device *vp_dev = to_vp_device(vdev);218218+219219+ /* As struct device is a kobject, it's not safe to220220+ * free the memory (including the reference counter itself)221221+ * until it's release callback. */222222+ kfree(vp_dev);223223+}224224+214225/* the PCI probing function */215226int virtio_pci_legacy_probe(struct pci_dev *pci_dev,216227 const struct pci_device_id *id)···313302 pci_iounmap(pci_dev, vp_dev->ioaddr);314303 pci_release_regions(pci_dev);315304 pci_disable_device(pci_dev);316316- kfree(vp_dev);317305}
+10-3
fs/btrfs/backref.c
···15521552{15531553 int ret;15541554 int type;15551555- struct btrfs_tree_block_info *info;15561555 struct btrfs_extent_inline_ref *eiref;1557155615581557 if (*ptr == (unsigned long)-1)···15721573 }1573157415741575 /* we can treat both ref types equally here */15751575- info = (struct btrfs_tree_block_info *)(ei + 1);15761576 *out_root = btrfs_extent_inline_ref_offset(eb, eiref);15771577- *out_level = btrfs_tree_block_level(eb, info);15771577+15781578+ if (key->type == BTRFS_EXTENT_ITEM_KEY) {15791579+ struct btrfs_tree_block_info *info;15801580+15811581+ info = (struct btrfs_tree_block_info *)(ei + 1);15821582+ *out_level = btrfs_tree_block_level(eb, info);15831583+ } else {15841584+ ASSERT(key->type == BTRFS_METADATA_ITEM_KEY);15851585+ *out_level = (u8)key->offset;15861586+ }1578158715791588 if (ret == 1)15801589 *ptr = (unsigned long)-1;
+8
fs/btrfs/delayed-inode.c
···18571857{18581858 struct btrfs_delayed_node *delayed_node;1859185918601860+ /*18611861+ * we don't do delayed inode updates during log recovery because it18621862+ * leads to enospc problems. This means we also can't do18631863+ * delayed inode refs18641864+ */18651865+ if (BTRFS_I(inode)->root->fs_info->log_root_recovering)18661866+ return -EAGAIN;18671867+18601868 delayed_node = btrfs_get_or_create_delayed_node(inode);18611869 if (IS_ERR(delayed_node))18621870 return PTR_ERR(delayed_node);
+6-6
fs/btrfs/extent-tree.c
···31393139 struct extent_buffer *leaf;3140314031413141 ret = btrfs_search_slot(trans, extent_root, &cache->key, path, 0, 1);31423142- if (ret < 0)31423142+ if (ret) {31433143+ if (ret > 0)31443144+ ret = -ENOENT;31433145 goto fail;31443144- BUG_ON(ret); /* Corruption */31463146+ }3145314731463148 leaf = path->nodes[0];31473149 bi = btrfs_item_ptr_offset(leaf, path->slots[0]);···31513149 btrfs_mark_buffer_dirty(leaf);31523150 btrfs_release_path(path);31533151fail:31543154- if (ret) {31523152+ if (ret)31553153 btrfs_abort_transaction(trans, root, ret);31563156- return ret;31573157- }31583158- return 0;31543154+ return ret;3159315531603156}31613157
+3-1
fs/btrfs/inode.c
···6255625562566256out_fail:62576257 btrfs_end_transaction(trans, root);62586258- if (drop_on_err)62586258+ if (drop_on_err) {62596259+ inode_dec_link_count(inode);62596260 iput(inode);62616261+ }62606262 btrfs_balance_delayed_items(root);62616263 btrfs_btree_balance_dirty(root);62626264 return err;
···11091109 return rc;11101110}1111111111121112-/* copied from fs/locks.c with a name change */11131113-#define cifs_for_each_lock(inode, lockp) \11141114- for (lockp = &inode->i_flock; *lockp != NULL; \11151115- lockp = &(*lockp)->fl_next)11161116-11171112struct lock_to_push {11181113 struct list_head llist;11191114 __u64 offset;···11231128{11241129 struct inode *inode = cfile->dentry->d_inode;11251130 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);11261126- struct file_lock *flock, **before;11271127- unsigned int count = 0, i = 0;11311131+ struct file_lock *flock;11321132+ struct file_lock_context *flctx = inode->i_flctx;11331133+ unsigned int i;11281134 int rc = 0, xid, type;11291135 struct list_head locks_to_send, *el;11301136 struct lock_to_push *lck, *tmp;···1133113711341138 xid = get_xid();1135113911361136- spin_lock(&inode->i_lock);11371137- cifs_for_each_lock(inode, before) {11381138- if ((*before)->fl_flags & FL_POSIX)11391139- count++;11401140- }11411141- spin_unlock(&inode->i_lock);11401140+ if (!flctx)11411141+ goto out;1142114211431143 INIT_LIST_HEAD(&locks_to_send);1144114411451145 /*11461146- * Allocating count locks is enough because no FL_POSIX locks can be11471147- * added to the list while we are holding cinode->lock_sem that11461146+ * Allocating flc_posix_cnt locks is enough because no FL_POSIX locks11471147+ * can be added to the list while we are holding cinode->lock_sem that11481148 * protects locking operations of this inode.11491149 */11501150- for (; i < count; i++) {11501150+ for (i = 0; i < flctx->flc_posix_cnt; i++) {11511151 lck = kmalloc(sizeof(struct lock_to_push), GFP_KERNEL);11521152 if (!lck) {11531153 rc = -ENOMEM;···11531161 }1154116211551163 el = locks_to_send.next;11561156- spin_lock(&inode->i_lock);11571157- cifs_for_each_lock(inode, before) {11581158- flock = *before;11591159- if ((flock->fl_flags & FL_POSIX) == 0)11601160- continue;11641164+ spin_lock(&flctx->flc_lock);11651165+ list_for_each_entry(flock, &flctx->flc_posix, fl_list) {11611166 if (el == &locks_to_send) {11621167 /*11631168 * The list ended. We don't have enough allocated···11741185 lck->length = length;11751186 lck->type = type;11761187 lck->offset = flock->fl_start;11771177- el = el->next;11781188 }11791179- spin_unlock(&inode->i_lock);11891189+ spin_unlock(&flctx->flc_lock);1180119011811191 list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {11821192 int stored_rc;
+2-2
fs/ext4/extents.c
···5166516651675167 /* fallback to generic here if not in extents fmt */51685168 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))51695169- return __generic_block_fiemap(inode, fieinfo, start, len,51705170- ext4_get_block);51695169+ return generic_block_fiemap(inode, fieinfo, start, len,51705170+ ext4_get_block);5171517151725172 if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS))51735173 return -EBADR;
+116-108
fs/ext4/file.c
···273273 * we determine this extent as a data or a hole according to whether the274274 * page cache has data or not.275275 */276276-static int ext4_find_unwritten_pgoff(struct inode *inode, int whence,277277- loff_t endoff, loff_t *offset)276276+static int ext4_find_unwritten_pgoff(struct inode *inode,277277+ int whence,278278+ struct ext4_map_blocks *map,279279+ loff_t *offset)278280{279281 struct pagevec pvec;282282+ unsigned int blkbits;280283 pgoff_t index;281284 pgoff_t end;285285+ loff_t endoff;282286 loff_t startoff;283287 loff_t lastoff;284288 int found = 0;285289290290+ blkbits = inode->i_sb->s_blocksize_bits;286291 startoff = *offset;287292 lastoff = startoff;288288-293293+ endoff = (loff_t)(map->m_lblk + map->m_len) << blkbits;289294290295 index = startoff >> PAGE_CACHE_SHIFT;291296 end = endoff >> PAGE_CACHE_SHIFT;···408403static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)409404{410405 struct inode *inode = file->f_mapping->host;411411- struct fiemap_extent_info fie;412412- struct fiemap_extent ext[2];413413- loff_t next;414414- int i, ret = 0;406406+ struct ext4_map_blocks map;407407+ struct extent_status es;408408+ ext4_lblk_t start, last, end;409409+ loff_t dataoff, isize;410410+ int blkbits;411411+ int ret = 0;415412416413 mutex_lock(&inode->i_mutex);417417- if (offset >= inode->i_size) {414414+415415+ isize = i_size_read(inode);416416+ if (offset >= isize) {418417 mutex_unlock(&inode->i_mutex);419418 return -ENXIO;420419 }421421- fie.fi_flags = 0;422422- fie.fi_extents_max = 2;423423- fie.fi_extents_start = (struct fiemap_extent __user *) &ext;424424- while (1) {425425- mm_segment_t old_fs = get_fs();426420427427- fie.fi_extents_mapped = 0;428428- memset(ext, 0, sizeof(*ext) * fie.fi_extents_max);421421+ blkbits = inode->i_sb->s_blocksize_bits;422422+ start = offset >> blkbits;423423+ last = start;424424+ end = isize >> blkbits;425425+ dataoff = offset;429426430430- set_fs(get_ds());431431- ret = ext4_fiemap(inode, &fie, offset, maxsize - offset);432432- set_fs(old_fs);433433- if (ret)434434- break;435435-436436- /* No extents found, EOF */437437- if (!fie.fi_extents_mapped) {438438- ret = -ENXIO;427427+ do {428428+ map.m_lblk = last;429429+ map.m_len = end - last + 1;430430+ ret = ext4_map_blocks(NULL, inode, &map, 0);431431+ if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) {432432+ if (last != start)433433+ dataoff = (loff_t)last << blkbits;439434 break;440435 }441441- for (i = 0; i < fie.fi_extents_mapped; i++) {442442- next = (loff_t)(ext[i].fe_length + ext[i].fe_logical);443436444444- if (offset < (loff_t)ext[i].fe_logical)445445- offset = (loff_t)ext[i].fe_logical;446446- /*447447- * If extent is not unwritten, then it contains valid448448- * data, mapped or delayed.449449- */450450- if (!(ext[i].fe_flags & FIEMAP_EXTENT_UNWRITTEN))451451- goto out;452452-453453- /*454454- * If there is a unwritten extent at this offset,455455- * it will be as a data or a hole according to page456456- * cache that has data or not.457457- */458458- if (ext4_find_unwritten_pgoff(inode, SEEK_DATA,459459- next, &offset))460460- goto out;461461-462462- if (ext[i].fe_flags & FIEMAP_EXTENT_LAST) {463463- ret = -ENXIO;464464- goto out;465465- }466466- offset = next;437437+ /*438438+ * If there is a delay extent at this offset,439439+ * it will be as a data.440440+ */441441+ ext4_es_find_delayed_extent_range(inode, last, last, &es);442442+ if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) {443443+ if (last != start)444444+ dataoff = (loff_t)last << blkbits;445445+ break;467446 }468468- }469469- if (offset > inode->i_size)470470- offset = inode->i_size;471471-out:447447+448448+ /*449449+ * If there is a unwritten extent at this offset,450450+ * it will be as a data or a hole according to page451451+ * cache that has data or not.452452+ */453453+ if (map.m_flags & EXT4_MAP_UNWRITTEN) {454454+ int unwritten;455455+ unwritten = ext4_find_unwritten_pgoff(inode, SEEK_DATA,456456+ &map, &dataoff);457457+ if (unwritten)458458+ break;459459+ }460460+461461+ last++;462462+ dataoff = (loff_t)last << blkbits;463463+ } while (last <= end);464464+472465 mutex_unlock(&inode->i_mutex);473473- if (ret)474474- return ret;475466476476- return vfs_setpos(file, offset, maxsize);467467+ if (dataoff > isize)468468+ return -ENXIO;469469+470470+ return vfs_setpos(file, dataoff, maxsize);477471}478472479473/*480480- * ext4_seek_hole() retrieves the offset for SEEK_HOLE474474+ * ext4_seek_hole() retrieves the offset for SEEK_HOLE.481475 */482476static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)483477{484478 struct inode *inode = file->f_mapping->host;485485- struct fiemap_extent_info fie;486486- struct fiemap_extent ext[2];487487- loff_t next;488488- int i, ret = 0;479479+ struct ext4_map_blocks map;480480+ struct extent_status es;481481+ ext4_lblk_t start, last, end;482482+ loff_t holeoff, isize;483483+ int blkbits;484484+ int ret = 0;489485490486 mutex_lock(&inode->i_mutex);491491- if (offset >= inode->i_size) {487487+488488+ isize = i_size_read(inode);489489+ if (offset >= isize) {492490 mutex_unlock(&inode->i_mutex);493491 return -ENXIO;494492 }495493496496- fie.fi_flags = 0;497497- fie.fi_extents_max = 2;498498- fie.fi_extents_start = (struct fiemap_extent __user *)&ext;499499- while (1) {500500- mm_segment_t old_fs = get_fs();494494+ blkbits = inode->i_sb->s_blocksize_bits;495495+ start = offset >> blkbits;496496+ last = start;497497+ end = isize >> blkbits;498498+ holeoff = offset;501499502502- fie.fi_extents_mapped = 0;503503- memset(ext, 0, sizeof(*ext));500500+ do {501501+ map.m_lblk = last;502502+ map.m_len = end - last + 1;503503+ ret = ext4_map_blocks(NULL, inode, &map, 0);504504+ if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) {505505+ last += ret;506506+ holeoff = (loff_t)last << blkbits;507507+ continue;508508+ }504509505505- set_fs(get_ds());506506- ret = ext4_fiemap(inode, &fie, offset, maxsize - offset);507507- set_fs(old_fs);508508- if (ret)509509- break;510510+ /*511511+ * If there is a delay extent at this offset,512512+ * we will skip this extent.513513+ */514514+ ext4_es_find_delayed_extent_range(inode, last, last, &es);515515+ if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) {516516+ last = es.es_lblk + es.es_len;517517+ holeoff = (loff_t)last << blkbits;518518+ continue;519519+ }510520511511- /* No extents found */512512- if (!fie.fi_extents_mapped)513513- break;514514-515515- for (i = 0; i < fie.fi_extents_mapped; i++) {516516- next = (loff_t)(ext[i].fe_logical + ext[i].fe_length);517517- /*518518- * If extent is not unwritten, then it contains valid519519- * data, mapped or delayed.520520- */521521- if (!(ext[i].fe_flags & FIEMAP_EXTENT_UNWRITTEN)) {522522- if (offset < (loff_t)ext[i].fe_logical)523523- goto out;524524- offset = next;521521+ /*522522+ * If there is a unwritten extent at this offset,523523+ * it will be as a data or a hole according to page524524+ * cache that has data or not.525525+ */526526+ if (map.m_flags & EXT4_MAP_UNWRITTEN) {527527+ int unwritten;528528+ unwritten = ext4_find_unwritten_pgoff(inode, SEEK_HOLE,529529+ &map, &holeoff);530530+ if (!unwritten) {531531+ last += ret;532532+ holeoff = (loff_t)last << blkbits;525533 continue;526534 }527527- /*528528- * If there is a unwritten extent at this offset,529529- * it will be as a data or a hole according to page530530- * cache that has data or not.531531- */532532- if (ext4_find_unwritten_pgoff(inode, SEEK_HOLE,533533- next, &offset))534534- goto out;535535-536536- offset = next;537537- if (ext[i].fe_flags & FIEMAP_EXTENT_LAST)538538- goto out;539535 }540540- }541541- if (offset > inode->i_size)542542- offset = inode->i_size;543543-out:544544- mutex_unlock(&inode->i_mutex);545545- if (ret)546546- return ret;547536548548- return vfs_setpos(file, offset, maxsize);537537+ /* find a hole */538538+ break;539539+ } while (last <= end);540540+541541+ mutex_unlock(&inode->i_mutex);542542+543543+ if (holeoff > isize)544544+ holeoff = isize;545545+546546+ return vfs_setpos(file, holeoff, maxsize);549547}550548551549/*
+12-12
fs/ext4/resize.c
···2424 return -EPERM;25252626 /*2727+ * If we are not using the primary superblock/GDT copy don't resize,2828+ * because the user tools have no way of handling this. Probably a2929+ * bad time to do it anyways.3030+ */3131+ if (EXT4_SB(sb)->s_sbh->b_blocknr !=3232+ le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {3333+ ext4_warning(sb, "won't resize using backup superblock at %llu",3434+ (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);3535+ return -EPERM;3636+ }3737+3838+ /*2739 * We are not allowed to do online-resizing on a filesystem mounted2840 * with error, because it can destroy the filesystem easily.2941 */···769757 printk(KERN_DEBUG770758 "EXT4-fs: ext4_add_new_gdb: adding group block %lu\n",771759 gdb_num);772772-773773- /*774774- * If we are not using the primary superblock/GDT copy don't resize,775775- * because the user tools have no way of handling this. Probably a776776- * bad time to do it anyways.777777- */778778- if (EXT4_SB(sb)->s_sbh->b_blocknr !=779779- le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {780780- ext4_warning(sb, "won't resize using backup superblock at %llu",781781- (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);782782- return -EPERM;783783- }784760785761 gdb_bh = sb_bread(sb, gdblock);786762 if (!gdb_bh)
+1-1
fs/ext4/super.c
···34823482 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,34833483 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&34843484 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM))34853485- ext4_warning(sb, KERN_INFO "metadata_csum and uninit_bg are "34853485+ ext4_warning(sb, "metadata_csum and uninit_bg are "34863486 "redundant flags; please run fsck.");3487348734883488 /* Check for a known checksum algorithm */
+3-2
fs/fcntl.c
···740740 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY741741 * is defined as O_NONBLOCK on some platforms and not on others.742742 */743743- BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(743743+ BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(744744 O_RDONLY | O_WRONLY | O_RDWR |745745 O_CREAT | O_EXCL | O_NOCTTY |746746 O_TRUNC | O_APPEND | /* O_NONBLOCK | */747747 __O_SYNC | O_DSYNC | FASYNC |748748 O_DIRECT | O_LARGEFILE | O_DIRECTORY |749749 O_NOFOLLOW | O_NOATIME | O_CLOEXEC |750750- __FMODE_EXEC | O_PATH | __O_TMPFILE750750+ __FMODE_EXEC | O_PATH | __O_TMPFILE |751751+ __FMODE_NONOTIFY751752 ));752753753754 fasync_cache = kmem_cache_create("fasync_cache",
+49-2
fs/fuse/dev.c
···131131 req->in.h.pid = current->pid;132132}133133134134+void fuse_set_initialized(struct fuse_conn *fc)135135+{136136+ /* Make sure stores before this are seen on another CPU */137137+ smp_wmb();138138+ fc->initialized = 1;139139+}140140+134141static bool fuse_block_alloc(struct fuse_conn *fc, bool for_background)135142{136143 return !fc->initialized || (for_background && fc->blocked);···162155 if (intr)163156 goto out;164157 }158158+ /* Matches smp_wmb() in fuse_set_initialized() */159159+ smp_rmb();165160166161 err = -ENOTCONN;167162 if (!fc->connected)···262253263254 atomic_inc(&fc->num_waiting);264255 wait_event(fc->blocked_waitq, fc->initialized);256256+ /* Matches smp_wmb() in fuse_set_initialized() */257257+ smp_rmb();265258 req = fuse_request_alloc(0);266259 if (!req)267260 req = get_reserved_req(fc, file);···522511}523512EXPORT_SYMBOL_GPL(fuse_request_send);524513514514+static void fuse_adjust_compat(struct fuse_conn *fc, struct fuse_args *args)515515+{516516+ if (fc->minor < 4 && args->in.h.opcode == FUSE_STATFS)517517+ args->out.args[0].size = FUSE_COMPAT_STATFS_SIZE;518518+519519+ if (fc->minor < 9) {520520+ switch (args->in.h.opcode) {521521+ case FUSE_LOOKUP:522522+ case FUSE_CREATE:523523+ case FUSE_MKNOD:524524+ case FUSE_MKDIR:525525+ case FUSE_SYMLINK:526526+ case FUSE_LINK:527527+ args->out.args[0].size = FUSE_COMPAT_ENTRY_OUT_SIZE;528528+ break;529529+ case FUSE_GETATTR:530530+ case FUSE_SETATTR:531531+ args->out.args[0].size = FUSE_COMPAT_ATTR_OUT_SIZE;532532+ break;533533+ }534534+ }535535+ if (fc->minor < 12) {536536+ switch (args->in.h.opcode) {537537+ case FUSE_CREATE:538538+ args->in.args[0].size = sizeof(struct fuse_open_in);539539+ break;540540+ case FUSE_MKNOD:541541+ args->in.args[0].size = FUSE_COMPAT_MKNOD_IN_SIZE;542542+ break;543543+ }544544+ }545545+}546546+525547ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args)526548{527549 struct fuse_req *req;···563519 req = fuse_get_req(fc, 0);564520 if (IS_ERR(req))565521 return PTR_ERR(req);522522+523523+ /* Needs to be done after fuse_get_req() so that fc->minor is valid */524524+ fuse_adjust_compat(fc, args);566525567526 req->in.h.opcode = args->in.h.opcode;568527 req->in.h.nodeid = args->in.h.nodeid;···21742127 if (fc->connected) {21752128 fc->connected = 0;21762129 fc->blocked = 0;21772177- fc->initialized = 1;21302130+ fuse_set_initialized(fc);21782131 end_io_requests(fc);21792132 end_queued_requests(fc);21802133 end_polls(fc);···21932146 spin_lock(&fc->lock);21942147 fc->connected = 0;21952148 fc->blocked = 0;21962196- fc->initialized = 1;21492149+ fuse_set_initialized(fc);21972150 end_queued_requests(fc);21982151 end_polls(fc);21992152 wake_up_all(&fc->blocked_waitq);
···157157int leases_enable = 1;158158int lease_break_time = 45;159159160160-#define for_each_lock(inode, lockp) \161161- for (lockp = &inode->i_flock; *lockp != NULL; lockp = &(*lockp)->fl_next)162162-163160/*164161 * The global file_lock_list is only used for displaying /proc/locks, so we165162 * keep a list on each CPU, with each list protected by its own spinlock via166163 * the file_lock_lglock. Note that alterations to the list also require that167167- * the relevant i_lock is held.164164+ * the relevant flc_lock is held.168165 */169166DEFINE_STATIC_LGLOCK(file_lock_lglock);170167static DEFINE_PER_CPU(struct hlist_head, file_lock_list);···189192 * contrast to those that are acting as records of acquired locks).190193 *191194 * Note that when we acquire this lock in order to change the above fields,192192- * we often hold the i_lock as well. In certain cases, when reading the fields195195+ * we often hold the flc_lock as well. In certain cases, when reading the fields193196 * protected by this lock, we can skip acquiring it iff we already hold the194194- * i_lock.197197+ * flc_lock.195198 *196199 * In particular, adding an entry to the fl_block list requires that you hold197197- * both the i_lock and the blocked_lock_lock (acquired in that order). Deleting198198- * an entry from the list however only requires the file_lock_lock.200200+ * both the flc_lock and the blocked_lock_lock (acquired in that order).201201+ * Deleting an entry from the list however only requires the file_lock_lock.199202 */200203static DEFINE_SPINLOCK(blocked_lock_lock);201204205205+static struct kmem_cache *flctx_cache __read_mostly;202206static struct kmem_cache *filelock_cache __read_mostly;207207+208208+static struct file_lock_context *209209+locks_get_lock_context(struct inode *inode)210210+{211211+ struct file_lock_context *new;212212+213213+ if (likely(inode->i_flctx))214214+ goto out;215215+216216+ new = kmem_cache_alloc(flctx_cache, GFP_KERNEL);217217+ if (!new)218218+ goto out;219219+220220+ spin_lock_init(&new->flc_lock);221221+ INIT_LIST_HEAD(&new->flc_flock);222222+ INIT_LIST_HEAD(&new->flc_posix);223223+ INIT_LIST_HEAD(&new->flc_lease);224224+225225+ /*226226+ * Assign the pointer if it's not already assigned. If it is, then227227+ * free the context we just allocated.228228+ */229229+ spin_lock(&inode->i_lock);230230+ if (likely(!inode->i_flctx)) {231231+ inode->i_flctx = new;232232+ new = NULL;233233+ }234234+ spin_unlock(&inode->i_lock);235235+236236+ if (new)237237+ kmem_cache_free(flctx_cache, new);238238+out:239239+ return inode->i_flctx;240240+}241241+242242+void243243+locks_free_lock_context(struct file_lock_context *ctx)244244+{245245+ if (ctx) {246246+ WARN_ON_ONCE(!list_empty(&ctx->flc_flock));247247+ WARN_ON_ONCE(!list_empty(&ctx->flc_posix));248248+ WARN_ON_ONCE(!list_empty(&ctx->flc_lease));249249+ kmem_cache_free(flctx_cache, ctx);250250+ }251251+}203252204253static void locks_init_lock_heads(struct file_lock *fl)205254{206255 INIT_HLIST_NODE(&fl->fl_link);256256+ INIT_LIST_HEAD(&fl->fl_list);207257 INIT_LIST_HEAD(&fl->fl_block);208258 init_waitqueue_head(&fl->fl_wait);209259}···287243void locks_free_lock(struct file_lock *fl)288244{289245 BUG_ON(waitqueue_active(&fl->fl_wait));246246+ BUG_ON(!list_empty(&fl->fl_list));290247 BUG_ON(!list_empty(&fl->fl_block));291248 BUG_ON(!hlist_unhashed(&fl->fl_link));292249···302257 struct file_lock *fl;303258304259 while (!list_empty(dispose)) {305305- fl = list_first_entry(dispose, struct file_lock, fl_block);306306- list_del_init(&fl->fl_block);260260+ fl = list_first_entry(dispose, struct file_lock, fl_list);261261+ list_del_init(&fl->fl_list);307262 locks_free_lock(fl);308263 }309264}···558513 return fl1->fl_owner == fl2->fl_owner;559514}560515561561-/* Must be called with the i_lock held! */516516+/* Must be called with the flc_lock held! */562517static void locks_insert_global_locks(struct file_lock *fl)563518{564519 lg_local_lock(&file_lock_lglock);···567522 lg_local_unlock(&file_lock_lglock);568523}569524570570-/* Must be called with the i_lock held! */525525+/* Must be called with the flc_lock held! */571526static void locks_delete_global_locks(struct file_lock *fl)572527{573528 /*574529 * Avoid taking lock if already unhashed. This is safe since this check575575- * is done while holding the i_lock, and new insertions into the list530530+ * is done while holding the flc_lock, and new insertions into the list576531 * also require that it be held.577532 */578533 if (hlist_unhashed(&fl->fl_link))···624579 * the order they blocked. The documentation doesn't require this but625580 * it seems like the reasonable thing to do.626581 *627627- * Must be called with both the i_lock and blocked_lock_lock held. The fl_block628628- * list itself is protected by the blocked_lock_lock, but by ensuring that the629629- * i_lock is also held on insertions we can avoid taking the blocked_lock_lock630630- * in some cases when we see that the fl_block list is empty.582582+ * Must be called with both the flc_lock and blocked_lock_lock held. The583583+ * fl_block list itself is protected by the blocked_lock_lock, but by ensuring584584+ * that the flc_lock is also held on insertions we can avoid taking the585585+ * blocked_lock_lock in some cases when we see that the fl_block list is empty.631586 */632587static void __locks_insert_block(struct file_lock *blocker,633588 struct file_lock *waiter)···639594 locks_insert_global_blocked(waiter);640595}641596642642-/* Must be called with i_lock held. */597597+/* Must be called with flc_lock held. */643598static void locks_insert_block(struct file_lock *blocker,644599 struct file_lock *waiter)645600{···651606/*652607 * Wake up processes blocked waiting for blocker.653608 *654654- * Must be called with the inode->i_lock held!609609+ * Must be called with the inode->flc_lock held!655610 */656611static void locks_wake_up_blocks(struct file_lock *blocker)657612{658613 /*659614 * Avoid taking global lock if list is empty. This is safe since new660660- * blocked requests are only added to the list under the i_lock, and661661- * the i_lock is always held here. Note that removal from the fl_block662662- * list does not require the i_lock, so we must recheck list_empty()615615+ * blocked requests are only added to the list under the flc_lock, and616616+ * the flc_lock is always held here. Note that removal from the fl_block617617+ * list does not require the flc_lock, so we must recheck list_empty()663618 * after acquiring the blocked_lock_lock.664619 */665620 if (list_empty(&blocker->fl_block))···680635 spin_unlock(&blocked_lock_lock);681636}682637683683-/* Insert file lock fl into an inode's lock list at the position indicated684684- * by pos. At the same time add the lock to the global file lock list.685685- *686686- * Must be called with the i_lock held!687687- */688688-static void locks_insert_lock(struct file_lock **pos, struct file_lock *fl)638638+static void639639+locks_insert_lock_ctx(struct file_lock *fl, int *counter,640640+ struct list_head *before)689641{690642 fl->fl_nspid = get_pid(task_tgid(current));691691-692692- /* insert into file's list */693693- fl->fl_next = *pos;694694- *pos = fl;695695-643643+ list_add_tail(&fl->fl_list, before);644644+ ++*counter;696645 locks_insert_global_locks(fl);697646}698647699699-/**700700- * locks_delete_lock - Delete a lock and then free it.701701- * @thisfl_p: pointer that points to the fl_next field of the previous702702- * inode->i_flock list entry703703- *704704- * Unlink a lock from all lists and free the namespace reference, but don't705705- * free it yet. Wake up processes that are blocked waiting for this lock and706706- * notify the FS that the lock has been cleared.707707- *708708- * Must be called with the i_lock held!709709- */710710-static void locks_unlink_lock(struct file_lock **thisfl_p)648648+static void649649+locks_unlink_lock_ctx(struct file_lock *fl, int *counter)711650{712712- struct file_lock *fl = *thisfl_p;713713-714651 locks_delete_global_locks(fl);715715-716716- *thisfl_p = fl->fl_next;717717- fl->fl_next = NULL;718718-652652+ list_del_init(&fl->fl_list);653653+ --*counter;719654 if (fl->fl_nspid) {720655 put_pid(fl->fl_nspid);721656 fl->fl_nspid = NULL;722657 }723723-724658 locks_wake_up_blocks(fl);725659}726660727727-/*728728- * Unlink a lock from all lists and free it.729729- *730730- * Must be called with i_lock held!731731- */732732-static void locks_delete_lock(struct file_lock **thisfl_p,733733- struct list_head *dispose)661661+static void662662+locks_delete_lock_ctx(struct file_lock *fl, int *counter,663663+ struct list_head *dispose)734664{735735- struct file_lock *fl = *thisfl_p;736736-737737- locks_unlink_lock(thisfl_p);665665+ locks_unlink_lock_ctx(fl, counter);738666 if (dispose)739739- list_add(&fl->fl_block, dispose);667667+ list_add(&fl->fl_list, dispose);740668 else741669 locks_free_lock(fl);742670}···764746posix_test_lock(struct file *filp, struct file_lock *fl)765747{766748 struct file_lock *cfl;749749+ struct file_lock_context *ctx;767750 struct inode *inode = file_inode(filp);768751769769- spin_lock(&inode->i_lock);770770- for (cfl = file_inode(filp)->i_flock; cfl; cfl = cfl->fl_next) {771771- if (!IS_POSIX(cfl))772772- continue;773773- if (posix_locks_conflict(fl, cfl))774774- break;775775- }776776- if (cfl) {777777- locks_copy_conflock(fl, cfl);778778- if (cfl->fl_nspid)779779- fl->fl_pid = pid_vnr(cfl->fl_nspid);780780- } else752752+ ctx = inode->i_flctx;753753+ if (!ctx || list_empty_careful(&ctx->flc_posix)) {781754 fl->fl_type = F_UNLCK;782782- spin_unlock(&inode->i_lock);755755+ return;756756+ }757757+758758+ spin_lock(&ctx->flc_lock);759759+ list_for_each_entry(cfl, &ctx->flc_posix, fl_list) {760760+ if (posix_locks_conflict(fl, cfl)) {761761+ locks_copy_conflock(fl, cfl);762762+ if (cfl->fl_nspid)763763+ fl->fl_pid = pid_vnr(cfl->fl_nspid);764764+ goto out;765765+ }766766+ }767767+ fl->fl_type = F_UNLCK;768768+out:769769+ spin_unlock(&ctx->flc_lock);783770 return;784771}785772EXPORT_SYMBOL(posix_test_lock);···868845static int flock_lock_file(struct file *filp, struct file_lock *request)869846{870847 struct file_lock *new_fl = NULL;871871- struct file_lock **before;872872- struct inode * inode = file_inode(filp);848848+ struct file_lock *fl;849849+ struct file_lock_context *ctx;850850+ struct inode *inode = file_inode(filp);873851 int error = 0;874874- int found = 0;852852+ bool found = false;875853 LIST_HEAD(dispose);854854+855855+ ctx = locks_get_lock_context(inode);856856+ if (!ctx)857857+ return -ENOMEM;876858877859 if (!(request->fl_flags & FL_ACCESS) && (request->fl_type != F_UNLCK)) {878860 new_fl = locks_alloc_lock();···885857 return -ENOMEM;886858 }887859888888- spin_lock(&inode->i_lock);860860+ spin_lock(&ctx->flc_lock);889861 if (request->fl_flags & FL_ACCESS)890862 goto find_conflict;891863892892- for_each_lock(inode, before) {893893- struct file_lock *fl = *before;894894- if (IS_POSIX(fl))895895- break;896896- if (IS_LEASE(fl))897897- continue;864864+ list_for_each_entry(fl, &ctx->flc_flock, fl_list) {898865 if (filp != fl->fl_file)899866 continue;900867 if (request->fl_type == fl->fl_type)901868 goto out;902902- found = 1;903903- locks_delete_lock(before, &dispose);869869+ found = true;870870+ locks_delete_lock_ctx(fl, &ctx->flc_flock_cnt, &dispose);904871 break;905872 }906873···910887 * give it the opportunity to lock the file.911888 */912889 if (found) {913913- spin_unlock(&inode->i_lock);890890+ spin_unlock(&ctx->flc_lock);914891 cond_resched();915915- spin_lock(&inode->i_lock);892892+ spin_lock(&ctx->flc_lock);916893 }917894918895find_conflict:919919- for_each_lock(inode, before) {920920- struct file_lock *fl = *before;921921- if (IS_POSIX(fl))922922- break;923923- if (IS_LEASE(fl))924924- continue;896896+ list_for_each_entry(fl, &ctx->flc_flock, fl_list) {925897 if (!flock_locks_conflict(request, fl))926898 continue;927899 error = -EAGAIN;···929911 if (request->fl_flags & FL_ACCESS)930912 goto out;931913 locks_copy_lock(new_fl, request);932932- locks_insert_lock(before, new_fl);914914+ locks_insert_lock_ctx(new_fl, &ctx->flc_flock_cnt, &ctx->flc_flock);933915 new_fl = NULL;934916 error = 0;935917936918out:937937- spin_unlock(&inode->i_lock);919919+ spin_unlock(&ctx->flc_lock);938920 if (new_fl)939921 locks_free_lock(new_fl);940922 locks_dispose_list(&dispose);···943925944926static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)945927{946946- struct file_lock *fl;928928+ struct file_lock *fl, *tmp;947929 struct file_lock *new_fl = NULL;948930 struct file_lock *new_fl2 = NULL;949931 struct file_lock *left = NULL;950932 struct file_lock *right = NULL;951951- struct file_lock **before;933933+ struct file_lock_context *ctx;952934 int error;953935 bool added = false;954936 LIST_HEAD(dispose);937937+938938+ ctx = locks_get_lock_context(inode);939939+ if (!ctx)940940+ return -ENOMEM;955941956942 /*957943 * We may need two file_lock structures for this operation,···970948 new_fl2 = locks_alloc_lock();971949 }972950973973- spin_lock(&inode->i_lock);951951+ spin_lock(&ctx->flc_lock);974952 /*975953 * New lock request. Walk all POSIX locks and look for conflicts. If976954 * there are any, either return error or put the request on the977955 * blocker's list of waiters and the global blocked_hash.978956 */979957 if (request->fl_type != F_UNLCK) {980980- for_each_lock(inode, before) {981981- fl = *before;958958+ list_for_each_entry(fl, &ctx->flc_posix, fl_list) {982959 if (!IS_POSIX(fl))983960 continue;984961 if (!posix_locks_conflict(request, fl))···1007986 if (request->fl_flags & FL_ACCESS)1008987 goto out;100998810101010- /*10111011- * Find the first old lock with the same owner as the new lock.10121012- */10131013-10141014- before = &inode->i_flock;10151015-10161016- /* First skip locks owned by other processes. */10171017- while ((fl = *before) && (!IS_POSIX(fl) ||10181018- !posix_same_owner(request, fl))) {10191019- before = &fl->fl_next;989989+ /* Find the first old lock with the same owner as the new lock */990990+ list_for_each_entry(fl, &ctx->flc_posix, fl_list) {991991+ if (posix_same_owner(request, fl))992992+ break;1020993 }10219941022995 /* Process locks with this owner. */10231023- while ((fl = *before) && posix_same_owner(request, fl)) {10241024- /* Detect adjacent or overlapping regions (if same lock type)10251025- */996996+ list_for_each_entry_safe_from(fl, tmp, &ctx->flc_posix, fl_list) {997997+ if (!posix_same_owner(request, fl))998998+ break;999999+10001000+ /* Detect adjacent or overlapping regions (if same lock type) */10261001 if (request->fl_type == fl->fl_type) {10271002 /* In all comparisons of start vs end, use10281003 * "start - 1" rather than "end + 1". If end10291004 * is OFFSET_MAX, end + 1 will become negative.10301005 */10311006 if (fl->fl_end < request->fl_start - 1)10321032- goto next_lock;10071007+ continue;10331008 /* If the next lock in the list has entirely bigger10341009 * addresses than the new one, insert the lock here.10351010 */···10461029 else10471030 request->fl_end = fl->fl_end;10481031 if (added) {10491049- locks_delete_lock(before, &dispose);10321032+ locks_delete_lock_ctx(fl, &ctx->flc_posix_cnt,10331033+ &dispose);10501034 continue;10511035 }10521036 request = fl;10531037 added = true;10541054- }10551055- else {10381038+ } else {10561039 /* Processing for different lock types is a bit10571040 * more complex.10581041 */10591042 if (fl->fl_end < request->fl_start)10601060- goto next_lock;10431043+ continue;10611044 if (fl->fl_start > request->fl_end)10621045 break;10631046 if (request->fl_type == F_UNLCK)···10761059 * one (This may happen several times).10771060 */10781061 if (added) {10791079- locks_delete_lock(before, &dispose);10621062+ locks_delete_lock_ctx(fl,10631063+ &ctx->flc_posix_cnt, &dispose);10801064 continue;10811065 }10821066 /*···10931075 locks_copy_lock(new_fl, request);10941076 request = new_fl;10951077 new_fl = NULL;10961096- locks_delete_lock(before, &dispose);10971097- locks_insert_lock(before, request);10781078+ locks_insert_lock_ctx(request,10791079+ &ctx->flc_posix_cnt, &fl->fl_list);10801080+ locks_delete_lock_ctx(fl,10811081+ &ctx->flc_posix_cnt, &dispose);10981082 added = true;10991083 }11001084 }11011101- /* Go on to next lock.11021102- */11031103- next_lock:11041104- before = &fl->fl_next;11051085 }1106108611071087 /*···11241108 goto out;11251109 }11261110 locks_copy_lock(new_fl, request);11271127- locks_insert_lock(before, new_fl);11111111+ locks_insert_lock_ctx(new_fl, &ctx->flc_posix_cnt,11121112+ &fl->fl_list);11281113 new_fl = NULL;11291114 }11301115 if (right) {···11361119 left = new_fl2;11371120 new_fl2 = NULL;11381121 locks_copy_lock(left, right);11391139- locks_insert_lock(before, left);11221122+ locks_insert_lock_ctx(left, &ctx->flc_posix_cnt,11231123+ &fl->fl_list);11401124 }11411125 right->fl_start = request->fl_end + 1;11421126 locks_wake_up_blocks(right);···11471129 locks_wake_up_blocks(left);11481130 }11491131 out:11501150- spin_unlock(&inode->i_lock);11321132+ spin_unlock(&ctx->flc_lock);11511133 /*11521134 * Free any unused locks.11531135 */···12171199 */12181200int locks_mandatory_locked(struct file *file)12191201{12021202+ int ret;12201203 struct inode *inode = file_inode(file);12041204+ struct file_lock_context *ctx;12211205 struct file_lock *fl;12061206+12071207+ ctx = inode->i_flctx;12081208+ if (!ctx || list_empty_careful(&ctx->flc_posix))12091209+ return 0;1222121012231211 /*12241212 * Search the lock list for this inode for any POSIX locks.12251213 */12261226- spin_lock(&inode->i_lock);12271227- for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {12281228- if (!IS_POSIX(fl))12291229- continue;12141214+ spin_lock(&ctx->flc_lock);12151215+ ret = 0;12161216+ list_for_each_entry(fl, &ctx->flc_posix, fl_list) {12301217 if (fl->fl_owner != current->files &&12311231- fl->fl_owner != file)12181218+ fl->fl_owner != file) {12191219+ ret = -EAGAIN;12321220 break;12211221+ }12331222 }12341234- spin_unlock(&inode->i_lock);12351235- return fl ? -EAGAIN : 0;12231223+ spin_unlock(&ctx->flc_lock);12241224+ return ret;12361225}1237122612381227/**···13191294}1320129513211296/* We already had a lease on this file; just change its type */13221322-int lease_modify(struct file_lock **before, int arg, struct list_head *dispose)12971297+int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose)13231298{13241324- struct file_lock *fl = *before;12991299+ struct file_lock_context *flctx;13251300 int error = assign_type(fl, arg);1326130113271302 if (error)···13311306 if (arg == F_UNLCK) {13321307 struct file *filp = fl->fl_file;1333130813091309+ flctx = file_inode(filp)->i_flctx;13341310 f_delown(filp);13351311 filp->f_owner.signum = 0;13361312 fasync_helper(0, fl->fl_file, 0, &fl->fl_fasync);···13391313 printk(KERN_ERR "locks_delete_lock: fasync == %p\n", fl->fl_fasync);13401314 fl->fl_fasync = NULL;13411315 }13421342- locks_delete_lock(before, dispose);13161316+ locks_delete_lock_ctx(fl, &flctx->flc_lease_cnt, dispose);13431317 }13441318 return 0;13451319}···1355132913561330static void time_out_leases(struct inode *inode, struct list_head *dispose)13571331{13581358- struct file_lock **before;13591359- struct file_lock *fl;13321332+ struct file_lock_context *ctx = inode->i_flctx;13331333+ struct file_lock *fl, *tmp;1360133413611361- lockdep_assert_held(&inode->i_lock);13351335+ lockdep_assert_held(&ctx->flc_lock);1362133613631363- before = &inode->i_flock;13641364- while ((fl = *before) && IS_LEASE(fl) && lease_breaking(fl)) {13371337+ list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) {13651338 trace_time_out_leases(inode, fl);13661339 if (past_time(fl->fl_downgrade_time))13671367- lease_modify(before, F_RDLCK, dispose);13401340+ lease_modify(fl, F_RDLCK, dispose);13681341 if (past_time(fl->fl_break_time))13691369- lease_modify(before, F_UNLCK, dispose);13701370- if (fl == *before) /* lease_modify may have freed fl */13711371- before = &fl->fl_next;13421342+ lease_modify(fl, F_UNLCK, dispose);13721343 }13731344}13741345···13791356static bool13801357any_leases_conflict(struct inode *inode, struct file_lock *breaker)13811358{13591359+ struct file_lock_context *ctx = inode->i_flctx;13821360 struct file_lock *fl;1383136113841384- lockdep_assert_held(&inode->i_lock);13621362+ lockdep_assert_held(&ctx->flc_lock);1385136313861386- for (fl = inode->i_flock ; fl && IS_LEASE(fl); fl = fl->fl_next) {13641364+ list_for_each_entry(fl, &ctx->flc_lease, fl_list) {13871365 if (leases_conflict(fl, breaker))13881366 return true;13891367 }···14081384{14091385 int error = 0;14101386 struct file_lock *new_fl;14111411- struct file_lock *fl, **before;13871387+ struct file_lock_context *ctx = inode->i_flctx;13881388+ struct file_lock *fl;14121389 unsigned long break_time;14131390 int want_write = (mode & O_ACCMODE) != O_RDONLY;14141391 LIST_HEAD(dispose);···14191394 return PTR_ERR(new_fl);14201395 new_fl->fl_flags = type;1421139614221422- spin_lock(&inode->i_lock);13971397+ /* typically we will check that ctx is non-NULL before calling */13981398+ if (!ctx) {13991399+ WARN_ON_ONCE(1);14001400+ return error;14011401+ }14021402+14031403+ spin_lock(&ctx->flc_lock);1423140414241405 time_out_leases(inode, &dispose);14251406···14391408 break_time++; /* so that 0 means no break time */14401409 }1441141014421442- for (before = &inode->i_flock;14431443- ((fl = *before) != NULL) && IS_LEASE(fl);14441444- before = &fl->fl_next) {14111411+ list_for_each_entry(fl, &ctx->flc_lease, fl_list) {14451412 if (!leases_conflict(fl, new_fl))14461413 continue;14471414 if (want_write) {···14481419 fl->fl_flags |= FL_UNLOCK_PENDING;14491420 fl->fl_break_time = break_time;14501421 } else {14511451- if (lease_breaking(inode->i_flock))14221422+ if (lease_breaking(fl))14521423 continue;14531424 fl->fl_flags |= FL_DOWNGRADE_PENDING;14541425 fl->fl_downgrade_time = break_time;14551426 }14561427 if (fl->fl_lmops->lm_break(fl))14571457- locks_delete_lock(before, &dispose);14281428+ locks_delete_lock_ctx(fl, &ctx->flc_lease_cnt,14291429+ &dispose);14581430 }1459143114601460- fl = inode->i_flock;14611461- if (!fl || !IS_LEASE(fl))14321432+ if (list_empty(&ctx->flc_lease))14621433 goto out;1463143414641435 if (mode & O_NONBLOCK) {···14681439 }1469144014701441restart:14711471- break_time = inode->i_flock->fl_break_time;14421442+ fl = list_first_entry(&ctx->flc_lease, struct file_lock, fl_list);14431443+ break_time = fl->fl_break_time;14721444 if (break_time != 0)14731445 break_time -= jiffies;14741446 if (break_time == 0)14751447 break_time++;14761476- locks_insert_block(inode->i_flock, new_fl);14481448+ locks_insert_block(fl, new_fl);14771449 trace_break_lease_block(inode, new_fl);14781478- spin_unlock(&inode->i_lock);14501450+ spin_unlock(&ctx->flc_lock);14791451 locks_dispose_list(&dispose);14801452 error = wait_event_interruptible_timeout(new_fl->fl_wait,14811453 !new_fl->fl_next, break_time);14821482- spin_lock(&inode->i_lock);14541454+ spin_lock(&ctx->flc_lock);14831455 trace_break_lease_unblock(inode, new_fl);14841456 locks_delete_block(new_fl);14851457 if (error >= 0) {···14921462 time_out_leases(inode, &dispose);14931463 if (any_leases_conflict(inode, new_fl))14941464 goto restart;14951495-14961465 error = 0;14971466 }14981498-14991467out:15001500- spin_unlock(&inode->i_lock);14681468+ spin_unlock(&ctx->flc_lock);15011469 locks_dispose_list(&dispose);15021470 locks_free_lock(new_fl);15031471 return error;···15151487void lease_get_mtime(struct inode *inode, struct timespec *time)15161488{15171489 bool has_lease = false;15181518- struct file_lock *flock;14901490+ struct file_lock_context *ctx = inode->i_flctx;14911491+ struct file_lock *fl;1519149215201520- if (inode->i_flock) {15211521- spin_lock(&inode->i_lock);15221522- flock = inode->i_flock;15231523- if (flock && IS_LEASE(flock) && (flock->fl_type == F_WRLCK))15241524- has_lease = true;15251525- spin_unlock(&inode->i_lock);14931493+ if (ctx && !list_empty_careful(&ctx->flc_lease)) {14941494+ spin_lock(&ctx->flc_lock);14951495+ if (!list_empty(&ctx->flc_lease)) {14961496+ fl = list_first_entry(&ctx->flc_lease,14971497+ struct file_lock, fl_list);14981498+ if (fl->fl_type == F_WRLCK)14991499+ has_lease = true;15001500+ }15011501+ spin_unlock(&ctx->flc_lock);15261502 }1527150315281504 if (has_lease)···15641532{15651533 struct file_lock *fl;15661534 struct inode *inode = file_inode(filp);15351535+ struct file_lock_context *ctx = inode->i_flctx;15671536 int type = F_UNLCK;15681537 LIST_HEAD(dispose);1569153815701570- spin_lock(&inode->i_lock);15711571- time_out_leases(file_inode(filp), &dispose);15721572- for (fl = file_inode(filp)->i_flock; fl && IS_LEASE(fl);15731573- fl = fl->fl_next) {15741574- if (fl->fl_file == filp) {15391539+ if (ctx && !list_empty_careful(&ctx->flc_lease)) {15401540+ spin_lock(&ctx->flc_lock);15411541+ time_out_leases(file_inode(filp), &dispose);15421542+ list_for_each_entry(fl, &ctx->flc_lease, fl_list) {15431543+ if (fl->fl_file != filp)15441544+ continue;15751545 type = target_leasetype(fl);15761546 break;15771547 }15481548+ spin_unlock(&ctx->flc_lock);15491549+ locks_dispose_list(&dispose);15781550 }15791579- spin_unlock(&inode->i_lock);15801580- locks_dispose_list(&dispose);15811551 return type;15821552}15831553···16121578static int16131579generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **priv)16141580{16151615- struct file_lock *fl, **before, **my_before = NULL, *lease;15811581+ struct file_lock *fl, *my_fl = NULL, *lease;16161582 struct dentry *dentry = filp->f_path.dentry;16171583 struct inode *inode = dentry->d_inode;15841584+ struct file_lock_context *ctx;16181585 bool is_deleg = (*flp)->fl_flags & FL_DELEG;16191586 int error;16201587 LIST_HEAD(dispose);1621158816221589 lease = *flp;16231590 trace_generic_add_lease(inode, lease);15911591+15921592+ ctx = locks_get_lock_context(inode);15931593+ if (!ctx)15941594+ return -ENOMEM;1624159516251596 /*16261597 * In the delegation case we need mutual exclusion with···16451606 return -EINVAL;16461607 }1647160816481648- spin_lock(&inode->i_lock);16091609+ spin_lock(&ctx->flc_lock);16491610 time_out_leases(inode, &dispose);16501611 error = check_conflicting_open(dentry, arg);16511612 if (error)···16601621 * except for this filp.16611622 */16621623 error = -EAGAIN;16631663- for (before = &inode->i_flock;16641664- ((fl = *before) != NULL) && IS_LEASE(fl);16651665- before = &fl->fl_next) {16241624+ list_for_each_entry(fl, &ctx->flc_lease, fl_list) {16661625 if (fl->fl_file == filp) {16671667- my_before = before;16261626+ my_fl = fl;16681627 continue;16691628 }16291629+16701630 /*16711631 * No exclusive leases if someone else has a lease on16721632 * this file:···16801642 goto out;16811643 }1682164416831683- if (my_before != NULL) {16841684- lease = *my_before;16851685- error = lease->fl_lmops->lm_change(my_before, arg, &dispose);16451645+ if (my_fl != NULL) {16461646+ error = lease->fl_lmops->lm_change(my_fl, arg, &dispose);16861647 if (error)16871648 goto out;16881649 goto out_setup;···16911654 if (!leases_enable)16921655 goto out;1693165616941694- locks_insert_lock(before, lease);16571657+ locks_insert_lock_ctx(lease, &ctx->flc_lease_cnt, &ctx->flc_lease);16951658 /*16961659 * The check in break_lease() is lockless. It's possible for another16971660 * open to race in after we did the earlier check for a conflicting···17031666 */17041667 smp_mb();17051668 error = check_conflicting_open(dentry, arg);17061706- if (error)17071707- goto out_unlink;16691669+ if (error) {16701670+ locks_unlink_lock_ctx(lease, &ctx->flc_lease_cnt);16711671+ goto out;16721672+ }1708167317091674out_setup:17101675 if (lease->fl_lmops->lm_setup)17111676 lease->fl_lmops->lm_setup(lease, priv);17121677out:17131713- spin_unlock(&inode->i_lock);16781678+ spin_unlock(&ctx->flc_lock);17141679 locks_dispose_list(&dispose);17151680 if (is_deleg)17161681 mutex_unlock(&inode->i_mutex);17171717- if (!error && !my_before)16821682+ if (!error && !my_fl)17181683 *flp = NULL;17191684 return error;17201720-out_unlink:17211721- locks_unlink_lock(before);17221722- goto out;17231685}1724168617251687static int generic_delete_lease(struct file *filp)17261688{17271689 int error = -EAGAIN;17281728- struct file_lock *fl, **before;16901690+ struct file_lock *fl, *victim = NULL;17291691 struct dentry *dentry = filp->f_path.dentry;17301692 struct inode *inode = dentry->d_inode;16931693+ struct file_lock_context *ctx = inode->i_flctx;17311694 LIST_HEAD(dispose);1732169517331733- spin_lock(&inode->i_lock);17341734- time_out_leases(inode, &dispose);17351735- for (before = &inode->i_flock;17361736- ((fl = *before) != NULL) && IS_LEASE(fl);17371737- before = &fl->fl_next) {17381738- if (fl->fl_file == filp)16961696+ if (!ctx) {16971697+ trace_generic_delete_lease(inode, NULL);16981698+ return error;16991699+ }17001700+17011701+ spin_lock(&ctx->flc_lock);17021702+ list_for_each_entry(fl, &ctx->flc_lease, fl_list) {17031703+ if (fl->fl_file == filp) {17041704+ victim = fl;17391705 break;17061706+ }17401707 }17411708 trace_generic_delete_lease(inode, fl);17421742- if (fl)17431743- error = fl->fl_lmops->lm_change(before, F_UNLCK, &dispose);17441744- spin_unlock(&inode->i_lock);17091709+ if (victim)17101710+ error = fl->fl_lmops->lm_change(victim, F_UNLCK, &dispose);17111711+ spin_unlock(&ctx->flc_lock);17451712 locks_dispose_list(&dispose);17461713 return error;17471714}···22122171 */22132172 /*22142173 * we need that spin_lock here - it prevents reordering between22152215- * update of inode->i_flock and check for it done in close().21742174+ * update of i_flctx->flc_posix and check for it done in close().22162175 * rcu_read_lock() wouldn't do.22172176 */22182177 spin_lock(¤t->files->file_lock);···23722331void locks_remove_posix(struct file *filp, fl_owner_t owner)23732332{23742333 struct file_lock lock;23342334+ struct file_lock_context *ctx = file_inode(filp)->i_flctx;2375233523762336 /*23772337 * If there are no locks held on this file, we don't need to call23782338 * posix_lock_file(). Another process could be setting a lock on this23792339 * file at the same time, but we wouldn't remove that lock anyway.23802340 */23812381- if (!file_inode(filp)->i_flock)23412341+ if (!ctx || list_empty(&ctx->flc_posix))23822342 return;2383234323842344 lock.fl_type = F_UNLCK;···2400235824012359EXPORT_SYMBOL(locks_remove_posix);2402236023612361+/* The i_flctx must be valid when calling into here */23622362+static void23632363+locks_remove_flock(struct file *filp)23642364+{23652365+ struct file_lock fl = {23662366+ .fl_owner = filp,23672367+ .fl_pid = current->tgid,23682368+ .fl_file = filp,23692369+ .fl_flags = FL_FLOCK,23702370+ .fl_type = F_UNLCK,23712371+ .fl_end = OFFSET_MAX,23722372+ };23732373+ struct file_lock_context *flctx = file_inode(filp)->i_flctx;23742374+23752375+ if (list_empty(&flctx->flc_flock))23762376+ return;23772377+23782378+ if (filp->f_op->flock)23792379+ filp->f_op->flock(filp, F_SETLKW, &fl);23802380+ else23812381+ flock_lock_file(filp, &fl);23822382+23832383+ if (fl.fl_ops && fl.fl_ops->fl_release_private)23842384+ fl.fl_ops->fl_release_private(&fl);23852385+}23862386+23872387+/* The i_flctx must be valid when calling into here */23882388+static void23892389+locks_remove_lease(struct file *filp)23902390+{23912391+ struct inode *inode = file_inode(filp);23922392+ struct file_lock_context *ctx = inode->i_flctx;23932393+ struct file_lock *fl, *tmp;23942394+ LIST_HEAD(dispose);23952395+23962396+ if (list_empty(&ctx->flc_lease))23972397+ return;23982398+23992399+ spin_lock(&ctx->flc_lock);24002400+ list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list)24012401+ lease_modify(fl, F_UNLCK, &dispose);24022402+ spin_unlock(&ctx->flc_lock);24032403+ locks_dispose_list(&dispose);24042404+}24052405+24032406/*24042407 * This function is called on the last close of an open file.24052408 */24062409void locks_remove_file(struct file *filp)24072410{24082408- struct inode * inode = file_inode(filp);24092409- struct file_lock *fl;24102410- struct file_lock **before;24112411- LIST_HEAD(dispose);24122412-24132413- if (!inode->i_flock)24112411+ if (!file_inode(filp)->i_flctx)24142412 return;2415241324142414+ /* remove any OFD locks */24162415 locks_remove_posix(filp, filp);2417241624182418- if (filp->f_op->flock) {24192419- struct file_lock fl = {24202420- .fl_owner = filp,24212421- .fl_pid = current->tgid,24222422- .fl_file = filp,24232423- .fl_flags = FL_FLOCK,24242424- .fl_type = F_UNLCK,24252425- .fl_end = OFFSET_MAX,24262426- };24272427- filp->f_op->flock(filp, F_SETLKW, &fl);24282428- if (fl.fl_ops && fl.fl_ops->fl_release_private)24292429- fl.fl_ops->fl_release_private(&fl);24302430- }24172417+ /* remove flock locks */24182418+ locks_remove_flock(filp);2431241924322432- spin_lock(&inode->i_lock);24332433- before = &inode->i_flock;24342434-24352435- while ((fl = *before) != NULL) {24362436- if (fl->fl_file == filp) {24372437- if (IS_LEASE(fl)) {24382438- lease_modify(before, F_UNLCK, &dispose);24392439- continue;24402440- }24412441-24422442- /*24432443- * There's a leftover lock on the list of a type that24442444- * we didn't expect to see. Most likely a classic24452445- * POSIX lock that ended up not getting released24462446- * properly, or that raced onto the list somehow. Log24472447- * some info about it and then just remove it from24482448- * the list.24492449- */24502450- WARN(!IS_FLOCK(fl),24512451- "leftover lock: dev=%u:%u ino=%lu type=%hhd flags=0x%x start=%lld end=%lld\n",24522452- MAJOR(inode->i_sb->s_dev),24532453- MINOR(inode->i_sb->s_dev), inode->i_ino,24542454- fl->fl_type, fl->fl_flags,24552455- fl->fl_start, fl->fl_end);24562456-24572457- locks_delete_lock(before, &dispose);24582458- continue;24592459- }24602460- before = &fl->fl_next;24612461- }24622462- spin_unlock(&inode->i_lock);24632463- locks_dispose_list(&dispose);24202420+ /* remove any leases */24212421+ locks_remove_lease(filp);24642422}2465242324662424/**···26622620static int __init filelock_init(void)26632621{26642622 int i;26232623+26242624+ flctx_cache = kmem_cache_create("file_lock_ctx",26252625+ sizeof(struct file_lock_context), 0, SLAB_PANIC, NULL);2665262626662627 filelock_cache = kmem_cache_create("file_lock_cache",26672628 sizeof(struct file_lock), 0, SLAB_PANIC, NULL);
+14-9
fs/nfs/delegation.c
···8585{8686 struct inode *inode = state->inode;8787 struct file_lock *fl;8888+ struct file_lock_context *flctx = inode->i_flctx;8989+ struct list_head *list;8890 int status = 0;89919090- if (inode->i_flock == NULL)9292+ if (flctx == NULL)9193 goto out;92949393- /* Protect inode->i_flock using the i_lock */9494- spin_lock(&inode->i_lock);9595- for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {9696- if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))9797- continue;9595+ list = &flctx->flc_posix;9696+ spin_lock(&flctx->flc_lock);9797+restart:9898+ list_for_each_entry(fl, list, fl_list) {9899 if (nfs_file_open_context(fl->fl_file) != ctx)99100 continue;100100- spin_unlock(&inode->i_lock);101101+ spin_unlock(&flctx->flc_lock);101102 status = nfs4_lock_delegation_recall(fl, state, stateid);102103 if (status < 0)103104 goto out;104104- spin_lock(&inode->i_lock);105105+ spin_lock(&flctx->flc_lock);105106 }106106- spin_unlock(&inode->i_lock);107107+ if (list == &flctx->flc_posix) {108108+ list = &flctx->flc_flock;109109+ goto restart;110110+ }111111+ spin_unlock(&flctx->flc_lock);107112out:108113 return status;109114}
+38-32
fs/nfs/nfs4state.c
···13661366 struct nfs_inode *nfsi = NFS_I(inode);13671367 struct file_lock *fl;13681368 int status = 0;13691369+ struct file_lock_context *flctx = inode->i_flctx;13701370+ struct list_head *list;1369137113701370- if (inode->i_flock == NULL)13721372+ if (flctx == NULL)13711373 return 0;13741374+13751375+ list = &flctx->flc_posix;1372137613731377 /* Guard against delegation returns and new lock/unlock calls */13741378 down_write(&nfsi->rwsem);13751375- /* Protect inode->i_flock using the BKL */13761376- spin_lock(&inode->i_lock);13771377- for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {13781378- if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))13791379- continue;13791379+ spin_lock(&flctx->flc_lock);13801380+restart:13811381+ list_for_each_entry(fl, list, fl_list) {13801382 if (nfs_file_open_context(fl->fl_file)->state != state)13811383 continue;13821382- spin_unlock(&inode->i_lock);13841384+ spin_unlock(&flctx->flc_lock);13831385 status = ops->recover_lock(state, fl);13841386 switch (status) {13851385- case 0:13861386- break;13871387- case -ESTALE:13881388- case -NFS4ERR_ADMIN_REVOKED:13891389- case -NFS4ERR_STALE_STATEID:13901390- case -NFS4ERR_BAD_STATEID:13911391- case -NFS4ERR_EXPIRED:13921392- case -NFS4ERR_NO_GRACE:13931393- case -NFS4ERR_STALE_CLIENTID:13941394- case -NFS4ERR_BADSESSION:13951395- case -NFS4ERR_BADSLOT:13961396- case -NFS4ERR_BAD_HIGH_SLOT:13971397- case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:13981398- goto out;13991399- default:14001400- printk(KERN_ERR "NFS: %s: unhandled error %d\n",14011401- __func__, status);14021402- case -ENOMEM:14031403- case -NFS4ERR_DENIED:14041404- case -NFS4ERR_RECLAIM_BAD:14051405- case -NFS4ERR_RECLAIM_CONFLICT:14061406- /* kill_proc(fl->fl_pid, SIGLOST, 1); */14071407- status = 0;13871387+ case 0:13881388+ break;13891389+ case -ESTALE:13901390+ case -NFS4ERR_ADMIN_REVOKED:13911391+ case -NFS4ERR_STALE_STATEID:13921392+ case -NFS4ERR_BAD_STATEID:13931393+ case -NFS4ERR_EXPIRED:13941394+ case -NFS4ERR_NO_GRACE:13951395+ case -NFS4ERR_STALE_CLIENTID:13961396+ case -NFS4ERR_BADSESSION:13971397+ case -NFS4ERR_BADSLOT:13981398+ case -NFS4ERR_BAD_HIGH_SLOT:13991399+ case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:14001400+ goto out;14011401+ default:14021402+ pr_err("NFS: %s: unhandled error %d\n",14031403+ __func__, status);14041404+ case -ENOMEM:14051405+ case -NFS4ERR_DENIED:14061406+ case -NFS4ERR_RECLAIM_BAD:14071407+ case -NFS4ERR_RECLAIM_CONFLICT:14081408+ /* kill_proc(fl->fl_pid, SIGLOST, 1); */14091409+ status = 0;14081410 }14091409- spin_lock(&inode->i_lock);14111411+ spin_lock(&flctx->flc_lock);14101412 }14111411- spin_unlock(&inode->i_lock);14131413+ if (list == &flctx->flc_posix) {14141414+ list = &flctx->flc_flock;14151415+ goto restart;14161416+ }14171417+ spin_unlock(&flctx->flc_lock);14121418out:14131419 up_write(&nfsi->rwsem);14141420 return status;
+5-1
fs/nfs/pagelist.c
···826826 struct nfs_pageio_descriptor *pgio)827827{828828 size_t size;829829+ struct file_lock_context *flctx;829830830831 if (prev) {831832 if (!nfs_match_open_context(req->wb_context, prev->wb_context))832833 return false;833833- if (req->wb_context->dentry->d_inode->i_flock != NULL &&834834+ flctx = req->wb_context->dentry->d_inode->i_flctx;835835+ if (flctx != NULL &&836836+ !(list_empty_careful(&flctx->flc_posix) &&837837+ list_empty_careful(&flctx->flc_flock)) &&834838 !nfs_match_lock_context(req->wb_lock_context,835839 prev->wb_lock_context))836840 return false;
+35-6
fs/nfs/write.c
···10911091{10921092 struct nfs_open_context *ctx = nfs_file_open_context(file);10931093 struct nfs_lock_context *l_ctx;10941094+ struct file_lock_context *flctx = file_inode(file)->i_flctx;10941095 struct nfs_page *req;10951096 int do_flush, status;10961097 /*···11101109 do_flush = req->wb_page != page || req->wb_context != ctx;11111110 /* for now, flush if more than 1 request in page_group */11121111 do_flush |= req->wb_this_page != req;11131113- if (l_ctx && ctx->dentry->d_inode->i_flock != NULL) {11121112+ if (l_ctx && flctx &&11131113+ !(list_empty_careful(&flctx->flc_posix) &&11141114+ list_empty_careful(&flctx->flc_flock))) {11141115 do_flush |= l_ctx->lockowner.l_owner != current->files11151116 || l_ctx->lockowner.l_pid != current->tgid;11161117 }···11731170 return PageUptodate(page) != 0;11741171}1175117211731173+static bool11741174+is_whole_file_wrlock(struct file_lock *fl)11751175+{11761176+ return fl->fl_start == 0 && fl->fl_end == OFFSET_MAX &&11771177+ fl->fl_type == F_WRLCK;11781178+}11791179+11761180/* If we know the page is up to date, and we're not using byte range locks (or11771181 * if we have the whole file locked for writing), it may be more efficient to11781182 * extend the write to cover the entire page in order to avoid fragmentation···11901180 */11911181static int nfs_can_extend_write(struct file *file, struct page *page, struct inode *inode)11921182{11831183+ int ret;11841184+ struct file_lock_context *flctx = inode->i_flctx;11851185+ struct file_lock *fl;11861186+11931187 if (file->f_flags & O_DSYNC)11941188 return 0;11951189 if (!nfs_write_pageuptodate(page, inode))11961190 return 0;11971191 if (NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE))11981192 return 1;11991199- if (inode->i_flock == NULL || (inode->i_flock->fl_start == 0 &&12001200- inode->i_flock->fl_end == OFFSET_MAX &&12011201- inode->i_flock->fl_type != F_RDLCK))12021202- return 1;12031203- return 0;11931193+ if (!flctx || (list_empty_careful(&flctx->flc_flock) &&11941194+ list_empty_careful(&flctx->flc_posix)))11951195+ return 0;11961196+11971197+ /* Check to see if there are whole file write locks */11981198+ ret = 0;11991199+ spin_lock(&flctx->flc_lock);12001200+ if (!list_empty(&flctx->flc_posix)) {12011201+ fl = list_first_entry(&flctx->flc_posix, struct file_lock,12021202+ fl_list);12031203+ if (is_whole_file_wrlock(fl))12041204+ ret = 1;12051205+ } else if (!list_empty(&flctx->flc_flock)) {12061206+ fl = list_first_entry(&flctx->flc_flock, struct file_lock,12071207+ fl_list);12081208+ if (fl->fl_type == F_WRLCK)12091209+ ret = 1;12101210+ }12111211+ spin_unlock(&flctx->flc_lock);12121212+ return ret;12041213}1205121412061215/*
+13-8
fs/nfsd/nfs4state.c
···34723472}3473347334743474static int34753475-nfsd_change_deleg_cb(struct file_lock **onlist, int arg, struct list_head *dispose)34753475+nfsd_change_deleg_cb(struct file_lock *onlist, int arg,34763476+ struct list_head *dispose)34763477{34773478 if (arg & F_UNLCK)34783479 return lease_modify(onlist, arg, dispose);···55525551static bool55535552check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner)55545553{55555555- struct file_lock **flpp;55545554+ struct file_lock *fl;55565555 int status = false;55575556 struct file *filp = find_any_file(fp);55585557 struct inode *inode;55585558+ struct file_lock_context *flctx;5559555955605560 if (!filp) {55615561 /* Any valid lock stateid should have some sort of access */···55655563 }5566556455675565 inode = file_inode(filp);55665566+ flctx = inode->i_flctx;5568556755695569- spin_lock(&inode->i_lock);55705570- for (flpp = &inode->i_flock; *flpp != NULL; flpp = &(*flpp)->fl_next) {55715571- if ((*flpp)->fl_owner == (fl_owner_t)lowner) {55725572- status = true;55735573- break;55685568+ if (flctx && !list_empty_careful(&flctx->flc_posix)) {55695569+ spin_lock(&flctx->flc_lock);55705570+ list_for_each_entry(fl, &flctx->flc_posix, fl_list) {55715571+ if (fl->fl_owner == (fl_owner_t)lowner) {55725572+ status = true;55735573+ break;55745574+ }55745575 }55765576+ spin_unlock(&flctx->flc_lock);55755577 }55765576- spin_unlock(&inode->i_lock);55775578 fput(filp);55785579 return status;55795580}
···9494 struct inode *inode,9595 const char *symname);96969797+static int ocfs2_double_lock(struct ocfs2_super *osb,9898+ struct buffer_head **bh1,9999+ struct inode *inode1,100100+ struct buffer_head **bh2,101101+ struct inode *inode2,102102+ int rename);103103+104104+static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2);97105/* An orphan dir name is an 8 byte value, printed as a hex string */98106#define OCFS2_ORPHAN_NAMELEN ((int)(2 * sizeof(u64)))99107···686678{687679 handle_t *handle;688680 struct inode *inode = old_dentry->d_inode;681681+ struct inode *old_dir = old_dentry->d_parent->d_inode;689682 int err;690683 struct buffer_head *fe_bh = NULL;684684+ struct buffer_head *old_dir_bh = NULL;691685 struct buffer_head *parent_fe_bh = NULL;692686 struct ocfs2_dinode *fe = NULL;693687 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);···706696707697 dquot_initialize(dir);708698709709- err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT);699699+ err = ocfs2_double_lock(osb, &old_dir_bh, old_dir,700700+ &parent_fe_bh, dir, 0);710701 if (err < 0) {711702 if (err != -ENOENT)712703 mlog_errno(err);713704 return err;705705+ }706706+707707+ /* make sure both dirs have bhs708708+ * get an extra ref on old_dir_bh if old==new */709709+ if (!parent_fe_bh) {710710+ if (old_dir_bh) {711711+ parent_fe_bh = old_dir_bh;712712+ get_bh(parent_fe_bh);713713+ } else {714714+ mlog(ML_ERROR, "%s: no old_dir_bh!\n", osb->uuid_str);715715+ err = -EIO;716716+ goto out;717717+ }714718 }715719716720 if (!dir->i_nlink) {···732708 goto out;733709 }734710735735- err = ocfs2_lookup_ino_from_name(dir, old_dentry->d_name.name,711711+ err = ocfs2_lookup_ino_from_name(old_dir, old_dentry->d_name.name,736712 old_dentry->d_name.len, &old_de_ino);737713 if (err) {738714 err = -ENOENT;···825801 ocfs2_inode_unlock(inode, 1);826802827803out:828828- ocfs2_inode_unlock(dir, 1);804804+ ocfs2_double_unlock(old_dir, dir);829805830806 brelse(fe_bh);831807 brelse(parent_fe_bh);808808+ brelse(old_dir_bh);832809833810 ocfs2_free_dir_lookup_result(&lookup);834811···10971072}1098107310991074/*11001100- * The only place this should be used is rename!10751075+ * The only place this should be used is rename and link!11011076 * if they have the same id, then the 1st one is the only one locked.11021077 */11031078static int ocfs2_double_lock(struct ocfs2_super *osb,11041079 struct buffer_head **bh1,11051080 struct inode *inode1,11061081 struct buffer_head **bh2,11071107- struct inode *inode2)10821082+ struct inode *inode2,10831083+ int rename)11081084{11091085 int status;11101086 int inode1_is_ancestor, inode2_is_ancestor;···11531127 }11541128 /* lock id2 */11551129 status = ocfs2_inode_lock_nested(inode2, bh2, 1,11561156- OI_LS_RENAME1);11301130+ rename == 1 ? OI_LS_RENAME1 : OI_LS_PARENT);11571131 if (status < 0) {11581132 if (status != -ENOENT)11591133 mlog_errno(status);···11621136 }1163113711641138 /* lock id1 */11651165- status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_RENAME2);11391139+ status = ocfs2_inode_lock_nested(inode1, bh1, 1,11401140+ rename == 1 ? OI_LS_RENAME2 : OI_LS_PARENT);11661141 if (status < 0) {11671142 /*11681143 * An error return must mean that no cluster locks···1279125212801253 /* if old and new are the same, this'll just do one lock. */12811254 status = ocfs2_double_lock(osb, &old_dir_bh, old_dir,12821282- &new_dir_bh, new_dir);12551255+ &new_dir_bh, new_dir, 1);12831256 if (status < 0) {12841257 mlog_errno(status);12851258 goto bail;
···196196struct acpi_processor {197197 acpi_handle handle;198198 u32 acpi_id;199199- u32 apic_id;200200- u32 id;199199+ u32 phys_id; /* CPU hardware ID such as APIC ID for x86 */200200+ u32 id; /* CPU logical ID allocated by OS */201201 u32 pblk;202202 int performance_platform_limit;203203 int throttling_platform_limit;···310310#endif /* CONFIG_CPU_FREQ */311311312312/* in processor_core.c */313313-int acpi_get_apicid(acpi_handle, int type, u32 acpi_id);314314-int acpi_map_cpuid(int apic_id, u32 acpi_id);313313+int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);314314+int acpi_map_cpuid(int phys_id, u32 acpi_id);315315int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);316316317317/* in processor_pdc.c */
···147147148148#ifdef CONFIG_ACPI_HOTPLUG_CPU149149/* Arch dependent functions for cpu hotplug support */150150-int acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu);151151-int acpi_unmap_lsapic(int cpu);150150+int acpi_map_cpu(acpi_handle handle, int physid, int *pcpu);151151+int acpi_unmap_cpu(int cpu);152152#endif /* CONFIG_ACPI_HOTPLUG_CPU */153153154154int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
+6-2
include/linux/blk-mq.h
···3434 unsigned long flags; /* BLK_MQ_F_* flags */35353636 struct request_queue *queue;3737- unsigned int queue_num;3837 struct blk_flush_queue *fq;39384039 void *driver_data;···5354 unsigned long dispatched[BLK_MQ_MAX_DISPATCH_ORDER];54555556 unsigned int numa_node;5656- unsigned int cmd_size; /* per-request extra data */5757+ unsigned int queue_num;57585859 atomic_t nr_active;5960···194195struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index);195196struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int, int);196197198198+int blk_mq_request_started(struct request *rq);197199void blk_mq_start_request(struct request *rq);198200void blk_mq_end_request(struct request *rq, int error);199201void __blk_mq_end_request(struct request *rq, int error);200202201203void blk_mq_requeue_request(struct request *rq);202204void blk_mq_add_to_requeue_list(struct request *rq, bool at_head);205205+void blk_mq_cancel_requeue_work(struct request_queue *q);203206void blk_mq_kick_requeue_list(struct request_queue *q);207207+void blk_mq_abort_requeue_list(struct request_queue *q);204208void blk_mq_complete_request(struct request *rq);205209206210void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx);···214212void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs);215213void blk_mq_tag_busy_iter(struct blk_mq_hw_ctx *hctx, busy_iter_fn *fn,216214 void *priv);215215+void blk_mq_unfreeze_queue(struct request_queue *q);216216+void blk_mq_freeze_queue_start(struct request_queue *q);217217218218/*219219 * Driver command data is immediately after the request. So subtract request
···215215 }216216}217217218218-static __always_inline void __assign_once_size(volatile void *p, void *res, int size)218218+static __always_inline void __write_once_size(volatile void *p, void *res, int size)219219{220220 switch (size) {221221 case 1: *(volatile __u8 *)p = *(__u8 *)res; break;···235235/*236236 * Prevent the compiler from merging or refetching reads or writes. The237237 * compiler is also forbidden from reordering successive instances of238238- * READ_ONCE, ASSIGN_ONCE and ACCESS_ONCE (see below), but only when the238238+ * READ_ONCE, WRITE_ONCE and ACCESS_ONCE (see below), but only when the239239 * compiler is aware of some particular ordering. One way to make the240240 * compiler aware of ordering is to put the two invocations of READ_ONCE,241241- * ASSIGN_ONCE or ACCESS_ONCE() in different C statements.241241+ * WRITE_ONCE or ACCESS_ONCE() in different C statements.242242 *243243 * In contrast to ACCESS_ONCE these two macros will also work on aggregate244244 * data types like structs or unions. If the size of the accessed data245245 * type exceeds the word size of the machine (e.g., 32 bits or 64 bits)246246- * READ_ONCE() and ASSIGN_ONCE() will fall back to memcpy and print a246246+ * READ_ONCE() and WRITE_ONCE() will fall back to memcpy and print a247247 * compile-time warning.248248 *249249 * Their two major use cases are: (1) Mediating communication between···257257#define READ_ONCE(x) \258258 ({ typeof(x) __val; __read_once_size(&x, &__val, sizeof(__val)); __val; })259259260260-#define ASSIGN_ONCE(val, x) \261261- ({ typeof(x) __val; __val = val; __assign_once_size(&x, &__val, sizeof(__val)); __val; })260260+#define WRITE_ONCE(x, val) \261261+ ({ typeof(x) __val; __val = val; __write_once_size(&x, &__val, sizeof(__val)); __val; })262262263263#endif /* __KERNEL__ */264264
+37-17
include/linux/fs.h
···135135#define FMODE_CAN_WRITE ((__force fmode_t)0x40000)136136137137/* File was opened by fanotify and shouldn't generate fanotify events */138138-#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)138138+#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)139139140140/*141141 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector···625625 atomic_t i_readcount; /* struct files open RO */626626#endif627627 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */628628- struct file_lock *i_flock;628628+ struct file_lock_context *i_flctx;629629 struct address_space i_data;630630 struct list_head i_devices;631631 union {···885885/* legacy typedef, should eventually be removed */886886typedef void *fl_owner_t;887887888888+struct file_lock;889889+888890struct file_lock_operations {889891 void (*fl_copy_lock)(struct file_lock *, struct file_lock *);890892 void (*fl_release_private)(struct file_lock *);···900898 void (*lm_notify)(struct file_lock *); /* unblock callback */901899 int (*lm_grant)(struct file_lock *, int);902900 bool (*lm_break)(struct file_lock *);903903- int (*lm_change)(struct file_lock **, int, struct list_head *);901901+ int (*lm_change)(struct file_lock *, int, struct list_head *);904902 void (*lm_setup)(struct file_lock *, void **);905903};906904···925923 * FIXME: should we create a separate "struct lock_request" to help distinguish926924 * these two uses?927925 *928928- * The i_flock list is ordered by:926926+ * The varous i_flctx lists are ordered by:929927 *930930- * 1) lock type -- FL_LEASEs first, then FL_FLOCK, and finally FL_POSIX931931- * 2) lock owner932932- * 3) lock range start933933- * 4) lock range end928928+ * 1) lock owner929929+ * 2) lock range start930930+ * 3) lock range end934931 *935932 * Obviously, the last two criteria only matter for POSIX locks.936933 */937934struct file_lock {938935 struct file_lock *fl_next; /* singly linked list for this inode */936936+ struct list_head fl_list; /* link into file_lock_context */939937 struct hlist_node fl_link; /* node in global lists */940938 struct list_head fl_block; /* circular list of blocked processes */941939 fl_owner_t fl_owner;···966964 } fl_u;967965};968966967967+struct file_lock_context {968968+ spinlock_t flc_lock;969969+ struct list_head flc_flock;970970+ struct list_head flc_posix;971971+ struct list_head flc_lease;972972+ int flc_flock_cnt;973973+ int flc_posix_cnt;974974+ int flc_lease_cnt;975975+};976976+969977/* The following constant reflects the upper bound of the file/locking space */970978#ifndef OFFSET_MAX971979#define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1)))···1002990extern int fcntl_getlease(struct file *filp);10039911004992/* fs/locks.c */993993+void locks_free_lock_context(struct file_lock_context *ctx);1005994void locks_free_lock(struct file_lock *fl);1006995extern void locks_init_lock(struct file_lock *);1007996extern struct file_lock * locks_alloc_lock(void);···10231010extern void lease_get_mtime(struct inode *, struct timespec *time);10241011extern int generic_setlease(struct file *, long, struct file_lock **, void **priv);10251012extern int vfs_setlease(struct file *, long, struct file_lock **, void **);10261026-extern int lease_modify(struct file_lock **, int, struct list_head *);10131013+extern int lease_modify(struct file_lock *, int, struct list_head *);10271014#else /* !CONFIG_FILE_LOCKING */10281015static inline int fcntl_getlk(struct file *file, unsigned int cmd,10291016 struct flock __user *user)···10581045static inline int fcntl_getlease(struct file *filp)10591046{10601047 return F_UNLCK;10481048+}10491049+10501050+static inline void10511051+locks_free_lock_context(struct file_lock_context *ctx)10521052+{10611053}1062105410631055static inline void locks_init_lock(struct file_lock *fl)···11551137 return -EINVAL;11561138}1157113911581158-static inline int lease_modify(struct file_lock **before, int arg,11401140+static inline int lease_modify(struct file_lock *fl, int arg,11591141 struct list_head *dispose)11601142{11611143 return -EINVAL;···19771959 struct file *filp,19781960 loff_t size)19791961{19801980- if (inode->i_flock && mandatory_lock(inode))19621962+ if (inode->i_flctx && mandatory_lock(inode))19811963 return locks_mandatory_area(19821964 FLOCK_VERIFY_WRITE, inode, filp,19831965 size < inode->i_size ? size : inode->i_size,···19911973{19921974 /*19931975 * Since this check is lockless, we must ensure that any refcounts19941994- * taken are done before checking inode->i_flock. Otherwise, we could19951995- * end up racing with tasks trying to set a new lease on this file.19761976+ * taken are done before checking i_flctx->flc_lease. Otherwise, we19771977+ * could end up racing with tasks trying to set a new lease on this19781978+ * file.19961979 */19971980 smp_mb();19981998- if (inode->i_flock)19811981+ if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))19991982 return __break_lease(inode, mode, FL_LEASE);20001983 return 0;20011984}···20051986{20061987 /*20071988 * Since this check is lockless, we must ensure that any refcounts20082008- * taken are done before checking inode->i_flock. Otherwise, we could20092009- * end up racing with tasks trying to set a new lease on this file.19891989+ * taken are done before checking i_flctx->flc_lease. Otherwise, we19901990+ * could end up racing with tasks trying to set a new lease on this19911991+ * file.20101992 */20111993 smp_mb();20122012- if (inode->i_flock)19941994+ if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease))20131995 return __break_lease(inode, mode, FL_DELEG);20141996 return 0;20151997}
+53-9
include/linux/kdb.h
···1313 * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com>1414 */15151616+/* Shifted versions of the command enable bits are be used if the command1717+ * has no arguments (see kdb_check_flags). This allows commands, such as1818+ * go, to have different permissions depending upon whether it is called1919+ * with an argument.2020+ */2121+#define KDB_ENABLE_NO_ARGS_SHIFT 102222+1623typedef enum {1717- KDB_REPEAT_NONE = 0, /* Do not repeat this command */1818- KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */1919- KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */2020-} kdb_repeat_t;2424+ KDB_ENABLE_ALL = (1 << 0), /* Enable everything */2525+ KDB_ENABLE_MEM_READ = (1 << 1),2626+ KDB_ENABLE_MEM_WRITE = (1 << 2),2727+ KDB_ENABLE_REG_READ = (1 << 3),2828+ KDB_ENABLE_REG_WRITE = (1 << 4),2929+ KDB_ENABLE_INSPECT = (1 << 5),3030+ KDB_ENABLE_FLOW_CTRL = (1 << 6),3131+ KDB_ENABLE_SIGNAL = (1 << 7),3232+ KDB_ENABLE_REBOOT = (1 << 8),3333+ /* User exposed values stop here, all remaining flags are3434+ * exclusively used to describe a commands behaviour.3535+ */3636+3737+ KDB_ENABLE_ALWAYS_SAFE = (1 << 9),3838+ KDB_ENABLE_MASK = (1 << KDB_ENABLE_NO_ARGS_SHIFT) - 1,3939+4040+ KDB_ENABLE_ALL_NO_ARGS = KDB_ENABLE_ALL << KDB_ENABLE_NO_ARGS_SHIFT,4141+ KDB_ENABLE_MEM_READ_NO_ARGS = KDB_ENABLE_MEM_READ4242+ << KDB_ENABLE_NO_ARGS_SHIFT,4343+ KDB_ENABLE_MEM_WRITE_NO_ARGS = KDB_ENABLE_MEM_WRITE4444+ << KDB_ENABLE_NO_ARGS_SHIFT,4545+ KDB_ENABLE_REG_READ_NO_ARGS = KDB_ENABLE_REG_READ4646+ << KDB_ENABLE_NO_ARGS_SHIFT,4747+ KDB_ENABLE_REG_WRITE_NO_ARGS = KDB_ENABLE_REG_WRITE4848+ << KDB_ENABLE_NO_ARGS_SHIFT,4949+ KDB_ENABLE_INSPECT_NO_ARGS = KDB_ENABLE_INSPECT5050+ << KDB_ENABLE_NO_ARGS_SHIFT,5151+ KDB_ENABLE_FLOW_CTRL_NO_ARGS = KDB_ENABLE_FLOW_CTRL5252+ << KDB_ENABLE_NO_ARGS_SHIFT,5353+ KDB_ENABLE_SIGNAL_NO_ARGS = KDB_ENABLE_SIGNAL5454+ << KDB_ENABLE_NO_ARGS_SHIFT,5555+ KDB_ENABLE_REBOOT_NO_ARGS = KDB_ENABLE_REBOOT5656+ << KDB_ENABLE_NO_ARGS_SHIFT,5757+ KDB_ENABLE_ALWAYS_SAFE_NO_ARGS = KDB_ENABLE_ALWAYS_SAFE5858+ << KDB_ENABLE_NO_ARGS_SHIFT,5959+ KDB_ENABLE_MASK_NO_ARGS = KDB_ENABLE_MASK << KDB_ENABLE_NO_ARGS_SHIFT,6060+6161+ KDB_REPEAT_NO_ARGS = 0x40000000, /* Repeat the command w/o arguments */6262+ KDB_REPEAT_WITH_ARGS = 0x80000000, /* Repeat the command with args */6363+} kdb_cmdflags_t;21642265typedef int (*kdb_func_t)(int, const char **);2366···10562#define KDB_BADLENGTH (-19)10663#define KDB_NOBP (-20)10764#define KDB_BADADDR (-21)6565+#define KDB_NOPERM (-22)1086610967/*11068 * kdb_diemsg···190146191147/* Dynamic kdb shell command registration */192148extern int kdb_register(char *, kdb_func_t, char *, char *, short);193193-extern int kdb_register_repeat(char *, kdb_func_t, char *, char *,194194- short, kdb_repeat_t);149149+extern int kdb_register_flags(char *, kdb_func_t, char *, char *,150150+ short, kdb_cmdflags_t);195151extern int kdb_unregister(char *);196152#else /* ! CONFIG_KGDB_KDB */197153static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }198154static inline void kdb_init(int level) {}199155static inline int kdb_register(char *cmd, kdb_func_t func, char *usage,200156 char *help, short minlen) { return 0; }201201-static inline int kdb_register_repeat(char *cmd, kdb_func_t func, char *usage,202202- char *help, short minlen,203203- kdb_repeat_t repeat) { return 0; }157157+static inline int kdb_register_flags(char *cmd, kdb_func_t func, char *usage,158158+ char *help, short minlen,159159+ kdb_cmdflags_t flags) { return 0; }204160static inline int kdb_unregister(char *cmd) { return 0; }205161#endif /* CONFIG_KGDB_KDB */206162enum {
+1-1
include/linux/mm.h
···19521952#if VM_GROWSUP19531953extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);19541954#else19551955- #define expand_upwards(vma, address) do { } while (0)19551955+ #define expand_upwards(vma, address) (0)19561956#endif1957195719581958/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
+1
include/linux/mmc/sdhci.h
···137137#define SDHCI_SDR104_NEEDS_TUNING (1<<10) /* SDR104/HS200 needs tuning */138138#define SDHCI_USING_RETUNING_TIMER (1<<11) /* Host is using a retuning timer for the card */139139#define SDHCI_USE_64_BIT_DMA (1<<12) /* Use 64-bit DMA */140140+#define SDHCI_HS400_TUNING (1<<13) /* Tuning for HS400 */140141141142 unsigned int version; /* SDHCI spec. version */142143
+3-3
include/linux/netdevice.h
···852852 * 3. Update dev->stats asynchronously and atomically, and define853853 * neither operation.854854 *855855- * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16t vid);855855+ * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16 vid);856856 * If device support VLAN filtering this function is called when a857857 * VLAN id is registered.858858 *859859- * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);859859+ * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, __be16 proto, u16 vid);860860 * If device support VLAN filtering this function is called when a861861 * VLAN id is unregistered.862862 *···20852085 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)20862086#define for_each_netdev_in_bond_rcu(bond, slave) \20872087 for_each_netdev_rcu(&init_net, slave) \20882088- if (netdev_master_upper_dev_get_rcu(slave) == bond)20882088+ if (netdev_master_upper_dev_get_rcu(slave) == (bond))20892089#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)2090209020912091static inline struct net_device *next_net_device(struct net_device *dev)
+7-5
include/linux/perf_event.h
···7979 struct perf_branch_entry entries[0];8080};81818282-struct perf_regs {8383- __u64 abi;8484- struct pt_regs *regs;8585-};8686-8782struct task_struct;88838984/*···605610 u32 reserved;606611 } cpu_entry;607612 struct perf_callchain_entry *callchain;613613+614614+ /*615615+ * regs_user may point to task_pt_regs or to regs_user_copy, depending616616+ * on arch details.617617+ */608618 struct perf_regs regs_user;619619+ struct pt_regs regs_user_copy;620620+609621 struct perf_regs regs_intr;610622 u64 stack_user_size;611623} ____cacheline_aligned;
···3737 atomic_t refcount;38383939 /*4040+ * Count of child anon_vmas and VMAs which points to this anon_vma.4141+ *4242+ * This counter is used for making decision about reusing anon_vma4343+ * instead of forking new one. See comments in function anon_vma_clone.4444+ */4545+ unsigned degree;4646+4747+ struct anon_vma *parent; /* Parent of this anon_vma */4848+4949+ /*4050 * NOTE: the LSB of the rb_root.rb_node is set by4151 * mm_take_all_locks() _after_ taking the above lock. So the4252 * rb_root must only be read/written after taking the above lock
···12701270 *12711271 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the12721272 * driver to indicate that it requires IV generation for this12731273- * particular key. Setting this flag does not necessarily mean that SKBs12741274- * will have sufficient tailroom for ICV or MIC.12731273+ * particular key.12751274 * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by12761275 * the driver for a TKIP key if it requires Michael MIC12771276 * generation in software.···12821283 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver12831284 * if space should be prepared for the IV, but the IV12841285 * itself should not be generated. Do not set together with12851285- * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. Setting this flag does12861286- * not necessarily mean that SKBs will have sufficient tailroom for ICV or12871287- * MIC.12861286+ * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key.12881287 * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received12891288 * management frames. The flag can help drivers that have a hardware12901289 * crypto implementation that doesn't deal with management frames
···7777#define DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT 07878/* Default max_write_same_len, disabled by default */7979#define DA_MAX_WRITE_SAME_LEN 08080-/* Default max transfer length */8181-#define DA_FABRIC_MAX_SECTORS 81928280/* Use a model alias based on the configfs backend device name */8381#define DA_EMULATE_MODEL_ALIAS 08482/* Emulation for Direct Page Out */···692694 u32 hw_block_size;693695 u32 block_size;694696 u32 hw_max_sectors;695695- u32 fabric_max_sectors;696697 u32 optimal_sectors;697698 u32 hw_queue_depth;698699 u32 queue_depth;
+1-1
include/uapi/asm-generic/fcntl.h
···5566/*77 * FMODE_EXEC is 0x2088- * FMODE_NONOTIFY is 0x100000088+ * FMODE_NONOTIFY is 0x400000099 * These cannot be used by userspace O_* until internal and external open1010 * flags are split.1111 * -Eric Paris
···174174 OVS_PACKET_ATTR_USERDATA, /* OVS_ACTION_ATTR_USERSPACE arg. */175175 OVS_PACKET_ATTR_EGRESS_TUN_KEY, /* Nested OVS_TUNNEL_KEY_ATTR_*176176 attributes. */177177+ OVS_PACKET_ATTR_UNUSED1,178178+ OVS_PACKET_ATTR_UNUSED2,179179+ OVS_PACKET_ATTR_PROBE, /* Packet operation is a feature probe,180180+ error logging should be suppressed. */177181 __OVS_PACKET_ATTR_MAX178182};179183
+51
include/xen/interface/nmi.h
···11+/******************************************************************************22+ * nmi.h33+ *44+ * NMI callback registration and reason codes.55+ *66+ * Copyright (c) 2005, Keir Fraser <keir@xensource.com>77+ */88+99+#ifndef __XEN_PUBLIC_NMI_H__1010+#define __XEN_PUBLIC_NMI_H__1111+1212+#include <xen/interface/xen.h>1313+1414+/*1515+ * NMI reason codes:1616+ * Currently these are x86-specific, stored in arch_shared_info.nmi_reason.1717+ */1818+ /* I/O-check error reported via ISA port 0x61, bit 6. */1919+#define _XEN_NMIREASON_io_error 02020+#define XEN_NMIREASON_io_error (1UL << _XEN_NMIREASON_io_error)2121+ /* PCI SERR reported via ISA port 0x61, bit 7. */2222+#define _XEN_NMIREASON_pci_serr 12323+#define XEN_NMIREASON_pci_serr (1UL << _XEN_NMIREASON_pci_serr)2424+ /* Unknown hardware-generated NMI. */2525+#define _XEN_NMIREASON_unknown 22626+#define XEN_NMIREASON_unknown (1UL << _XEN_NMIREASON_unknown)2727+2828+/*2929+ * long nmi_op(unsigned int cmd, void *arg)3030+ * NB. All ops return zero on success, else a negative error code.3131+ */3232+3333+/*3434+ * Register NMI callback for this (calling) VCPU. Currently this only makes3535+ * sense for domain 0, vcpu 0. All other callers will be returned EINVAL.3636+ * arg == pointer to xennmi_callback structure.3737+ */3838+#define XENNMI_register_callback 03939+struct xennmi_callback {4040+ unsigned long handler_address;4141+ unsigned long pad;4242+};4343+DEFINE_GUEST_HANDLE_STRUCT(xennmi_callback);4444+4545+/*4646+ * Deregister NMI callback for this (calling) VCPU.4747+ * arg == NULL.4848+ */4949+#define XENNMI_unregister_callback 15050+5151+#endif /* __XEN_PUBLIC_NMI_H__ */
+28-24
kernel/debug/debug_core.c
···2727 * version 2. This program is licensed "as is" without any warranty of any2828 * kind, whether express or implied.2929 */3030+3131+#define pr_fmt(fmt) "KGDB: " fmt3232+3033#include <linux/pid_namespace.h>3134#include <linux/clocksource.h>3235#include <linux/serial_core.h>···199196 return err;200197 err = kgdb_arch_remove_breakpoint(&tmp);201198 if (err)202202- printk(KERN_ERR "KGDB: Critical breakpoint error, kernel "203203- "memory destroyed at: %lx", addr);199199+ pr_err("Critical breakpoint error, kernel memory destroyed at: %lx\n",200200+ addr);204201 return err;205202}206203···259256 error = kgdb_arch_set_breakpoint(&kgdb_break[i]);260257 if (error) {261258 ret = error;262262- printk(KERN_INFO "KGDB: BP install failed: %lx",263263- kgdb_break[i].bpt_addr);259259+ pr_info("BP install failed: %lx\n",260260+ kgdb_break[i].bpt_addr);264261 continue;265262 }266263···322319 continue;323320 error = kgdb_arch_remove_breakpoint(&kgdb_break[i]);324321 if (error) {325325- printk(KERN_INFO "KGDB: BP remove failed: %lx\n",326326- kgdb_break[i].bpt_addr);322322+ pr_info("BP remove failed: %lx\n",323323+ kgdb_break[i].bpt_addr);327324 ret = error;328325 }329326···370367 goto setundefined;371368 error = kgdb_arch_remove_breakpoint(&kgdb_break[i]);372369 if (error)373373- printk(KERN_ERR "KGDB: breakpoint remove failed: %lx\n",370370+ pr_err("breakpoint remove failed: %lx\n",374371 kgdb_break[i].bpt_addr);375372setundefined:376373 kgdb_break[i].state = BP_UNDEFINED;···403400 if (print_wait) {404401#ifdef CONFIG_KGDB_KDB405402 if (!dbg_kdb_mode)406406- printk(KERN_CRIT "KGDB: waiting... or $3#33 for KDB\n");403403+ pr_crit("waiting... or $3#33 for KDB\n");407404#else408408- printk(KERN_CRIT "KGDB: Waiting for remote debugger\n");405405+ pr_crit("Waiting for remote debugger\n");409406#endif410407 }411408 return 1;···433430 exception_level = 0;434431 kgdb_skipexception(ks->ex_vector, ks->linux_regs);435432 dbg_activate_sw_breakpoints();436436- printk(KERN_CRIT "KGDB: re-enter error: breakpoint removed %lx\n",437437- addr);433433+ pr_crit("re-enter error: breakpoint removed %lx\n", addr);438434 WARN_ON_ONCE(1);439435440436 return 1;···446444 panic("Recursive entry to debugger");447445 }448446449449- printk(KERN_CRIT "KGDB: re-enter exception: ALL breakpoints killed\n");447447+ pr_crit("re-enter exception: ALL breakpoints killed\n");450448#ifdef CONFIG_KGDB_KDB451449 /* Allow kdb to debug itself one level */452450 return 0;···473471 int cpu;474472 int trace_on = 0;475473 int online_cpus = num_online_cpus();474474+ u64 time_left;476475477476 kgdb_info[ks->cpu].enter_kgdb++;478477 kgdb_info[ks->cpu].exception_state |= exception_state;···598595 /*599596 * Wait for the other CPUs to be notified and be waiting for us:600597 */601601- while (kgdb_do_roundup && (atomic_read(&masters_in_kgdb) +602602- atomic_read(&slaves_in_kgdb)) != online_cpus)598598+ time_left = loops_per_jiffy * HZ;599599+ while (kgdb_do_roundup && --time_left &&600600+ (atomic_read(&masters_in_kgdb) + atomic_read(&slaves_in_kgdb)) !=601601+ online_cpus)603602 cpu_relax();603603+ if (!time_left)604604+ pr_crit("KGDB: Timed out waiting for secondary CPUs.\n");604605605606 /*606607 * At this point the primary processor is completely···802795static void sysrq_handle_dbg(int key)803796{804797 if (!dbg_io_ops) {805805- printk(KERN_CRIT "ERROR: No KGDB I/O module available\n");798798+ pr_crit("ERROR: No KGDB I/O module available\n");806799 return;807800 }808801 if (!kgdb_connected) {809802#ifdef CONFIG_KGDB_KDB810803 if (!dbg_kdb_mode)811811- printk(KERN_CRIT "KGDB or $3#33 for KDB\n");804804+ pr_crit("KGDB or $3#33 for KDB\n");812805#else813813- printk(KERN_CRIT "Entering KGDB\n");806806+ pr_crit("Entering KGDB\n");814807#endif815808 }816809···952945{953946 kgdb_break_asap = 0;954947955955- printk(KERN_CRIT "kgdb: Waiting for connection from remote gdb...\n");948948+ pr_crit("Waiting for connection from remote gdb...\n");956949 kgdb_breakpoint();957950}958951···971964 if (dbg_io_ops) {972965 spin_unlock(&kgdb_registration_lock);973966974974- printk(KERN_ERR "kgdb: Another I/O driver is already "975975- "registered with KGDB.\n");967967+ pr_err("Another I/O driver is already registered with KGDB\n");976968 return -EBUSY;977969 }978970···987981988982 spin_unlock(&kgdb_registration_lock);989983990990- printk(KERN_INFO "kgdb: Registered I/O driver %s.\n",991991- new_dbg_io_ops->name);984984+ pr_info("Registered I/O driver %s\n", new_dbg_io_ops->name);992985993986 /* Arm KGDB now. */994987 kgdb_register_callbacks();···1022101710231018 spin_unlock(&kgdb_registration_lock);1024101910251025- printk(KERN_INFO10261026- "kgdb: Unregistered I/O driver %s, debugger disabled.\n",10201020+ pr_info("Unregistered I/O driver %s, debugger disabled\n",10271021 old_dbg_io_ops->name);10281022}10291023EXPORT_SYMBOL_GPL(kgdb_unregister_io_module);
···129129 ks->pass_exception = 1;130130 KDB_FLAG_SET(CATASTROPHIC);131131 }132132+ /* set CATASTROPHIC if the system contains unresponsive processors */133133+ for_each_online_cpu(i)134134+ if (!kgdb_info[i].enter_kgdb)135135+ KDB_FLAG_SET(CATASTROPHIC);132136 if (KDB_STATE(SSBPT) && reason == KDB_REASON_SSTEP) {133137 KDB_STATE_CLEAR(SSBPT);134138 KDB_STATE_CLEAR(DOING_SS);
+170-95
kernel/debug/kdb/kdb_main.c
···1212 */13131414#include <linux/ctype.h>1515+#include <linux/types.h>1516#include <linux/string.h>1617#include <linux/kernel.h>1718#include <linux/kmsg_dump.h>···2423#include <linux/vmalloc.h>2524#include <linux/atomic.h>2625#include <linux/module.h>2626+#include <linux/moduleparam.h>2727#include <linux/mm.h>2828#include <linux/init.h>2929#include <linux/kallsyms.h>···4341#include <linux/uaccess.h>4442#include <linux/slab.h>4543#include "kdb_private.h"4444+4545+#undef MODULE_PARAM_PREFIX4646+#define MODULE_PARAM_PREFIX "kdb."4747+4848+static int kdb_cmd_enabled = CONFIG_KDB_DEFAULT_ENABLE;4949+module_param_named(cmd_enable, kdb_cmd_enabled, int, 0600);46504751#define GREP_LEN 2564852char kdb_grep_string[GREP_LEN];···129121 KDBMSG(BADLENGTH, "Invalid length field"),130122 KDBMSG(NOBP, "No Breakpoint exists"),131123 KDBMSG(BADADDR, "Invalid address"),124124+ KDBMSG(NOPERM, "Permission denied"),132125};133126#undef KDBMSG134127···194185 p = krp->p;195186#endif196187 return p;188188+}189189+190190+/*191191+ * Check whether the flags of the current command and the permissions192192+ * of the kdb console has allow a command to be run.193193+ */194194+static inline bool kdb_check_flags(kdb_cmdflags_t flags, int permissions,195195+ bool no_args)196196+{197197+ /* permissions comes from userspace so needs massaging slightly */198198+ permissions &= KDB_ENABLE_MASK;199199+ permissions |= KDB_ENABLE_ALWAYS_SAFE;200200+201201+ /* some commands change group when launched with no arguments */202202+ if (no_args)203203+ permissions |= permissions << KDB_ENABLE_NO_ARGS_SHIFT;204204+205205+ flags |= KDB_ENABLE_ALL;206206+207207+ return permissions & flags;197208}198209199210/*···505476 kdb_symtab_t symtab;506477507478 /*479479+ * If the enable flags prohibit both arbitrary memory access480480+ * and flow control then there are no reasonable grounds to481481+ * provide symbol lookup.482482+ */483483+ if (!kdb_check_flags(KDB_ENABLE_MEM_READ | KDB_ENABLE_FLOW_CTRL,484484+ kdb_cmd_enabled, false))485485+ return KDB_NOPERM;486486+487487+ /*508488 * Process arguments which follow the following syntax:509489 *510490 * symbol | numeric-address [+/- numeric-offset]···679641 if (!s->count)680642 s->usable = 0;681643 if (s->usable)682682- kdb_register(s->name, kdb_exec_defcmd,683683- s->usage, s->help, 0);644644+ /* macros are always safe because when executed each645645+ * internal command re-enters kdb_parse() and is646646+ * safety checked individually.647647+ */648648+ kdb_register_flags(s->name, kdb_exec_defcmd, s->usage,649649+ s->help, 0,650650+ KDB_ENABLE_ALWAYS_SAFE);684651 return 0;685652 }686653 if (!s->usable)···1046100310471004 if (i < kdb_max_commands) {10481005 int result;10061006+10071007+ if (!kdb_check_flags(tp->cmd_flags, kdb_cmd_enabled, argc <= 1))10081008+ return KDB_NOPERM;10091009+10491010 KDB_STATE_SET(CMD);10501011 result = (*tp->cmd_func)(argc-1, (const char **)argv);10511012 if (result && ignore_errors && result > KDB_CMD_GO)10521013 result = 0;10531014 KDB_STATE_CLEAR(CMD);10541054- switch (tp->cmd_repeat) {10551055- case KDB_REPEAT_NONE:10561056- argc = 0;10571057- if (argv[0])10581058- *(argv[0]) = '\0';10591059- break;10601060- case KDB_REPEAT_NO_ARGS:10611061- argc = 1;10621062- if (argv[1])10631063- *(argv[1]) = '\0';10641064- break;10651065- case KDB_REPEAT_WITH_ARGS:10661066- break;10671067- }10151015+10161016+ if (tp->cmd_flags & KDB_REPEAT_WITH_ARGS)10171017+ return result;10181018+10191019+ argc = tp->cmd_flags & KDB_REPEAT_NO_ARGS ? 1 : 0;10201020+ if (argv[argc])10211021+ *(argv[argc]) = '\0';10681022 return result;10691023 }10701024···19611921 */19621922static int kdb_sr(int argc, const char **argv)19631923{19241924+ bool check_mask =19251925+ !kdb_check_flags(KDB_ENABLE_ALL, kdb_cmd_enabled, false);19261926+19641927 if (argc != 1)19651928 return KDB_ARGCOUNT;19291929+19661930 kdb_trap_printk++;19671967- __handle_sysrq(*argv[1], false);19311931+ __handle_sysrq(*argv[1], check_mask);19681932 kdb_trap_printk--;1969193319701934 return 0;···22012157 for (start_cpu = -1, i = 0; i < NR_CPUS; i++) {22022158 if (!cpu_online(i)) {22032159 state = 'F'; /* cpu is offline */21602160+ } else if (!kgdb_info[i].enter_kgdb) {21612161+ state = 'D'; /* cpu is online but unresponsive */22042162 } else {22052163 state = ' '; /* cpu is responding to kdb */22062164 if (kdb_task_state_char(KDB_TSK(i)) == 'I')···22562210 /*22572211 * Validate cpunum22582212 */22592259- if ((cpunum > NR_CPUS) || !cpu_online(cpunum))22132213+ if ((cpunum > NR_CPUS) || !kgdb_info[cpunum].enter_kgdb)22602214 return KDB_BADCPUNUM;2261221522622216 dbg_switch_cpu = cpunum;···24202374 if (KDB_FLAG(CMD_INTERRUPT))24212375 return 0;24222376 if (!kt->cmd_name)23772377+ continue;23782378+ if (!kdb_check_flags(kt->cmd_flags, kdb_cmd_enabled, true))24232379 continue;24242380 if (strlen(kt->cmd_usage) > 20)24252381 space = "\n ";···26772629}2678263026792631/*26802680- * kdb_register_repeat - This function is used to register a kernel26322632+ * kdb_register_flags - This function is used to register a kernel26812633 * debugger command.26822634 * Inputs:26832635 * cmd Command name···26892641 * zero for success, one if a duplicate command.26902642 */26912643#define kdb_command_extend 50 /* arbitrary */26922692-int kdb_register_repeat(char *cmd,26932693- kdb_func_t func,26942694- char *usage,26952695- char *help,26962696- short minlen,26972697- kdb_repeat_t repeat)26442644+int kdb_register_flags(char *cmd,26452645+ kdb_func_t func,26462646+ char *usage,26472647+ char *help,26482648+ short minlen,26492649+ kdb_cmdflags_t flags)26982650{26992651 int i;27002652 kdbtab_t *kp;···27422694 kp->cmd_func = func;27432695 kp->cmd_usage = usage;27442696 kp->cmd_help = help;27452745- kp->cmd_flags = 0;27462697 kp->cmd_minlen = minlen;27472747- kp->cmd_repeat = repeat;26982698+ kp->cmd_flags = flags;2748269927492700 return 0;27502701}27512751-EXPORT_SYMBOL_GPL(kdb_register_repeat);27022702+EXPORT_SYMBOL_GPL(kdb_register_flags);275227032753270427542705/*27552706 * kdb_register - Compatibility register function for commands that do27562707 * not need to specify a repeat state. Equivalent to27572757- * kdb_register_repeat with KDB_REPEAT_NONE.27082708+ * kdb_register_flags with flags set to 0.27582709 * Inputs:27592710 * cmd Command name27602711 * func Function to execute the command···27682721 char *help,27692722 short minlen)27702723{27712771- return kdb_register_repeat(cmd, func, usage, help, minlen,27722772- KDB_REPEAT_NONE);27242724+ return kdb_register_flags(cmd, func, usage, help, minlen, 0);27732725}27742726EXPORT_SYMBOL_GPL(kdb_register);27752727···28102764 for_each_kdbcmd(kp, i)28112765 kp->cmd_name = NULL;2812276628132813- kdb_register_repeat("md", kdb_md, "<vaddr>",27672767+ kdb_register_flags("md", kdb_md, "<vaddr>",28142768 "Display Memory Contents, also mdWcN, e.g. md8c1", 1,28152815- KDB_REPEAT_NO_ARGS);28162816- kdb_register_repeat("mdr", kdb_md, "<vaddr> <bytes>",28172817- "Display Raw Memory", 0, KDB_REPEAT_NO_ARGS);28182818- kdb_register_repeat("mdp", kdb_md, "<paddr> <bytes>",28192819- "Display Physical Memory", 0, KDB_REPEAT_NO_ARGS);28202820- kdb_register_repeat("mds", kdb_md, "<vaddr>",28212821- "Display Memory Symbolically", 0, KDB_REPEAT_NO_ARGS);28222822- kdb_register_repeat("mm", kdb_mm, "<vaddr> <contents>",28232823- "Modify Memory Contents", 0, KDB_REPEAT_NO_ARGS);28242824- kdb_register_repeat("go", kdb_go, "[<vaddr>]",28252825- "Continue Execution", 1, KDB_REPEAT_NONE);28262826- kdb_register_repeat("rd", kdb_rd, "",28272827- "Display Registers", 0, KDB_REPEAT_NONE);28282828- kdb_register_repeat("rm", kdb_rm, "<reg> <contents>",28292829- "Modify Registers", 0, KDB_REPEAT_NONE);28302830- kdb_register_repeat("ef", kdb_ef, "<vaddr>",28312831- "Display exception frame", 0, KDB_REPEAT_NONE);28322832- kdb_register_repeat("bt", kdb_bt, "[<vaddr>]",28332833- "Stack traceback", 1, KDB_REPEAT_NONE);28342834- kdb_register_repeat("btp", kdb_bt, "<pid>",28352835- "Display stack for process <pid>", 0, KDB_REPEAT_NONE);28362836- kdb_register_repeat("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]",28372837- "Backtrace all processes matching state flag", 0, KDB_REPEAT_NONE);28382838- kdb_register_repeat("btc", kdb_bt, "",28392839- "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE);28402840- kdb_register_repeat("btt", kdb_bt, "<vaddr>",27692769+ KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);27702770+ kdb_register_flags("mdr", kdb_md, "<vaddr> <bytes>",27712771+ "Display Raw Memory", 0,27722772+ KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);27732773+ kdb_register_flags("mdp", kdb_md, "<paddr> <bytes>",27742774+ "Display Physical Memory", 0,27752775+ KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);27762776+ kdb_register_flags("mds", kdb_md, "<vaddr>",27772777+ "Display Memory Symbolically", 0,27782778+ KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);27792779+ kdb_register_flags("mm", kdb_mm, "<vaddr> <contents>",27802780+ "Modify Memory Contents", 0,27812781+ KDB_ENABLE_MEM_WRITE | KDB_REPEAT_NO_ARGS);27822782+ kdb_register_flags("go", kdb_go, "[<vaddr>]",27832783+ "Continue Execution", 1,27842784+ KDB_ENABLE_REG_WRITE | KDB_ENABLE_ALWAYS_SAFE_NO_ARGS);27852785+ kdb_register_flags("rd", kdb_rd, "",27862786+ "Display Registers", 0,27872787+ KDB_ENABLE_REG_READ);27882788+ kdb_register_flags("rm", kdb_rm, "<reg> <contents>",27892789+ "Modify Registers", 0,27902790+ KDB_ENABLE_REG_WRITE);27912791+ kdb_register_flags("ef", kdb_ef, "<vaddr>",27922792+ "Display exception frame", 0,27932793+ KDB_ENABLE_MEM_READ);27942794+ kdb_register_flags("bt", kdb_bt, "[<vaddr>]",27952795+ "Stack traceback", 1,27962796+ KDB_ENABLE_MEM_READ | KDB_ENABLE_INSPECT_NO_ARGS);27972797+ kdb_register_flags("btp", kdb_bt, "<pid>",27982798+ "Display stack for process <pid>", 0,27992799+ KDB_ENABLE_INSPECT);28002800+ kdb_register_flags("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]",28012801+ "Backtrace all processes matching state flag", 0,28022802+ KDB_ENABLE_INSPECT);28032803+ kdb_register_flags("btc", kdb_bt, "",28042804+ "Backtrace current process on each cpu", 0,28052805+ KDB_ENABLE_INSPECT);28062806+ kdb_register_flags("btt", kdb_bt, "<vaddr>",28412807 "Backtrace process given its struct task address", 0,28422842- KDB_REPEAT_NONE);28432843- kdb_register_repeat("env", kdb_env, "",28442844- "Show environment variables", 0, KDB_REPEAT_NONE);28452845- kdb_register_repeat("set", kdb_set, "",28462846- "Set environment variables", 0, KDB_REPEAT_NONE);28472847- kdb_register_repeat("help", kdb_help, "",28482848- "Display Help Message", 1, KDB_REPEAT_NONE);28492849- kdb_register_repeat("?", kdb_help, "",28502850- "Display Help Message", 0, KDB_REPEAT_NONE);28512851- kdb_register_repeat("cpu", kdb_cpu, "<cpunum>",28522852- "Switch to new cpu", 0, KDB_REPEAT_NONE);28532853- kdb_register_repeat("kgdb", kdb_kgdb, "",28542854- "Enter kgdb mode", 0, KDB_REPEAT_NONE);28552855- kdb_register_repeat("ps", kdb_ps, "[<flags>|A]",28562856- "Display active task list", 0, KDB_REPEAT_NONE);28572857- kdb_register_repeat("pid", kdb_pid, "<pidnum>",28582858- "Switch to another task", 0, KDB_REPEAT_NONE);28592859- kdb_register_repeat("reboot", kdb_reboot, "",28602860- "Reboot the machine immediately", 0, KDB_REPEAT_NONE);28082808+ KDB_ENABLE_MEM_READ | KDB_ENABLE_INSPECT_NO_ARGS);28092809+ kdb_register_flags("env", kdb_env, "",28102810+ "Show environment variables", 0,28112811+ KDB_ENABLE_ALWAYS_SAFE);28122812+ kdb_register_flags("set", kdb_set, "",28132813+ "Set environment variables", 0,28142814+ KDB_ENABLE_ALWAYS_SAFE);28152815+ kdb_register_flags("help", kdb_help, "",28162816+ "Display Help Message", 1,28172817+ KDB_ENABLE_ALWAYS_SAFE);28182818+ kdb_register_flags("?", kdb_help, "",28192819+ "Display Help Message", 0,28202820+ KDB_ENABLE_ALWAYS_SAFE);28212821+ kdb_register_flags("cpu", kdb_cpu, "<cpunum>",28222822+ "Switch to new cpu", 0,28232823+ KDB_ENABLE_ALWAYS_SAFE_NO_ARGS);28242824+ kdb_register_flags("kgdb", kdb_kgdb, "",28252825+ "Enter kgdb mode", 0, 0);28262826+ kdb_register_flags("ps", kdb_ps, "[<flags>|A]",28272827+ "Display active task list", 0,28282828+ KDB_ENABLE_INSPECT);28292829+ kdb_register_flags("pid", kdb_pid, "<pidnum>",28302830+ "Switch to another task", 0,28312831+ KDB_ENABLE_INSPECT);28322832+ kdb_register_flags("reboot", kdb_reboot, "",28332833+ "Reboot the machine immediately", 0,28342834+ KDB_ENABLE_REBOOT);28612835#if defined(CONFIG_MODULES)28622862- kdb_register_repeat("lsmod", kdb_lsmod, "",28632863- "List loaded kernel modules", 0, KDB_REPEAT_NONE);28362836+ kdb_register_flags("lsmod", kdb_lsmod, "",28372837+ "List loaded kernel modules", 0,28382838+ KDB_ENABLE_INSPECT);28642839#endif28652840#if defined(CONFIG_MAGIC_SYSRQ)28662866- kdb_register_repeat("sr", kdb_sr, "<key>",28672867- "Magic SysRq key", 0, KDB_REPEAT_NONE);28412841+ kdb_register_flags("sr", kdb_sr, "<key>",28422842+ "Magic SysRq key", 0,28432843+ KDB_ENABLE_ALWAYS_SAFE);28682844#endif28692845#if defined(CONFIG_PRINTK)28702870- kdb_register_repeat("dmesg", kdb_dmesg, "[lines]",28712871- "Display syslog buffer", 0, KDB_REPEAT_NONE);28462846+ kdb_register_flags("dmesg", kdb_dmesg, "[lines]",28472847+ "Display syslog buffer", 0,28482848+ KDB_ENABLE_ALWAYS_SAFE);28722849#endif28732850 if (arch_kgdb_ops.enable_nmi) {28742874- kdb_register_repeat("disable_nmi", kdb_disable_nmi, "",28752875- "Disable NMI entry to KDB", 0, KDB_REPEAT_NONE);28512851+ kdb_register_flags("disable_nmi", kdb_disable_nmi, "",28522852+ "Disable NMI entry to KDB", 0,28532853+ KDB_ENABLE_ALWAYS_SAFE);28762854 }28772877- kdb_register_repeat("defcmd", kdb_defcmd, "name \"usage\" \"help\"",28782878- "Define a set of commands, down to endefcmd", 0, KDB_REPEAT_NONE);28792879- kdb_register_repeat("kill", kdb_kill, "<-signal> <pid>",28802880- "Send a signal to a process", 0, KDB_REPEAT_NONE);28812881- kdb_register_repeat("summary", kdb_summary, "",28822882- "Summarize the system", 4, KDB_REPEAT_NONE);28832883- kdb_register_repeat("per_cpu", kdb_per_cpu, "<sym> [<bytes>] [<cpu>]",28842884- "Display per_cpu variables", 3, KDB_REPEAT_NONE);28852885- kdb_register_repeat("grephelp", kdb_grep_help, "",28862886- "Display help on | grep", 0, KDB_REPEAT_NONE);28552855+ kdb_register_flags("defcmd", kdb_defcmd, "name \"usage\" \"help\"",28562856+ "Define a set of commands, down to endefcmd", 0,28572857+ KDB_ENABLE_ALWAYS_SAFE);28582858+ kdb_register_flags("kill", kdb_kill, "<-signal> <pid>",28592859+ "Send a signal to a process", 0,28602860+ KDB_ENABLE_SIGNAL);28612861+ kdb_register_flags("summary", kdb_summary, "",28622862+ "Summarize the system", 4,28632863+ KDB_ENABLE_ALWAYS_SAFE);28642864+ kdb_register_flags("per_cpu", kdb_per_cpu, "<sym> [<bytes>] [<cpu>]",28652865+ "Display per_cpu variables", 3,28662866+ KDB_ENABLE_MEM_READ);28672867+ kdb_register_flags("grephelp", kdb_grep_help, "",28682868+ "Display help on | grep", 0,28692869+ KDB_ENABLE_ALWAYS_SAFE);28872870}2888287128892872/* Execute any commands defined in kdb_cmds. */
+1-2
kernel/debug/kdb/kdb_private.h
···172172 kdb_func_t cmd_func; /* Function to execute command */173173 char *cmd_usage; /* Usage String for this command */174174 char *cmd_help; /* Help message for this command */175175- short cmd_flags; /* Parsing flags */176175 short cmd_minlen; /* Minimum legal # command177176 * chars required */178178- kdb_repeat_t cmd_repeat; /* Does command auto repeat on enter? */177177+ kdb_cmdflags_t cmd_flags; /* Command behaviour flags */179178} kdbtab_t;180179181180extern int kdb_bt(int, const char **); /* KDB display back trace */
+8-11
kernel/events/core.c
···44614461}4462446244634463static void perf_sample_regs_user(struct perf_regs *regs_user,44644464- struct pt_regs *regs)44644464+ struct pt_regs *regs,44654465+ struct pt_regs *regs_user_copy)44654466{44664466- if (!user_mode(regs)) {44674467- if (current->mm)44684468- regs = task_pt_regs(current);44694469- else44704470- regs = NULL;44714471- }44724472-44734473- if (regs) {44744474- regs_user->abi = perf_reg_abi(current);44674467+ if (user_mode(regs)) {44684468+ regs_user->abi = perf_reg_abi(current);44754469 regs_user->regs = regs;44704470+ } else if (current->mm) {44714471+ perf_get_regs_user(regs_user, regs, regs_user_copy);44764472 } else {44774473 regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE;44784474 regs_user->regs = NULL;···49474951 }4948495249494953 if (sample_type & (PERF_SAMPLE_REGS_USER | PERF_SAMPLE_STACK_USER))49504950- perf_sample_regs_user(&data->regs_user, regs);49544954+ perf_sample_regs_user(&data->regs_user, regs,49554955+ &data->regs_user_copy);4951495649524957 if (sample_type & PERF_SAMPLE_REGS_USER) {49534958 /* regs dump ABI info */
+9-3
kernel/exit.c
···12871287static int wait_consider_task(struct wait_opts *wo, int ptrace,12881288 struct task_struct *p)12891289{12901290+ /*12911291+ * We can race with wait_task_zombie() from another thread.12921292+ * Ensure that EXIT_ZOMBIE -> EXIT_DEAD/EXIT_TRACE transition12931293+ * can't confuse the checks below.12941294+ */12951295+ int exit_state = ACCESS_ONCE(p->exit_state);12901296 int ret;1291129712921292- if (unlikely(p->exit_state == EXIT_DEAD))12981298+ if (unlikely(exit_state == EXIT_DEAD))12931299 return 0;1294130012951301 ret = eligible_child(wo, p);···13161310 return 0;13171311 }1318131213191319- if (unlikely(p->exit_state == EXIT_TRACE)) {13131313+ if (unlikely(exit_state == EXIT_TRACE)) {13201314 /*13211315 * ptrace == 0 means we are the natural parent. In this case13221316 * we should clear notask_error, debugger will notify us.···13431337 }1344133813451339 /* slay zombie? */13461346- if (p->exit_state == EXIT_ZOMBIE) {13401340+ if (exit_state == EXIT_ZOMBIE) {13471341 /* we don't reap group leaders with subthreads */13481342 if (!delay_group_leader(p)) {13491343 /*
+1-1
kernel/locking/mutex-debug.c
···8080 DEBUG_LOCKS_WARN_ON(lock->owner != current);81818282 DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);8383- mutex_clear_owner(lock);8483 }85848685 /*8786 * __mutex_slowpath_needs_to_unlock() is explicitly 0 for debug8887 * mutexes so that we can do it here after we've verified state.8988 */8989+ mutex_clear_owner(lock);9090 atomic_set(&lock->count, 1);9191}9292
···570570static571571int dl_runtime_exceeded(struct rq *rq, struct sched_dl_entity *dl_se)572572{573573- int dmiss = dl_time_before(dl_se->deadline, rq_clock(rq));574574- int rorun = dl_se->runtime <= 0;575575-576576- if (!rorun && !dmiss)577577- return 0;578578-579579- /*580580- * If we are beyond our current deadline and we are still581581- * executing, then we have already used some of the runtime of582582- * the next instance. Thus, if we do not account that, we are583583- * stealing bandwidth from the system at each deadline miss!584584- */585585- if (dmiss) {586586- dl_se->runtime = rorun ? dl_se->runtime : 0;587587- dl_se->runtime -= rq_clock(rq) - dl_se->deadline;588588- }589589-590590- return 1;573573+ return (dl_se->runtime <= 0);591574}592575593576extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);···809826 * parameters of the task might need updating. Otherwise,810827 * we want a replenishment of its runtime.811828 */812812- if (!dl_se->dl_new && flags & ENQUEUE_REPLENISH)813813- replenish_dl_entity(dl_se, pi_se);814814- else829829+ if (dl_se->dl_new || flags & ENQUEUE_WAKEUP)815830 update_dl_entity(dl_se, pi_se);831831+ else if (flags & ENQUEUE_REPLENISH)832832+ replenish_dl_entity(dl_se, pi_se);816833817834 __enqueue_dl_entity(dl_se);818835}
+5-1
kernel/sched/fair.c
···4005400540064006static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)40074007{40084008+ /* init_cfs_bandwidth() was not called */40094009+ if (!cfs_b->throttled_cfs_rq.next)40104010+ return;40114011+40084012 hrtimer_cancel(&cfs_b->period_timer);40094013 hrtimer_cancel(&cfs_b->slack_timer);40104014}···44284424 * wl = S * s'_i; see (2)44294425 */44304426 if (W > 0 && w < W)44314431- wl = (w * tg->shares) / W;44274427+ wl = (w * (long)tg->shares) / W;44324428 else44334429 wl = tg->shares;44344430
···7373 help7474 KDB frontend for kernel75757676+config KDB_DEFAULT_ENABLE7777+ hex "KDB: Select kdb command functions to be enabled by default"7878+ depends on KGDB_KDB7979+ default 0x18080+ help8181+ Specifiers which kdb commands are enabled by default. This may8282+ be set to 1 or 0 to enable all commands or disable almost all8383+ commands.8484+8585+ Alternatively the following bitmask applies:8686+8787+ 0x0002 - allow arbitrary reads from memory and symbol lookup8888+ 0x0004 - allow arbitrary writes to memory8989+ 0x0008 - allow current register state to be inspected9090+ 0x0010 - allow current register state to be modified9191+ 0x0020 - allow passive inspection (backtrace, process list, lsmod)9292+ 0x0040 - allow flow control management (breakpoint, single step)9393+ 0x0080 - enable signalling of processes9494+ 0x0100 - allow machine to be rebooted9595+9696+ The config option merely sets the default at boot time. Both9797+ issuing 'echo X > /sys/module/kdb/parameters/cmd_enable' or9898+ setting with kdb.cmd_enable=X kernel command line option will9999+ override the default settings.100100+76101config KDB_KEYBOARD77102 bool "KGDB_KDB: keyboard as input device"78103 depends on VT && KGDB_KDB
+1
lib/assoc_array.c
···1111 * 2 of the Licence, or (at your option) any later version.1212 */1313//#define DEBUG1414+#include <linux/rcupdate.h>1415#include <linux/slab.h>1516#include <linux/err.h>1617#include <linux/assoc_array_priv.h>
-9
mm/Kconfig.debug
···1414 depends on !KMEMCHECK1515 select PAGE_EXTENSION1616 select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC1717- select PAGE_GUARD if ARCH_SUPPORTS_DEBUG_PAGEALLOC1817 ---help---1918 Unmap pages from the kernel linear mapping after free_pages().2019 This results in a large slowdown, but helps to find certain types···2627 that would result in incorrect warnings of memory corruption after2728 a resume because free pages are not saved to the suspend image.28292929-config WANT_PAGE_DEBUG_FLAGS3030- bool3131-3230config PAGE_POISONING3331 bool3434- select WANT_PAGE_DEBUG_FLAGS3535-3636-config PAGE_GUARD3737- bool3838- select WANT_PAGE_DEBUG_FLAGS
+4-13
mm/memcontrol.c
···30433043 if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) {30443044 mem_cgroup_swap_statistics(from, false);30453045 mem_cgroup_swap_statistics(to, true);30463046- /*30473047- * This function is only called from task migration context now.30483048- * It postpones page_counter and refcount handling till the end30493049- * of task migration(mem_cgroup_clear_mc()) for performance30503050- * improvement. But we cannot postpone css_get(to) because if30513051- * the process that has been moved to @to does swap-in, the30523052- * refcount of @to might be decreased to 0.30533053- *30543054- * We are in attach() phase, so the cgroup is guaranteed to be30553055- * alive, so we can just call css_get().30563056- */30573057- css_get(&to->css);30583046 return 0;30593047 }30603048 return -EINVAL;···46674679 if (parent_css == NULL) {46684680 root_mem_cgroup = memcg;46694681 page_counter_init(&memcg->memory, NULL);46824682+ memcg->soft_limit = PAGE_COUNTER_MAX;46704683 page_counter_init(&memcg->memsw, NULL);46714684 page_counter_init(&memcg->kmem, NULL);46724685 }···4713472447144725 if (parent->use_hierarchy) {47154726 page_counter_init(&memcg->memory, &parent->memory);47274727+ memcg->soft_limit = PAGE_COUNTER_MAX;47164728 page_counter_init(&memcg->memsw, &parent->memsw);47174729 page_counter_init(&memcg->kmem, &parent->kmem);47184730···47234733 */47244734 } else {47254735 page_counter_init(&memcg->memory, NULL);47364736+ memcg->soft_limit = PAGE_COUNTER_MAX;47264737 page_counter_init(&memcg->memsw, NULL);47274738 page_counter_init(&memcg->kmem, NULL);47284739 /*···47984807 mem_cgroup_resize_limit(memcg, PAGE_COUNTER_MAX);47994808 mem_cgroup_resize_memsw_limit(memcg, PAGE_COUNTER_MAX);48004809 memcg_update_kmem_limit(memcg, PAGE_COUNTER_MAX);48014801- memcg->soft_limit = 0;48104810+ memcg->soft_limit = PAGE_COUNTER_MAX;48024811}4803481248044813#ifdef CONFIG_MMU
+23-16
mm/memory.c
···235235236236static void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)237237{238238+ if (!tlb->end)239239+ return;240240+238241 tlb_flush(tlb);239242 mmu_notifier_invalidate_range(tlb->mm, tlb->start, tlb->end);240243#ifdef CONFIG_HAVE_RCU_TABLE_FREE···250247{251248 struct mmu_gather_batch *batch;252249253253- for (batch = &tlb->local; batch; batch = batch->next) {250250+ for (batch = &tlb->local; batch && batch->nr; batch = batch->next) {254251 free_pages_and_swap_cache(batch->pages, batch->nr);255252 batch->nr = 0;256253 }···259256260257void tlb_flush_mmu(struct mmu_gather *tlb)261258{262262- if (!tlb->end)263263- return;264264-265259 tlb_flush_mmu_tlbonly(tlb);266260 tlb_flush_mmu_free(tlb);267261}···21372137 if (!dirty_page)21382138 return ret;2139213921402140- /*21412141- * Yes, Virginia, this is actually required to prevent a race21422142- * with clear_page_dirty_for_io() from clearing the page dirty21432143- * bit after it clear all dirty ptes, but before a racing21442144- * do_wp_page installs a dirty pte.21452145- *21462146- * do_shared_fault is protected similarly.21472147- */21482140 if (!page_mkwrite) {21492149- wait_on_page_locked(dirty_page);21502150- set_page_dirty_balance(dirty_page);21412141+ struct address_space *mapping;21422142+ int dirtied;21432143+21442144+ lock_page(dirty_page);21452145+ dirtied = set_page_dirty(dirty_page);21462146+ VM_BUG_ON_PAGE(PageAnon(dirty_page), dirty_page);21472147+ mapping = dirty_page->mapping;21482148+ unlock_page(dirty_page);21492149+21502150+ if (dirtied && mapping) {21512151+ /*21522152+ * Some device drivers do not set page.mapping21532153+ * but still dirty their pages21542154+ */21552155+ balance_dirty_pages_ratelimited(mapping);21562156+ }21572157+21512158 /* file_update_time outside page_lock */21522159 if (vma->vm_file)21532160 file_update_time(vma->vm_file);···26002593 if (prev && prev->vm_end == address)26012594 return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;2602259526032603- expand_downwards(vma, address - PAGE_SIZE);25962596+ return expand_downwards(vma, address - PAGE_SIZE);26042597 }26052598 if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {26062599 struct vm_area_struct *next = vma->vm_next;···26092602 if (next && next->vm_start == address + PAGE_SIZE)26102603 return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;2611260426122612- expand_upwards(vma, address + PAGE_SIZE);26052605+ return expand_upwards(vma, address + PAGE_SIZE);26132606 }26142607 return 0;26152608}
+10-5
mm/mmap.c
···778778 if (exporter && exporter->anon_vma && !importer->anon_vma) {779779 int error;780780781781- error = anon_vma_clone(importer, exporter);782782- if (error)783783- return error;784781 importer->anon_vma = exporter->anon_vma;782782+ error = anon_vma_clone(importer, exporter);783783+ if (error) {784784+ importer->anon_vma = NULL;785785+ return error;786786+ }785787 }786788 }787789···21012099{21022100 struct mm_struct *mm = vma->vm_mm;21032101 struct rlimit *rlim = current->signal->rlim;21042104- unsigned long new_start;21022102+ unsigned long new_start, actual_size;2105210321062104 /* address space limit tests */21072105 if (!may_expand_vm(mm, grow))21082106 return -ENOMEM;2109210721102108 /* Stack limit test */21112111- if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))21092109+ actual_size = size;21102110+ if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN)))21112111+ actual_size -= PAGE_SIZE;21122112+ if (actual_size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))21122113 return -ENOMEM;2113211421142115 /* mlock limit tests */
+12-31
mm/page-writeback.c
···15411541 bdi_start_background_writeback(bdi);15421542}1543154315441544-void set_page_dirty_balance(struct page *page)15451545-{15461546- if (set_page_dirty(page)) {15471547- struct address_space *mapping = page_mapping(page);15481548-15491549- if (mapping)15501550- balance_dirty_pages_ratelimited(mapping);15511551- }15521552-}15531553-15541544static DEFINE_PER_CPU(int, bdp_ratelimits);1555154515561546/*···21132123 * page dirty in that case, but not all the buffers. This is a "bottom-up"21142124 * dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying.21152125 *21162116- * Most callers have locked the page, which pins the address_space in memory.21172117- * But zap_pte_range() does not lock the page, however in that case the21182118- * mapping is pinned by the vma's ->vm_file reference.21192119- *21202120- * We take care to handle the case where the page was truncated from the21212121- * mapping by re-checking page_mapping() inside tree_lock.21262126+ * The caller must ensure this doesn't race with truncation. Most will simply21272127+ * hold the page lock, but e.g. zap_pte_range() calls with the page mapped and21282128+ * the pte lock held, which also locks out truncation.21222129 */21232130int __set_page_dirty_nobuffers(struct page *page)21242131{21252132 if (!TestSetPageDirty(page)) {21262133 struct address_space *mapping = page_mapping(page);21272127- struct address_space *mapping2;21282134 unsigned long flags;2129213521302136 if (!mapping)21312137 return 1;2132213821332139 spin_lock_irqsave(&mapping->tree_lock, flags);21342134- mapping2 = page_mapping(page);21352135- if (mapping2) { /* Race with truncate? */21362136- BUG_ON(mapping2 != mapping);21372137- WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));21382138- account_page_dirtied(page, mapping);21392139- radix_tree_tag_set(&mapping->page_tree,21402140- page_index(page), PAGECACHE_TAG_DIRTY);21412141- }21402140+ BUG_ON(page_mapping(page) != mapping);21412141+ WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));21422142+ account_page_dirtied(page, mapping);21432143+ radix_tree_tag_set(&mapping->page_tree, page_index(page),21442144+ PAGECACHE_TAG_DIRTY);21422145 spin_unlock_irqrestore(&mapping->tree_lock, flags);21432146 if (mapping->host) {21442147 /* !PageAnon && !swapper_space */···22882305 /*22892306 * We carefully synchronise fault handlers against22902307 * installing a dirty pte and marking the page dirty22912291- * at this point. We do this by having them hold the22922292- * page lock at some point after installing their22932293- * pte, but before marking the page dirty.22942294- * Pages are always locked coming in here, so we get22952295- * the desired exclusion. See mm/memory.c:do_wp_page()22962296- * for more comments.23082308+ * at this point. We do this by having them hold the23092309+ * page lock while dirtying the page, and pages are23102310+ * always locked coming in here, so we get the desired23112311+ * exclusion.22972312 */22982313 if (TestClearPageDirty(page)) {22992314 dec_zone_page_state(page, NR_FILE_DIRTY);
+41-1
mm/rmap.c
···7272 anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);7373 if (anon_vma) {7474 atomic_set(&anon_vma->refcount, 1);7575+ anon_vma->degree = 1; /* Reference for first vma */7676+ anon_vma->parent = anon_vma;7577 /*7678 * Initialise the anon_vma root to point to itself. If called7779 * from fork, the root will be reset to the parents anon_vma.···190188 if (likely(!vma->anon_vma)) {191189 vma->anon_vma = anon_vma;192190 anon_vma_chain_link(vma, avc, anon_vma);191191+ /* vma reference or self-parent link for new root */192192+ anon_vma->degree++;193193 allocated = NULL;194194 avc = NULL;195195 }···240236/*241237 * Attach the anon_vmas from src to dst.242238 * Returns 0 on success, -ENOMEM on failure.239239+ *240240+ * If dst->anon_vma is NULL this function tries to find and reuse existing241241+ * anon_vma which has no vmas and only one child anon_vma. This prevents242242+ * degradation of anon_vma hierarchy to endless linear chain in case of243243+ * constantly forking task. On the other hand, an anon_vma with more than one244244+ * child isn't reused even if there was no alive vma, thus rmap walker has a245245+ * good chance of avoiding scanning the whole hierarchy when it searches where246246+ * page is mapped.243247 */244248int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)245249{···268256 anon_vma = pavc->anon_vma;269257 root = lock_anon_vma_root(root, anon_vma);270258 anon_vma_chain_link(dst, avc, anon_vma);259259+260260+ /*261261+ * Reuse existing anon_vma if its degree lower than two,262262+ * that means it has no vma and only one anon_vma child.263263+ *264264+ * Do not chose parent anon_vma, otherwise first child265265+ * will always reuse it. Root anon_vma is never reused:266266+ * it has self-parent reference and at least one child.267267+ */268268+ if (!dst->anon_vma && anon_vma != src->anon_vma &&269269+ anon_vma->degree < 2)270270+ dst->anon_vma = anon_vma;271271 }272272+ if (dst->anon_vma)273273+ dst->anon_vma->degree++;272274 unlock_anon_vma_root(root);273275 return 0;274276···306280 if (!pvma->anon_vma)307281 return 0;308282283283+ /* Drop inherited anon_vma, we'll reuse existing or allocate new. */284284+ vma->anon_vma = NULL;285285+309286 /*310287 * First, attach the new VMA to the parent VMA's anon_vmas,311288 * so rmap can find non-COWed pages in child processes.···316287 error = anon_vma_clone(vma, pvma);317288 if (error)318289 return error;290290+291291+ /* An existing anon_vma has been reused, all done then. */292292+ if (vma->anon_vma)293293+ return 0;319294320295 /* Then add our own anon_vma. */321296 anon_vma = anon_vma_alloc();···334301 * lock any of the anon_vmas in this anon_vma tree.335302 */336303 anon_vma->root = pvma->anon_vma->root;304304+ anon_vma->parent = pvma->anon_vma;337305 /*338306 * With refcounts, an anon_vma can stay around longer than the339307 * process it belongs to. The root anon_vma needs to be pinned until···345311 vma->anon_vma = anon_vma;346312 anon_vma_lock_write(anon_vma);347313 anon_vma_chain_link(vma, avc, anon_vma);314314+ anon_vma->parent->degree++;348315 anon_vma_unlock_write(anon_vma);349316350317 return 0;···376341 * Leave empty anon_vmas on the list - we'll need377342 * to free them outside the lock.378343 */379379- if (RB_EMPTY_ROOT(&anon_vma->rb_root))344344+ if (RB_EMPTY_ROOT(&anon_vma->rb_root)) {345345+ anon_vma->parent->degree--;380346 continue;347347+ }381348382349 list_del(&avc->same_vma);383350 anon_vma_chain_free(avc);384351 }352352+ if (vma->anon_vma)353353+ vma->anon_vma->degree--;385354 unlock_anon_vma_root(root);386355387356 /*···396357 list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) {397358 struct anon_vma *anon_vma = avc->anon_vma;398359360360+ BUG_ON(anon_vma->degree);399361 put_anon_vma(anon_vma);400362401363 list_del(&avc->same_vma);
+13-11
mm/vmscan.c
···29212921 return false;2922292229232923 /*29242924- * There is a potential race between when kswapd checks its watermarks29252925- * and a process gets throttled. There is also a potential race if29262926- * processes get throttled, kswapd wakes, a large process exits therby29272927- * balancing the zones that causes kswapd to miss a wakeup. If kswapd29282928- * is going to sleep, no process should be sleeping on pfmemalloc_wait29292929- * so wake them now if necessary. If necessary, processes will wake29302930- * kswapd and get throttled again29242924+ * The throttled processes are normally woken up in balance_pgdat() as29252925+ * soon as pfmemalloc_watermark_ok() is true. But there is a potential29262926+ * race between when kswapd checks the watermarks and a process gets29272927+ * throttled. There is also a potential race if processes get29282928+ * throttled, kswapd wakes, a large process exits thereby balancing the29292929+ * zones, which causes kswapd to exit balance_pgdat() before reaching29302930+ * the wake up checks. If kswapd is going to sleep, no process should29312931+ * be sleeping on pfmemalloc_wait, so wake them now if necessary. If29322932+ * the wake up is premature, processes will wake kswapd and get29332933+ * throttled again. The difference from wake ups in balance_pgdat() is29342934+ * that here we are under prepare_to_wait().29312935 */29322932- if (waitqueue_active(&pgdat->pfmemalloc_wait)) {29332933- wake_up(&pgdat->pfmemalloc_wait);29342934- return false;29352935- }29362936+ if (waitqueue_active(&pgdat->pfmemalloc_wait))29372937+ wake_up_all(&pgdat->pfmemalloc_wait);2936293829372939 return pgdat_balanced(pgdat, order, classzone_idx);29382940}
+7-4
net/batman-adv/multicast.c
···685685 if (orig_initialized)686686 atomic_dec(&bat_priv->mcast.num_disabled);687687 orig->capabilities |= BATADV_ORIG_CAPA_HAS_MCAST;688688- /* If mcast support is being switched off increase the disabled689689- * mcast node counter.688688+ /* If mcast support is being switched off or if this is an initial689689+ * OGM without mcast support then increase the disabled mcast690690+ * node counter.690691 */691692 } else if (!orig_mcast_enabled &&692692- orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST) {693693+ (orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST ||694694+ !orig_initialized)) {693695 atomic_inc(&bat_priv->mcast.num_disabled);694696 orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_MCAST;695697 }···740738{741739 struct batadv_priv *bat_priv = orig->bat_priv;742740743743- if (!(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST))741741+ if (!(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST) &&742742+ orig->capa_initialized & BATADV_ORIG_CAPA_HAS_MCAST)744743 atomic_dec(&bat_priv->mcast.num_disabled);745744746745 batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS);
+1-1
net/batman-adv/network-coding.c
···133133 if (!bat_priv->nc.decoding_hash)134134 goto err;135135136136- batadv_hash_set_lock_class(bat_priv->nc.coding_hash,136136+ batadv_hash_set_lock_class(bat_priv->nc.decoding_hash,137137 &batadv_nc_decoding_hash_lock_class_key);138138139139 INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker);
···443443444444 router = batadv_orig_router_get(orig_node, recv_if);445445446446+ if (!router)447447+ return router;448448+446449 /* only consider bonding for recv_if == BATADV_IF_DEFAULT (first hop)447450 * and if activated.448451 */449449- if (recv_if == BATADV_IF_DEFAULT || !atomic_read(&bat_priv->bonding) ||450450- !router)452452+ if (!(recv_if == BATADV_IF_DEFAULT && atomic_read(&bat_priv->bonding)))451453 return router;452454453455 /* bonding: loop through the list of possible routers found
+2-1
net/bridge/br_input.c
···154154 dst = NULL;155155156156 if (is_broadcast_ether_addr(dest)) {157157- if (p->flags & BR_PROXYARP &&157157+ if (IS_ENABLED(CONFIG_INET) &&158158+ p->flags & BR_PROXYARP &&158159 skb->protocol == htons(ETH_P_ARP))159160 br_do_proxy_arp(skb, br, vid);160161
···20432043 case NDTPA_BASE_REACHABLE_TIME:20442044 NEIGH_VAR_SET(p, BASE_REACHABLE_TIME,20452045 nla_get_msecs(tbp[i]));20462046+ /* update reachable_time as well, otherwise, the change will20472047+ * only be effective after the next time neigh_periodic_work20482048+ * decides to recompute it (can be multiple minutes)20492049+ */20502050+ p->reachable_time =20512051+ neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME));20462052 break;20472053 case NDTPA_GC_STALETIME:20482054 NEIGH_VAR_SET(p, GC_STALETIME,···29272921 return ret;29282922}2929292329242924+static int neigh_proc_base_reachable_time(struct ctl_table *ctl, int write,29252925+ void __user *buffer,29262926+ size_t *lenp, loff_t *ppos)29272927+{29282928+ struct neigh_parms *p = ctl->extra2;29292929+ int ret;29302930+29312931+ if (strcmp(ctl->procname, "base_reachable_time") == 0)29322932+ ret = neigh_proc_dointvec_jiffies(ctl, write, buffer, lenp, ppos);29332933+ else if (strcmp(ctl->procname, "base_reachable_time_ms") == 0)29342934+ ret = neigh_proc_dointvec_ms_jiffies(ctl, write, buffer, lenp, ppos);29352935+ else29362936+ ret = -1;29372937+29382938+ if (write && ret == 0) {29392939+ /* update reachable_time as well, otherwise, the change will29402940+ * only be effective after the next time neigh_periodic_work29412941+ * decides to recompute it29422942+ */29432943+ p->reachable_time =29442944+ neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME));29452945+ }29462946+ return ret;29472947+}29482948+29302949#define NEIGH_PARMS_DATA_OFFSET(index) \29312950 (&((struct neigh_parms *) 0)->data[index])29322951···30783047 t->neigh_vars[NEIGH_VAR_RETRANS_TIME_MS].proc_handler = handler;30793048 /* ReachableTime (in milliseconds) */30803049 t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler = handler;30503050+ } else {30513051+ /* Those handlers will update p->reachable_time after30523052+ * base_reachable_time(_ms) is set to ensure the new timer starts being30533053+ * applied after the next neighbour update instead of waiting for30543054+ * neigh_periodic_work to update its value (can be multiple minutes)30553055+ * So any handler that replaces them should do this as well30563056+ */30573057+ /* ReachableTime */30583058+ t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME].proc_handler =30593059+ neigh_proc_base_reachable_time;30603060+ /* ReachableTime (in milliseconds) */30613061+ t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].proc_handler =30623062+ neigh_proc_base_reachable_time;30813063 }3082306430833065 /* Don't export sysctls to unprivileged users */
···140140 if (!ret) {141141 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;142142143143- if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC))143143+ if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||144144+ (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||145145+ (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))144146 sdata->crypto_tx_tailroom_needed_cnt--;145147146148 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&···190188 sta = key->sta;191189 sdata = key->sdata;192190193193- if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC))191191+ if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||192192+ (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||193193+ (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))194194 increment_tailroom_need_count(sdata);195195196196 ret = drv_set_key(key->local, DISABLE_KEY, sdata,···888884 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {889885 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;890886891891- if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC))887887+ if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||888888+ (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||889889+ (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))892890 increment_tailroom_need_count(key->sdata);893891 }894892
+5-5
net/netfilter/ipvs/ip_vs_ftp.c
···183183 struct nf_conn *ct;184184 struct net *net;185185186186+ *diff = 0;187187+186188#ifdef CONFIG_IP_VS_IPV6187189 /* This application helper doesn't work with IPv6 yet,188190 * so turn this into a no-op for IPv6 packets···192190 if (cp->af == AF_INET6)193191 return 1;194192#endif195195-196196- *diff = 0;197193198194 /* Only useful for established sessions */199195 if (cp->state != IP_VS_TCP_S_ESTABLISHED)···322322 struct ip_vs_conn *n_cp;323323 struct net *net;324324325325+ /* no diff required for incoming packets */326326+ *diff = 0;327327+325328#ifdef CONFIG_IP_VS_IPV6326329 /* This application helper doesn't work with IPv6 yet,327330 * so turn this into a no-op for IPv6 packets···332329 if (cp->af == AF_INET6)333330 return 1;334331#endif335335-336336- /* no diff required for incoming packets */337337- *diff = 0;338332339333 /* Only useful for established sessions */340334 if (cp->state != IP_VS_TCP_S_ESTABLISHED)
+9-11
net/netfilter/nf_conntrack_core.c
···611611 */612612 NF_CT_ASSERT(!nf_ct_is_confirmed(ct));613613 pr_debug("Confirming conntrack %p\n", ct);614614- /* We have to check the DYING flag inside the lock to prevent615615- a race against nf_ct_get_next_corpse() possibly called from616616- user context, else we insert an already 'dead' hash, blocking617617- further use of that particular connection -JM */614614+ /* We have to check the DYING flag after unlink to prevent615615+ * a race against nf_ct_get_next_corpse() possibly called from616616+ * user context, else we insert an already 'dead' hash, blocking617617+ * further use of that particular connection -JM.618618+ */619619+ nf_ct_del_from_dying_or_unconfirmed_list(ct);618620619619- if (unlikely(nf_ct_is_dying(ct))) {620620- nf_conntrack_double_unlock(hash, reply_hash);621621- local_bh_enable();622622- return NF_ACCEPT;623623- }621621+ if (unlikely(nf_ct_is_dying(ct)))622622+ goto out;624623625624 /* See if there's one in the list already, including reverse:626625 NAT could have grabbed it without realizing, since we're···634635 &h->tuple) &&635636 zone == nf_ct_zone(nf_ct_tuplehash_to_ctrack(h)))636637 goto out;637637-638638- nf_ct_del_from_dying_or_unconfirmed_list(ct);639638640639 /* Timer relative to confirmation time, not original641640 setting time, otherwise we'd get timer wrap in···670673 return NF_ACCEPT;671674672675out:676676+ nf_ct_add_to_dying_list(ct);673677 nf_conntrack_double_unlock(hash, reply_hash);674678 NF_CT_STAT_INC(net, insert_failed);675679 local_bh_enable();
···42424343__clean-files := $(filter-out $(no-clean-files), $(__clean-files))44444545-# as clean-files is given relative to the current directory, this adds4646-# a $(obj) prefix, except for absolute paths4545+# clean-files is given relative to the current directory, unless it4646+# starts with $(objtree)/ (which means "./", so do not add "./" unless4747+# you want to delete a file from the toplevel object directory).47484849__clean-files := $(wildcard \4949- $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \5050- $(filter /%, $(__clean-files)))5050+ $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \5151+ $(filter $(objtree)/%, $(__clean-files)))51525252-# as clean-dirs is given relative to the current directory, this adds5353-# a $(obj) prefix, except for absolute paths5353+# same as clean-files54545555__clean-dirs := $(wildcard \5656- $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \5757- $(filter /%, $(clean-dirs)))5656+ $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \5757+ $(filter $(objtree)/%, $(clean-dirs)))58585959# ==========================================================================6060
+2-2
security/keys/gc.c
···148148 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags))149149 atomic_dec(&key->user->nikeys);150150151151- key_user_put(key->user);152152-153151 /* now throw away the key memory */154152 if (key->type->destroy)155153 key->type->destroy(key);154154+155155+ key_user_put(key->user);156156157157 kfree(key->description);158158
···495495 }496496497497 if (ntevs == 0) { /* No error but failed to find probe point. */498498- pr_warning("Probe point '%s' not found.\n",498498+ pr_warning("Probe point '%s' not found in debuginfo.\n",499499 synthesize_perf_probe_point(&pev->point));500500- return -ENOENT;500500+ if (need_dwarf)501501+ return -ENOENT;502502+ return 0;501503 }502504 /* Error path : ntevs < 0 */503505 pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs);
+17-1
tools/perf/util/probe-finder.c
···989989 int ret = 0;990990991991#if _ELFUTILS_PREREQ(0, 142)992992+ Elf *elf;993993+ GElf_Ehdr ehdr;994994+ GElf_Shdr shdr;995995+992996 /* Get the call frame information from this dwarf */993993- pf->cfi = dwarf_getcfi_elf(dwarf_getelf(dbg->dbg));997997+ elf = dwarf_getelf(dbg->dbg);998998+ if (elf == NULL)999999+ return -EINVAL;10001000+10011001+ if (gelf_getehdr(elf, &ehdr) == NULL)10021002+ return -EINVAL;10031003+10041004+ if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&10051005+ shdr.sh_type == SHT_PROGBITS) {10061006+ pf->cfi = dwarf_getcfi_elf(elf);10071007+ } else {10081008+ pf->cfi = dwarf_getcfi(dbg->dbg);10091009+ }9941010#endif99510119961012 off = 0;
+13-6
tools/testing/selftests/exec/execveat.c
···6262}63636464static int check_execveat_invoked_rc(int fd, const char *path, int flags,6565- int expected_rc)6565+ int expected_rc, int expected_rc2)6666{6767 int status;6868 int rc;···9898 child, status);9999 return 1;100100 }101101- if (WEXITSTATUS(status) != expected_rc) {102102- printf("[FAIL] (child %d exited with %d not %d)\n",103103- child, WEXITSTATUS(status), expected_rc);101101+ if ((WEXITSTATUS(status) != expected_rc) &&102102+ (WEXITSTATUS(status) != expected_rc2)) {103103+ printf("[FAIL] (child %d exited with %d not %d nor %d)\n",104104+ child, WEXITSTATUS(status), expected_rc, expected_rc2);104105 return 1;105106 }106107 printf("[OK]\n");···110109111110static int check_execveat(int fd, const char *path, int flags)112111{113113- return check_execveat_invoked_rc(fd, path, flags, 99);112112+ return check_execveat_invoked_rc(fd, path, flags, 99, 99);114113}115114116115static char *concat(const char *left, const char *right)···193192 * Execute as a long pathname relative to ".". If this is a script,194193 * the interpreter will launch but fail to open the script because its195194 * name ("/dev/fd/5/xxx....") is bigger than PATH_MAX.195195+ *196196+ * The failure code is usually 127 (POSIX: "If a command is not found,197197+ * the exit status shall be 127."), but some systems give 126 (POSIX:198198+ * "If the command name is found, but it is not an executable utility,199199+ * the exit status shall be 126."), so allow either.196200 */197201 if (is_script)198198- fail += check_execveat_invoked_rc(dot_dfd, longpath, 0, 127);202202+ fail += check_execveat_invoked_rc(dot_dfd, longpath, 0,203203+ 127, 126);199204 else200205 fail += check_execveat(dot_dfd, longpath, 0);201206
+1-2
tools/testing/selftests/mqueue/mq_perf_tests.c
···536536{537537 struct mq_attr attr;538538 char *option, *next_option;539539- int i, cpu;539539+ int i, cpu, rc;540540 struct sigaction sa;541541 poptContext popt_context;542542- char rc;543542 void *retval;544543545544 main_thread = pthread_self();