···8181Required properties for pin configuration node:8282- atmel,pins: 4 integers array, represents a group of pins mux and config8383 setting. The format is atmel,pins = <PIN_BANK PIN_BANK_NUM PERIPH CONFIG>.8484- The PERIPH 0 means gpio.8484+ The PERIPH 0 means gpio, PERIPH 1 is periph A, PERIPH 2 is periph B...8585+ PIN_BANK 0 is pioA, PIN_BANK 1 is pioB...85868687Bits used for CONFIG:8788PULL_UP (1 << 0): indicate this pin need a pull up.···127126 pinctrl_dbgu: dbgu-0 {128127 atmel,pins =129128 <1 14 0x1 0x0 /* PB14 periph A */130130- 1 15 0x1 0x1>; /* PB15 periph with pullup */129129+ 1 15 0x1 0x1>; /* PB15 periph A with pullup */131130 };132131 };133132};
+9-9
Documentation/filesystems/f2fs.txt
···175175 align with the zone size <-|176176 |-> align with the segment size177177 _________________________________________________________________________178178- | | | Node | Segment | Segment | |179179- | Superblock | Checkpoint | Address | Info. | Summary | Main |180180- | (SB) | (CP) | Table (NAT) | Table (SIT) | Area (SSA) | |178178+ | | | Segment | Node | Segment | |179179+ | Superblock | Checkpoint | Info. | Address | Summary | Main |180180+ | (SB) | (CP) | Table (SIT) | Table (NAT) | Area (SSA) | |181181 |____________|_____2______|______N______|______N______|______N_____|__N___|182182 . .183183 . .···200200 : It contains file system information, bitmaps for valid NAT/SIT sets, orphan201201 inode lists, and summary entries of current active segments.202202203203-- Node Address Table (NAT)204204- : It is composed of a block address table for all the node blocks stored in205205- Main area.206206-207203- Segment Information Table (SIT)208204 : It contains segment information such as valid block count and bitmap for the209205 validity of all the blocks.206206+207207+- Node Address Table (NAT)208208+ : It is composed of a block address table for all the node blocks stored in209209+ Main area.210210211211- Segment Summary Area (SSA)212212 : It contains summary entries which contains the owner information of all the···236236valid, as shown as below.237237238238 +--------+----------+---------+239239- | CP | NAT | SIT |239239+ | CP | SIT | NAT |240240 +--------+----------+---------+241241 . . . .242242 . . . .243243 . . . .244244 +-------+-------+--------+--------+--------+--------+245245- | CP #0 | CP #1 | NAT #0 | NAT #1 | SIT #0 | SIT #1 |245245+ | CP #0 | CP #1 | SIT #0 | SIT #1 | NAT #0 | NAT #1 |246246 +-------+-------+--------+--------+--------+--------+247247 | ^ ^248248 | | |
···1919CONFIG_SOC_AT91SAM9263=y2020CONFIG_SOC_AT91SAM9G45=y2121CONFIG_SOC_AT91SAM9X5=y2222+CONFIG_SOC_AT91SAM9N12=y2223CONFIG_MACH_AT91SAM_DT=y2324CONFIG_AT91_PROGRAMMABLE_CLOCKS=y2425CONFIG_AT91_TIMER_HZ=128···3231CONFIG_ZBOOT_ROM_BSS=0x03332CONFIG_ARM_APPENDED_DTB=y3433CONFIG_ARM_ATAG_DTB_COMPAT=y3535-CONFIG_CMDLINE="mem=128M console=ttyS0,115200 initrd=0x21100000,25165824 root=/dev/ram0 rw"3434+CONFIG_CMDLINE="console=ttyS0,115200 initrd=0x21100000,25165824 root=/dev/ram0 rw"3635CONFIG_KEXEC=y3736CONFIG_AUTO_ZRELADDR=y3837# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
···246246247247 /*248248 * Then map boot params address in r2 if specified.249249+ * We map 2 sections in case the ATAGs/DTB crosses a section boundary.249250 */250251 mov r0, r2, lsr #SECTION_SHIFT251252 movs r0, r0, lsl #SECTION_SHIFT···254253 addne r3, r3, #PAGE_OFFSET255254 addne r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER)256255 orrne r6, r7, r0256256+ strne r6, [r3], #1 << PMD_ORDER257257+ addne r6, r6, #1 << SECTION_SHIFT257258 strne r6, [r3]258259259260#ifdef CONFIG_DEBUG_LL···334331 * as it has already been validated by the primary processor.335332 */336333#ifdef CONFIG_ARM_VIRT_EXT337337- bl __hyp_stub_install334334+ bl __hyp_stub_install_secondary338335#endif339336 safe_svcmode_maskall r9340337
+6-12
arch/arm/kernel/hyp-stub.S
···9999 * immediately.100100 */101101 compare_cpu_mode_with_primary r4, r5, r6, r7102102- bxne lr102102+ movne pc, lr103103104104 /*105105 * Once we have given up on one CPU, we do not try to install the···111111 */112112113113 cmp r4, #HYP_MODE114114- bxne lr @ give up if the CPU is not in HYP mode114114+ movne pc, lr @ give up if the CPU is not in HYP mode115115116116/*117117 * Configure HSCTLR to set correct exception endianness/instruction set···120120 * Eventually, CPU-specific code might be needed -- assume not for now121121 *122122 * This code relies on the "eret" instruction to synchronize the123123- * various coprocessor accesses.123123+ * various coprocessor accesses. This is done when we switch to SVC124124+ * (see safe_svcmode_maskall).124125 */125126 @ Now install the hypervisor stub:126127 adr r7, __hyp_stub_vectors···1561551:157156#endif158157159159- bic r7, r4, #MODE_MASK160160- orr r7, r7, #SVC_MODE161161-THUMB( orr r7, r7, #PSR_T_BIT )162162- msr spsr_cxsf, r7 @ This is SPSR_hyp.163163-164164- __MSR_ELR_HYP(14) @ msr elr_hyp, lr165165- __ERET @ return, switching to SVC mode166166- @ The boot CPU mode is left in r4.158158+ bx lr @ The boot CPU mode is left in r4.167159ENDPROC(__hyp_stub_install_secondary)168160169161__hyp_stub_do_trap:···194200 @ fall through195201ENTRY(__hyp_set_vectors)196202 __HVC(0)197197- bx lr203203+ mov pc, lr198204ENDPROC(__hyp_set_vectors)199205200206#ifndef ZIMAGE
+2
arch/arm/mach-at91/setup.c
···105105 switch (socid) {106106 case ARCH_ID_AT91RM9200:107107 at91_soc_initdata.type = AT91_SOC_RM9200;108108+ if (at91_soc_initdata.subtype == AT91_SOC_SUBTYPE_NONE)109109+ at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;108110 at91_boot_soc = at91rm9200_soc;109111 break;110112
···436436 for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)437437 clk_prepare_enable(clk[clks_init_on[i]]);438438439439+ /* Set initial power mode */440440+ imx6q_set_lpm(WAIT_CLOCKED);441441+439442 np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt");440443 base = of_iomap(np, 0);441444 WARN_ON(!base);
+1
arch/arm/mach-imx/common.h
···142142extern void imx6q_clock_map_io(void);143143144144extern void imx_cpu_die(unsigned int cpu);145145+extern int imx_cpu_kill(unsigned int cpu);145146146147#ifdef CONFIG_PM147148extern void imx6q_pm_init(void);
···4646void imx_cpu_die(unsigned int cpu)4747{4848 cpu_enter_lowpower();4949- imx_enable_cpu(cpu, false);4949+ cpu_do_idle();5050+}50515151- /* spin here until hardware takes it down */5252- while (1)5353- ;5252+int imx_cpu_kill(unsigned int cpu)5353+{5454+ imx_enable_cpu(cpu, false);5555+ return 1;5456}
···475475{476476 int ret = 0;477477478478+ if (!ap_syscon_base)479479+ return -EINVAL;480480+478481 if (nr == 0) {479482 sys->mem_offset = PHYS_PCI_MEM_BASE;480483 ret = pci_v3_setup_resources(sys);481481- /* Remap the Integrator system controller */482482- ap_syscon_base = ioremap(INTEGRATOR_SC_BASE, 0x100);483483- if (!ap_syscon_base)484484- return -EINVAL;485484 }486485487486 return ret;···495496 unsigned long flags;496497 unsigned int temp;497498 int ret;499499+500500+ /* Remap the Integrator system controller */501501+ ap_syscon_base = ioremap(INTEGRATOR_SC_BASE, 0x100);502502+ if (!ap_syscon_base) {503503+ pr_err("unable to remap the AP syscon for PCIv3\n");504504+ return;505505+ }498506499507 pcibios_min_mem = 0x00100000;500508
-38
arch/arm/mach-kirkwood/board-ns2.c
···1818#include <linux/gpio.h>1919#include <linux/of.h>2020#include "common.h"2121-#include "mpp.h"22212322static struct mv643xx_eth_platform_data ns2_ge00_data = {2423 .phy_addr = MV643XX_ETH_PHY_ADDR(8),2525-};2626-2727-static unsigned int ns2_mpp_config[] __initdata = {2828- MPP0_SPI_SCn,2929- MPP1_SPI_MOSI,3030- MPP2_SPI_SCK,3131- MPP3_SPI_MISO,3232- MPP4_NF_IO6,3333- MPP5_NF_IO7,3434- MPP6_SYSRST_OUTn,3535- MPP7_GPO, /* Fan speed (bit 1) */3636- MPP8_TW0_SDA,3737- MPP9_TW0_SCK,3838- MPP10_UART0_TXD,3939- MPP11_UART0_RXD,4040- MPP12_GPO, /* Red led */4141- MPP14_GPIO, /* USB fuse */4242- MPP16_GPIO, /* SATA 0 power */4343- MPP17_GPIO, /* SATA 1 power */4444- MPP18_NF_IO0,4545- MPP19_NF_IO1,4646- MPP20_SATA1_ACTn,4747- MPP21_SATA0_ACTn,4848- MPP22_GPIO, /* Fan speed (bit 0) */4949- MPP23_GPIO, /* Fan power */5050- MPP24_GPIO, /* USB mode select */5151- MPP25_GPIO, /* Fan rotation fail */5252- MPP26_GPIO, /* USB device vbus */5353- MPP28_GPIO, /* USB enable host vbus */5454- MPP29_GPIO, /* Blue led (slow register) */5555- MPP30_GPIO, /* Blue led (command register) */5656- MPP31_GPIO, /* Board power off */5757- MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */5858- MPP33_GPO, /* Fan speed (bit 2) */5959- 06024};61256226#define NS2_GPIO_POWER_OFF 31···3571 /*3672 * Basic setup. Needs to be called early.3773 */3838- kirkwood_mpp_conf(ns2_mpp_config);3939-4074 if (of_machine_is_compatible("lacie,netspace_lite_v2") ||4175 of_machine_is_compatible("lacie,netspace_mini_v2"))4276 ns2_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
···20262026 * On OMAP4460 the ABE DPLL fails to turn on if in idle low-power20272027 * state when turning the ABE clock domain. Workaround this by20282028 * locking the ABE DPLL on boot.20292029+ * Lock the ABE DPLL in any case to avoid issues with audio.20292030 */20302030- if (cpu_is_omap446x()) {20312031- rc = clk_set_parent(&abe_dpll_refclk_mux_ck, &sys_32k_ck);20322032- if (!rc)20332033- rc = clk_set_rate(&dpll_abe_ck, OMAP4_DPLL_ABE_DEFFREQ);20342034- if (rc)20352035- pr_err("%s: failed to configure ABE DPLL!\n", __func__);20362036- }20312031+ rc = clk_set_parent(&abe_dpll_refclk_mux_ck, &sys_32k_ck);20322032+ if (!rc)20332033+ rc = clk_set_rate(&dpll_abe_ck, OMAP4_DPLL_ABE_DEFFREQ);20342034+ if (rc)20352035+ pr_err("%s: failed to configure ABE DPLL!\n", __func__);2037203620382037 return 0;20392038}
···21322132 * currently reset very early during boot, before I2C is21332133 * available, so it doesn't seem that we have any choice in21342134 * the kernel other than to avoid resetting it.21352135+ *21362136+ * Also, McPDM needs to be configured to NO_IDLE mode when it21372137+ * is in used otherwise vital clocks will be gated which21382138+ * results 'slow motion' audio playback.21352139 */21362136- .flags = HWMOD_EXT_OPT_MAIN_CLK,21402140+ .flags = HWMOD_EXT_OPT_MAIN_CLK | HWMOD_SWSUP_SIDLE,21372141 .mpu_irqs = omap44xx_mcpdm_irqs,21382142 .sdma_reqs = omap44xx_mcpdm_sdma_reqs,21392143 .main_clk = "mcpdm_fck",
+2-6
arch/arm/mach-omap2/timer.c
···165165 struct device_node *np;166166167167 for_each_matching_node(np, match) {168168- if (!of_device_is_available(np)) {169169- of_node_put(np);168168+ if (!of_device_is_available(np))170169 continue;171171- }172170173173- if (property && !of_get_property(np, property, NULL)) {174174- of_node_put(np);171171+ if (property && !of_get_property(np, property, NULL))175172 continue;176176- }177173178174 of_add_property(np, &device_disabled);179175 return np;
···338338 for (i = 0; i < ARRAY_SIZE(s3c64xx_pm_domains); i++)339339 pm_genpd_init(&s3c64xx_pm_domains[i]->pd, NULL, false);340340341341+#ifdef CONFIG_S3C_DEV_FB341342 if (dev_get_platdata(&s3c_device_fb.dev))342343 pm_genpd_add_device(&s3c64xx_pm_f.pd, &s3c_device_fb.dev);344344+#endif343345344346 return 0;345347}
+10-8
arch/arm/mm/dma-mapping.c
···774774 size_t size, enum dma_data_direction dir,775775 void (*op)(const void *, size_t, int))776776{777777+ unsigned long pfn;778778+ size_t left = size;779779+780780+ pfn = page_to_pfn(page) + offset / PAGE_SIZE;781781+ offset %= PAGE_SIZE;782782+777783 /*778784 * A single sg entry may refer to multiple physically contiguous779785 * pages. But we still need to process highmem pages individually.780786 * If highmem is not configured then the bulk of this loop gets781787 * optimized out.782788 */783783- size_t left = size;784789 do {785790 size_t len = left;786791 void *vaddr;787792793793+ page = pfn_to_page(pfn);794794+788795 if (PageHighMem(page)) {789789- if (len + offset > PAGE_SIZE) {790790- if (offset >= PAGE_SIZE) {791791- page += offset / PAGE_SIZE;792792- offset %= PAGE_SIZE;793793- }796796+ if (len + offset > PAGE_SIZE)794797 len = PAGE_SIZE - offset;795795- }796798 vaddr = kmap_high_get(page);797799 if (vaddr) {798800 vaddr += offset;···811809 op(vaddr, len, dir);812810 }813811 offset = 0;814814- page++;812812+ pfn++;815813 left -= len;816814 } while (left);817815}
···672672 read_unlock(&tasklist_lock);673673}674674675675-static inline int676676-thread_matches (struct task_struct *thread, unsigned long addr)677677-{678678- unsigned long thread_rbs_end;679679- struct pt_regs *thread_regs;680680-681681- if (ptrace_check_attach(thread, 0) < 0)682682- /*683683- * If the thread is not in an attachable state, we'll684684- * ignore it. The net effect is that if ADDR happens685685- * to overlap with the portion of the thread's686686- * register backing store that is currently residing687687- * on the thread's kernel stack, then ptrace() may end688688- * up accessing a stale value. But if the thread689689- * isn't stopped, that's a problem anyhow, so we're690690- * doing as well as we can...691691- */692692- return 0;693693-694694- thread_regs = task_pt_regs(thread);695695- thread_rbs_end = ia64_get_user_rbs_end(thread, thread_regs, NULL);696696- if (!on_kernel_rbs(addr, thread_regs->ar_bspstore, thread_rbs_end))697697- return 0;698698-699699- return 1; /* looks like we've got a winner */700700-}701701-702675/*703676 * Write f32-f127 back to task->thread.fph if it has been modified.704677 */
···3939#define OP_31_XOP_TRAP 44040#define OP_31_XOP_LWZX 234141#define OP_31_XOP_TRAP_64 684242+#define OP_31_XOP_DCBF 864243#define OP_31_XOP_LBZX 874344#define OP_31_XOP_STWX 1514445#define OP_31_XOP_STBX 215···375374 emulated = kvmppc_emulate_mtspr(vcpu, sprn, rs);376375 break;377376377377+ case OP_31_XOP_DCBF:378378 case OP_31_XOP_DCBI:379379 /* Do nothing. The guest is performing dcbi because380380 * hardware DMA is not snooped by the dcache, but
-6
arch/x86/kernel/cpu/perf_event.c
···340340 /* BTS is currently only allowed for user-mode. */341341 if (!attr->exclude_kernel)342342 return -EOPNOTSUPP;343343-344344- if (!attr->exclude_guest)345345- return -EOPNOTSUPP;346343 }347344348345 hwc->config |= config;···381384{382385 if (event->attr.precise_ip) {383386 int precise = 0;384384-385385- if (!event->attr.exclude_guest)386386- return -EOPNOTSUPP;387387388388 /* Support for constant skid */389389 if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) {
···165165 * Ensure irq/preemption can't change debugctl in between.166166 * Note also that both TIF_BLOCKSTEP and debugctl should167167 * be changed atomically wrt preemption.168168- * FIXME: this means that set/clear TIF_BLOCKSTEP is simply169169- * wrong if task != current, SIGKILL can wakeup the stopped170170- * tracee and set/clear can play with the running task, this171171- * can confuse the next __switch_to_xtra().168168+ *169169+ * NOTE: this means that set/clear TIF_BLOCKSTEP is only safe if170170+ * task is current or it can't be running, otherwise we can race171171+ * with __switch_to_xtra(). We rely on ptrace_freeze_traced() but172172+ * PTRACE_KILL is not safe.172173 */173174 local_irq_disable();174175 debugctl = get_debugctlmsr();
-7
arch/x86/xen/smp.c
···432432 play_dead_common();433433 HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);434434 cpu_bringup();435435- /*436436- * Balance out the preempt calls - as we are running in cpu_idle437437- * loop which has been called at bootup from cpu_bringup_and_idle.438438- * The cpucpu_bringup_and_idle called cpu_bringup which made a439439- * preempt_disable() So this preempt_enable will balance it out.440440- */441441- preempt_enable();442435}443436444437#else /* !CONFIG_HOTPLUG_CPU */
···340340 if ((boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model < 10)341341 || boot_cpu_data.x86 == 0x11) {342342 rdmsr(MSR_AMD_PSTATE_DEF_BASE + index, lo, hi);343343+ /*344344+ * MSR C001_0064+:345345+ * Bit 63: PstateEn. Read-write. If set, the P-state is valid.346346+ */347347+ if (!(hi & BIT(31)))348348+ return;349349+343350 fid = lo & 0x3f;344351 did = (lo >> 6) & 7;345352 if (boot_cpu_data.x86 == 0x10)
+7-1
drivers/ata/ahci.c
···53535454enum {5555 AHCI_PCI_BAR_STA2X11 = 0,5656+ AHCI_PCI_BAR_ENMOTUS = 2,5657 AHCI_PCI_BAR_STANDARD = 5,5758};5859···410409 { PCI_VDEVICE(ASMEDIA, 0x0602), board_ahci }, /* ASM1060 */411410 { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */412411 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */412412+413413+ /* Enmotus */414414+ { PCI_DEVICE(0x1c44, 0x8000), board_ahci },413415414416 /* Generic, PCI class code for AHCI */415417 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,···11021098 dev_info(&pdev->dev,11031099 "PDC42819 can only drive SATA devices with this driver\n");1104110011051105- /* The Connext uses non-standard BAR */11011101+ /* Both Connext and Enmotus devices use non-standard BARs */11061102 if (pdev->vendor == PCI_VENDOR_ID_STMICRO && pdev->device == 0xCC06)11071103 ahci_pci_bar = AHCI_PCI_BAR_STA2X11;11041104+ else if (pdev->vendor == 0x1c44 && pdev->device == 0x8000)11051105+ ahci_pci_bar = AHCI_PCI_BAR_ENMOTUS;1108110611091107 /* acquire resources */11101108 rc = pcim_enable_device(pdev);
+3-3
drivers/ata/libahci.c
···19511951 /* Use the nominal value 10 ms if the read MDAT is zero,19521952 * the nominal value of DETO is 20 ms.19531953 */19541954- if (dev->sata_settings[ATA_LOG_DEVSLP_VALID] &19541954+ if (dev->devslp_timing[ATA_LOG_DEVSLP_VALID] &19551955 ATA_LOG_DEVSLP_VALID_MASK) {19561956- mdat = dev->sata_settings[ATA_LOG_DEVSLP_MDAT] &19561956+ mdat = dev->devslp_timing[ATA_LOG_DEVSLP_MDAT] &19571957 ATA_LOG_DEVSLP_MDAT_MASK;19581958 if (!mdat)19591959 mdat = 10;19601960- deto = dev->sata_settings[ATA_LOG_DEVSLP_DETO];19601960+ deto = dev->devslp_timing[ATA_LOG_DEVSLP_DETO];19611961 if (!deto)19621962 deto = 20;19631963 } else {
+13-9
drivers/ata/libata-core.c
···23252325 }23262326 }2327232723282328- /* check and mark DevSlp capability */23292329- if (ata_id_has_devslp(dev->id))23302330- dev->flags |= ATA_DFLAG_DEVSLP;23312331-23322332- /* Obtain SATA Settings page from Identify Device Data Log,23332333- * which contains DevSlp timing variables etc.23342334- * Exclude old devices with ata_id_has_ncq()23282328+ /* Check and mark DevSlp capability. Get DevSlp timing variables23292329+ * from SATA Settings page of Identify Device Data Log.23352330 */23362336- if (ata_id_has_ncq(dev->id)) {23312331+ if (ata_id_has_devslp(dev->id)) {23322332+ u8 sata_setting[ATA_SECT_SIZE];23332333+ int i, j;23342334+23352335+ dev->flags |= ATA_DFLAG_DEVSLP;23372336 err_mask = ata_read_log_page(dev,23382337 ATA_LOG_SATA_ID_DEV_DATA,23392338 ATA_LOG_SATA_SETTINGS,23402340- dev->sata_settings,23392339+ sata_setting,23412340 1);23422341 if (err_mask)23432342 ata_dev_dbg(dev,23442343 "failed to get Identify Device Data, Emask 0x%x\n",23452344 err_mask);23452345+ else23462346+ for (i = 0; i < ATA_LOG_DEVSLP_SIZE; i++) {23472347+ j = ATA_LOG_DEVSLP_OFFSET + i;23482348+ dev->devslp_timing[i] = sata_setting[j];23492349+ }23462350 }2347235123482352 dev->cdb_len = 16;
+1-1
drivers/ata/libata-eh.c
···20942094 */20952095static inline int ata_eh_worth_retry(struct ata_queued_cmd *qc)20962096{20972097- if (qc->flags & AC_ERR_MEDIA)20972097+ if (qc->err_mask & AC_ERR_MEDIA)20982098 return 0; /* don't retry media errors */20992099 if (qc->flags & ATA_QCFLAG_IO)21002100 return 1; /* otherwise retry anything from fs stack */
···11061106 * @val_count: Number of registers to write11071107 *11081108 * This function is intended to be used for writing a large block of11091109- * data to be device either in single transfer or multiple transfer.11091109+ * data to the device either in single transfer or multiple transfer.11101110 *11111111 * A value of zero will be returned on success, a negative errno will11121112 * be returned in error cases.
+6-1
drivers/block/virtio_blk.c
···889889{890890 struct virtio_blk *vblk = vdev->priv;891891 int index = vblk->index;892892+ int refc;892893893894 /* Prevent config work handler from accessing the device. */894895 mutex_lock(&vblk->config_lock);···904903905904 flush_work(&vblk->config_work);906905906906+ refc = atomic_read(&disk_to_dev(vblk->disk)->kobj.kref.refcount);907907 put_disk(vblk->disk);908908 mempool_destroy(vblk->pool);909909 vdev->config->del_vqs(vdev);910910 kfree(vblk);911911- ida_simple_remove(&vd_index_ida, index);911911+912912+ /* Only free device id if we don't have any users */913913+ if (refc == 1)914914+ ida_simple_remove(&vd_index_ida, index);912915}913916914917#ifdef CONFIG_PM
···106106config X86_POWERNOW_K8107107 tristate "AMD Opteron/Athlon64 PowerNow!"108108 select CPU_FREQ_TABLE109109- depends on ACPI && ACPI_PROCESSOR109109+ depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ110110 help111111 This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors.112112 Support for K10 and newer processors is now in acpi-cpufreq.
···7171 }72727373 if (cpu_reg) {7474+ rcu_read_lock();7475 opp = opp_find_freq_ceil(cpu_dev, &freq_Hz);7576 if (IS_ERR(opp)) {7777+ rcu_read_unlock();7678 pr_err("failed to find OPP for %ld\n", freq_Hz);7779 return PTR_ERR(opp);7880 }7981 volt = opp_get_voltage(opp);8282+ rcu_read_unlock();8083 tol = volt * voltage_tolerance / 100;8184 volt_old = regulator_get_voltage(cpu_reg);8285 }···239236 */240237 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)241238 ;239239+ rcu_read_lock();242240 opp = opp_find_freq_exact(cpu_dev,243241 freq_table[0].frequency * 1000, true);244242 min_uV = opp_get_voltage(opp);245243 opp = opp_find_freq_exact(cpu_dev,246244 freq_table[i-1].frequency * 1000, true);247245 max_uV = opp_get_voltage(opp);246246+ rcu_read_unlock();248247 ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV);249248 if (ret > 0)250249 transition_latency += ret * 1000;
+3
drivers/cpufreq/omap-cpufreq.c
···110110 freq = ret;111111112112 if (mpu_reg) {113113+ rcu_read_lock();113114 opp = opp_find_freq_ceil(mpu_dev, &freq);114115 if (IS_ERR(opp)) {116116+ rcu_read_unlock();115117 dev_err(mpu_dev, "%s: unable to find MPU OPP for %d\n",116118 __func__, freqs.new);117119 return -EINVAL;118120 }119121 volt = opp_get_voltage(opp);122122+ rcu_read_unlock();120123 tol = volt * OPP_TOLERANCE / 100;121124 volt_old = regulator_get_voltage(mpu_reg);122125 }
+5
drivers/devfreq/devfreq.c
···994994 * @freq: The frequency given to target function995995 * @flags: Flags handed from devfreq framework.996996 *997997+ * Locking: This function must be called under rcu_read_lock(). opp is a rcu998998+ * protected pointer. The reason for the same is that the opp pointer which is999999+ * returned will remain valid for use with opp_get_{voltage, freq} only while10001000+ * under the locked area. The pointer returned must be used prior to unlocking10011001+ * with rcu_read_unlock() to maintain the integrity of the pointer.9971002 */9981003struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq,9991004 u32 flags)
+67-27
drivers/devfreq/exynos4_bus.c
···7373#define EX4210_LV_NUM (LV_2 + 1)7474#define EX4x12_LV_NUM (LV_4 + 1)75757676+/**7777+ * struct busfreq_opp_info - opp information for bus7878+ * @rate: Frequency in hertz7979+ * @volt: Voltage in microvolts corresponding to this OPP8080+ */8181+struct busfreq_opp_info {8282+ unsigned long rate;8383+ unsigned long volt;8484+};8585+7686struct busfreq_data {7787 enum exynos4_busf_type type;7888 struct device *dev;···9080 bool disabled;9181 struct regulator *vdd_int;9282 struct regulator *vdd_mif; /* Exynos4412/4212 only */9393- struct opp *curr_opp;8383+ struct busfreq_opp_info curr_oppinfo;9484 struct exynos4_ppmu dmc[2];95859686 struct notifier_block pm_notifier;···306296};307297308298309309-static int exynos4210_set_busclk(struct busfreq_data *data, struct opp *opp)299299+static int exynos4210_set_busclk(struct busfreq_data *data,300300+ struct busfreq_opp_info *oppi)310301{311302 unsigned int index;312303 unsigned int tmp;313304314305 for (index = LV_0; index < EX4210_LV_NUM; index++)315315- if (opp_get_freq(opp) == exynos4210_busclk_table[index].clk)306306+ if (oppi->rate == exynos4210_busclk_table[index].clk)316307 break;317308318309 if (index == EX4210_LV_NUM)···372361 return 0;373362}374363375375-static int exynos4x12_set_busclk(struct busfreq_data *data, struct opp *opp)364364+static int exynos4x12_set_busclk(struct busfreq_data *data,365365+ struct busfreq_opp_info *oppi)376366{377367 unsigned int index;378368 unsigned int tmp;379369380370 for (index = LV_0; index < EX4x12_LV_NUM; index++)381381- if (opp_get_freq(opp) == exynos4x12_mifclk_table[index].clk)371371+ if (oppi->rate == exynos4x12_mifclk_table[index].clk)382372 break;383373384374 if (index == EX4x12_LV_NUM)···588576 return -EINVAL;589577}590578591591-static int exynos4_bus_setvolt(struct busfreq_data *data, struct opp *opp,592592- struct opp *oldopp)579579+static int exynos4_bus_setvolt(struct busfreq_data *data,580580+ struct busfreq_opp_info *oppi,581581+ struct busfreq_opp_info *oldoppi)593582{594583 int err = 0, tmp;595595- unsigned long volt = opp_get_voltage(opp);584584+ unsigned long volt = oppi->volt;596585597586 switch (data->type) {598587 case TYPE_BUSF_EXYNOS4210:···608595 if (err)609596 break;610597611611- tmp = exynos4x12_get_intspec(opp_get_freq(opp));598598+ tmp = exynos4x12_get_intspec(oppi->rate);612599 if (tmp < 0) {613600 err = tmp;614601 regulator_set_voltage(data->vdd_mif,615615- opp_get_voltage(oldopp),602602+ oldoppi->volt,616603 MAX_SAFEVOLT);617604 break;618605 }···622609 /* Try to recover */623610 if (err)624611 regulator_set_voltage(data->vdd_mif,625625- opp_get_voltage(oldopp),612612+ oldoppi->volt,626613 MAX_SAFEVOLT);627614 break;628615 default:···639626 struct platform_device *pdev = container_of(dev, struct platform_device,640627 dev);641628 struct busfreq_data *data = platform_get_drvdata(pdev);642642- struct opp *opp = devfreq_recommended_opp(dev, _freq, flags);643643- unsigned long freq = opp_get_freq(opp);644644- unsigned long old_freq = opp_get_freq(data->curr_opp);629629+ struct opp *opp;630630+ unsigned long freq;631631+ unsigned long old_freq = data->curr_oppinfo.rate;632632+ struct busfreq_opp_info new_oppinfo;645633646646- if (IS_ERR(opp))634634+ rcu_read_lock();635635+ opp = devfreq_recommended_opp(dev, _freq, flags);636636+ if (IS_ERR(opp)) {637637+ rcu_read_unlock();647638 return PTR_ERR(opp);639639+ }640640+ new_oppinfo.rate = opp_get_freq(opp);641641+ new_oppinfo.volt = opp_get_voltage(opp);642642+ rcu_read_unlock();643643+ freq = new_oppinfo.rate;648644649645 if (old_freq == freq)650646 return 0;651647652652- dev_dbg(dev, "targetting %lukHz %luuV\n", freq, opp_get_voltage(opp));648648+ dev_dbg(dev, "targetting %lukHz %luuV\n", freq, new_oppinfo.volt);653649654650 mutex_lock(&data->lock);655651···666644 goto out;667645668646 if (old_freq < freq)669669- err = exynos4_bus_setvolt(data, opp, data->curr_opp);647647+ err = exynos4_bus_setvolt(data, &new_oppinfo,648648+ &data->curr_oppinfo);670649 if (err)671650 goto out;672651673652 if (old_freq != freq) {674653 switch (data->type) {675654 case TYPE_BUSF_EXYNOS4210:676676- err = exynos4210_set_busclk(data, opp);655655+ err = exynos4210_set_busclk(data, &new_oppinfo);677656 break;678657 case TYPE_BUSF_EXYNOS4x12:679679- err = exynos4x12_set_busclk(data, opp);658658+ err = exynos4x12_set_busclk(data, &new_oppinfo);680659 break;681660 default:682661 err = -EINVAL;···687664 goto out;688665689666 if (old_freq > freq)690690- err = exynos4_bus_setvolt(data, opp, data->curr_opp);667667+ err = exynos4_bus_setvolt(data, &new_oppinfo,668668+ &data->curr_oppinfo);691669 if (err)692670 goto out;693671694694- data->curr_opp = opp;672672+ data->curr_oppinfo = new_oppinfo;695673out:696674 mutex_unlock(&data->lock);697675 return err;···726702727703 exynos4_read_ppmu(data);728704 busier_dmc = exynos4_get_busier_dmc(data);729729- stat->current_frequency = opp_get_freq(data->curr_opp);705705+ stat->current_frequency = data->curr_oppinfo.rate;730706731707 if (busier_dmc)732708 addr = S5P_VA_DMC1;···957933 struct busfreq_data *data = container_of(this, struct busfreq_data,958934 pm_notifier);959935 struct opp *opp;936936+ struct busfreq_opp_info new_oppinfo;960937 unsigned long maxfreq = ULONG_MAX;961938 int err = 0;962939···968943969944 data->disabled = true;970945946946+ rcu_read_lock();971947 opp = opp_find_freq_floor(data->dev, &maxfreq);948948+ if (IS_ERR(opp)) {949949+ rcu_read_unlock();950950+ dev_err(data->dev, "%s: unable to find a min freq\n",951951+ __func__);952952+ return PTR_ERR(opp);953953+ }954954+ new_oppinfo.rate = opp_get_freq(opp);955955+ new_oppinfo.volt = opp_get_voltage(opp);956956+ rcu_read_unlock();972957973973- err = exynos4_bus_setvolt(data, opp, data->curr_opp);958958+ err = exynos4_bus_setvolt(data, &new_oppinfo,959959+ &data->curr_oppinfo);974960 if (err)975961 goto unlock;976962977963 switch (data->type) {978964 case TYPE_BUSF_EXYNOS4210:979979- err = exynos4210_set_busclk(data, opp);965965+ err = exynos4210_set_busclk(data, &new_oppinfo);980966 break;981967 case TYPE_BUSF_EXYNOS4x12:982982- err = exynos4x12_set_busclk(data, opp);968968+ err = exynos4x12_set_busclk(data, &new_oppinfo);983969 break;984970 default:985971 err = -EINVAL;···998962 if (err)999963 goto unlock;100096410011001- data->curr_opp = opp;965965+ data->curr_oppinfo = new_oppinfo;1002966unlock:1003967 mutex_unlock(&data->lock);1004968 if (err)···10631027 }10641028 }1065102910301030+ rcu_read_lock();10661031 opp = opp_find_freq_floor(dev, &exynos4_devfreq_profile.initial_freq);10671032 if (IS_ERR(opp)) {10331033+ rcu_read_unlock();10681034 dev_err(dev, "Invalid initial frequency %lu kHz.\n",10691035 exynos4_devfreq_profile.initial_freq);10701036 return PTR_ERR(opp);10711037 }10721072- data->curr_opp = opp;10381038+ data->curr_oppinfo.rate = opp_get_freq(opp);10391039+ data->curr_oppinfo.volt = opp_get_voltage(opp);10401040+ rcu_read_unlock();1073104110741042 platform_set_drvdata(pdev, data);10751043
···539539 total = 0;540540 for (i = 0; i < count; i++) {541541 struct drm_i915_gem_relocation_entry __user *user_relocs;542542+ u64 invalid_offset = (u64)-1;543543+ int j;542544543545 user_relocs = (void __user *)(uintptr_t)exec[i].relocs_ptr;544546···549547 ret = -EFAULT;550548 mutex_lock(&dev->struct_mutex);551549 goto err;550550+ }551551+552552+ /* As we do not update the known relocation offsets after553553+ * relocating (due to the complexities in lock handling),554554+ * we need to mark them as invalid now so that we force the555555+ * relocation processing next time. Just in case the target556556+ * object is evicted and then rebound into its old557557+ * presumed_offset before the next execbuffer - if that558558+ * happened we would make the mistake of assuming that the559559+ * relocations were valid.560560+ */561561+ for (j = 0; j < exec[i].relocation_count; j++) {562562+ if (copy_to_user(&user_relocs[j].presumed_offset,563563+ &invalid_offset,564564+ sizeof(invalid_offset))) {565565+ ret = -EFAULT;566566+ mutex_lock(&dev->struct_mutex);567567+ goto err;568568+ }552569 }553570554571 reloc_offset[i] = total;
···512512#define GEN7_ERR_INT 0x44040513513#define ERR_INT_MMIO_UNCLAIMED (1<<13)514514515515+#define DERRMR 0x44050516516+515517/* GM45+ chicken bits -- debug workaround bits that may be required516518 * for various sorts of correct behavior. The top 16 bits of each are517519 * the enables for writing to the corresponding low bit.
+32-15
drivers/gpu/drm/i915/intel_dp.c
···2579257925802580static void25812581intel_dp_init_panel_power_sequencer(struct drm_device *dev,25822582- struct intel_dp *intel_dp)25822582+ struct intel_dp *intel_dp,25832583+ struct edp_power_seq *out)25832584{25842585 struct drm_i915_private *dev_priv = dev->dev_private;25852586 struct edp_power_seq cur, vbt, spec, final;···26512650 intel_dp->panel_power_cycle_delay = get_delay(t11_t12);26522651#undef get_delay2653265226532653+ DRM_DEBUG_KMS("panel power up delay %d, power down delay %d, power cycle delay %d\n",26542654+ intel_dp->panel_power_up_delay, intel_dp->panel_power_down_delay,26552655+ intel_dp->panel_power_cycle_delay);26562656+26572657+ DRM_DEBUG_KMS("backlight on delay %d, off delay %d\n",26582658+ intel_dp->backlight_on_delay, intel_dp->backlight_off_delay);26592659+26602660+ if (out)26612661+ *out = final;26622662+}26632663+26642664+static void26652665+intel_dp_init_panel_power_sequencer_registers(struct drm_device *dev,26662666+ struct intel_dp *intel_dp,26672667+ struct edp_power_seq *seq)26682668+{26692669+ struct drm_i915_private *dev_priv = dev->dev_private;26702670+ u32 pp_on, pp_off, pp_div;26712671+26542672 /* And finally store the new values in the power sequencer. */26552655- pp_on = (final.t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) |26562656- (final.t8 << PANEL_LIGHT_ON_DELAY_SHIFT);26572657- pp_off = (final.t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) |26582658- (final.t10 << PANEL_POWER_DOWN_DELAY_SHIFT);26732673+ pp_on = (seq->t1_t3 << PANEL_POWER_UP_DELAY_SHIFT) |26742674+ (seq->t8 << PANEL_LIGHT_ON_DELAY_SHIFT);26752675+ pp_off = (seq->t9 << PANEL_LIGHT_OFF_DELAY_SHIFT) |26762676+ (seq->t10 << PANEL_POWER_DOWN_DELAY_SHIFT);26592677 /* Compute the divisor for the pp clock, simply match the Bspec26602678 * formula. */26612679 pp_div = ((100 * intel_pch_rawclk(dev))/2 - 1)26622680 << PP_REFERENCE_DIVIDER_SHIFT;26632663- pp_div |= (DIV_ROUND_UP(final.t11_t12, 1000)26812681+ pp_div |= (DIV_ROUND_UP(seq->t11_t12, 1000)26642682 << PANEL_POWER_CYCLE_DELAY_SHIFT);2665268326662684 /* Haswell doesn't have any port selection bits for the panel···26942674 I915_WRITE(PCH_PP_ON_DELAYS, pp_on);26952675 I915_WRITE(PCH_PP_OFF_DELAYS, pp_off);26962676 I915_WRITE(PCH_PP_DIVISOR, pp_div);26972697-26982698-26992699- DRM_DEBUG_KMS("panel power up delay %d, power down delay %d, power cycle delay %d\n",27002700- intel_dp->panel_power_up_delay, intel_dp->panel_power_down_delay,27012701- intel_dp->panel_power_cycle_delay);27022702-27032703- DRM_DEBUG_KMS("backlight on delay %d, off delay %d\n",27042704- intel_dp->backlight_on_delay, intel_dp->backlight_off_delay);2705267727062678 DRM_DEBUG_KMS("panel power sequencer register settings: PP_ON %#x, PP_OFF %#x, PP_DIV %#x\n",27072679 I915_READ(PCH_PP_ON_DELAYS),···27112699 struct drm_device *dev = intel_encoder->base.dev;27122700 struct drm_i915_private *dev_priv = dev->dev_private;27132701 struct drm_display_mode *fixed_mode = NULL;27022702+ struct edp_power_seq power_seq = { 0 };27142703 enum port port = intel_dig_port->port;27152704 const char *name = NULL;27162705 int type;···27842771 }2785277227862773 if (is_edp(intel_dp))27872787- intel_dp_init_panel_power_sequencer(dev, intel_dp);27742774+ intel_dp_init_panel_power_sequencer(dev, intel_dp, &power_seq);2788277527892776 intel_dp_i2c_init(intel_dp, intel_connector, name);27902777···28102797 intel_dp_destroy(connector);28112798 return;28122799 }28002800+28012801+ /* We now know it's not a ghost, init power sequence regs. */28022802+ intel_dp_init_panel_power_sequencer_registers(dev, intel_dp,28032803+ &power_seq);2813280428142805 ironlake_edp_panel_vdd_on(intel_dp);28152806 edid = drm_get_edid(connector, &intel_dp->adapter);
+12-5
drivers/gpu/drm/i915/intel_pm.c
···42504250static void __gen6_gt_force_wake_mt_reset(struct drm_i915_private *dev_priv)42514251{42524252 I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_DISABLE(0xffff));42534253- POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */42534253+ /* something from same cacheline, but !FORCEWAKE_MT */42544254+ POSTING_READ(ECOBUS);42544255}4255425642564257static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv)···42684267 DRM_ERROR("Timed out waiting for forcewake old ack to clear.\n");4269426842704269 I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_ENABLE(FORCEWAKE_KERNEL));42714271- POSTING_READ(ECOBUS); /* something from same cacheline, but !FORCEWAKE */42704270+ /* something from same cacheline, but !FORCEWAKE_MT */42714271+ POSTING_READ(ECOBUS);4272427242734273 if (wait_for_atomic((I915_READ_NOTRACE(forcewake_ack) & 1),42744274 FORCEWAKE_ACK_TIMEOUT_MS))···43064304static void __gen6_gt_force_wake_put(struct drm_i915_private *dev_priv)43074305{43084306 I915_WRITE_NOTRACE(FORCEWAKE, 0);43094309- /* gen6_gt_check_fifodbg doubles as the POSTING_READ */43074307+ /* something from same cacheline, but !FORCEWAKE */43084308+ POSTING_READ(ECOBUS);43104309 gen6_gt_check_fifodbg(dev_priv);43114310}4312431143134312static void __gen6_gt_force_wake_mt_put(struct drm_i915_private *dev_priv)43144313{43154314 I915_WRITE_NOTRACE(FORCEWAKE_MT, _MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));43164316- /* gen6_gt_check_fifodbg doubles as the POSTING_READ */43154315+ /* something from same cacheline, but !FORCEWAKE_MT */43164316+ POSTING_READ(ECOBUS);43174317 gen6_gt_check_fifodbg(dev_priv);43184318}43194319···43554351static void vlv_force_wake_reset(struct drm_i915_private *dev_priv)43564352{43574353 I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(0xffff));43544354+ /* something from same cacheline, but !FORCEWAKE_VLV */43554355+ POSTING_READ(FORCEWAKE_ACK_VLV);43584356}4359435743604358static void vlv_force_wake_get(struct drm_i915_private *dev_priv)···43774371static void vlv_force_wake_put(struct drm_i915_private *dev_priv)43784372{43794373 I915_WRITE_NOTRACE(FORCEWAKE_VLV, _MASKED_BIT_DISABLE(FORCEWAKE_KERNEL));43804380- /* The below doubles as a POSTING_READ */43744374+ /* something from same cacheline, but !FORCEWAKE_VLV */43754375+ POSTING_READ(FORCEWAKE_ACK_VLV);43814376 gen6_gt_check_fifodbg(dev_priv);43824377}43834378
+6
drivers/gpu/drm/radeon/evergreen.c
···24012401{24022402 struct evergreen_mc_save save;2403240324042404+ if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))24052405+ reset_mask &= ~(RADEON_RESET_GFX | RADEON_RESET_COMPUTE);24062406+24072407+ if (RREG32(DMA_STATUS_REG) & DMA_IDLE)24082408+ reset_mask &= ~RADEON_RESET_DMA;24092409+24042410 if (reset_mask == 0)24052411 return 0;24062412
+6
drivers/gpu/drm/radeon/ni.c
···14091409{14101410 struct evergreen_mc_save save;1411141114121412+ if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))14131413+ reset_mask &= ~(RADEON_RESET_GFX | RADEON_RESET_COMPUTE);14141414+14151415+ if (RREG32(DMA_STATUS_REG) & DMA_IDLE)14161416+ reset_mask &= ~RADEON_RESET_DMA;14171417+14121418 if (reset_mask == 0)14131419 return 0;14141420
+6
drivers/gpu/drm/radeon/r600.c
···13781378{13791379 struct rv515_mc_save save;1380138013811381+ if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))13821382+ reset_mask &= ~(RADEON_RESET_GFX | RADEON_RESET_COMPUTE);13831383+13841384+ if (RREG32(DMA_STATUS_REG) & DMA_IDLE)13851385+ reset_mask &= ~RADEON_RESET_DMA;13861386+13811387 if (reset_mask == 0)13821388 return 0;13831389
···784784 }785785 seq_printf(m, "driver's copy of the wptr: 0x%08x [%5d]\n", ring->wptr, ring->wptr);786786 seq_printf(m, "driver's copy of the rptr: 0x%08x [%5d]\n", ring->rptr, ring->rptr);787787+ seq_printf(m, "last semaphore signal addr : 0x%016llx\n", ring->last_semaphore_signal_addr);788788+ seq_printf(m, "last semaphore wait addr : 0x%016llx\n", ring->last_semaphore_wait_addr);787789 seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);788790 seq_printf(m, "%u dwords in ring\n", count);789791 /* print 8 dw before current rptr as often it's the last executed
+4
drivers/gpu/drm/radeon/radeon_semaphore.c
···9595 /* we assume caller has already allocated space on waiters ring */9696 radeon_semaphore_emit_wait(rdev, waiter, semaphore);97979898+ /* for debugging lockup only, used by sysfs debug files */9999+ rdev->ring[signaler].last_semaphore_signal_addr = semaphore->gpu_addr;100100+ rdev->ring[waiter].last_semaphore_wait_addr = semaphore->gpu_addr;101101+98102 return 0;99103}100104
···344344345345 if (ttm->state == tt_unpopulated) {346346 ret = ttm->bdev->driver->ttm_tt_populate(ttm);347347- if (ret)347347+ if (ret) {348348+ /* if we fail here don't nuke the mm node349349+ * as the bo still owns it */350350+ old_copy.mm_node = NULL;348351 goto out1;352352+ }349353 }350354351355 add = 0;···375371 prot);376372 } else377373 ret = ttm_copy_io_page(new_iomap, old_iomap, page);378378- if (ret)374374+ if (ret) {375375+ /* failing here, means keep old copy as-is */376376+ old_copy.mm_node = NULL;379377 goto out1;378378+ }380379 }381380 mb();382381out2:
+21-14
drivers/hv/hv_balloon.c
···403403 */404404405405struct dm_info_msg {406406- struct dm_info_header header;406406+ struct dm_header hdr;407407 __u32 reserved;408408 __u32 info_size;409409 __u8 info[];···503503504504static void process_info(struct hv_dynmem_device *dm, struct dm_info_msg *msg)505505{506506- switch (msg->header.type) {506506+ struct dm_info_header *info_hdr;507507+508508+ info_hdr = (struct dm_info_header *)msg->info;509509+510510+ switch (info_hdr->type) {507511 case INFO_TYPE_MAX_PAGE_CNT:508512 pr_info("Received INFO_TYPE_MAX_PAGE_CNT\n");509509- pr_info("Data Size is %d\n", msg->header.data_size);513513+ pr_info("Data Size is %d\n", info_hdr->data_size);510514 break;511515 default:512512- pr_info("Received Unknown type: %d\n", msg->header.type);516516+ pr_info("Received Unknown type: %d\n", info_hdr->type);513517 }514518}515519···883879 balloon_onchannelcallback, dev);884880885881 if (ret)886886- return ret;882882+ goto probe_error0;887883888884 dm_device.dev = dev;889885 dm_device.state = DM_INITIALIZING;···895891 kthread_run(dm_thread_func, &dm_device, "hv_balloon");896892 if (IS_ERR(dm_device.thread)) {897893 ret = PTR_ERR(dm_device.thread);898898- goto probe_error0;894894+ goto probe_error1;899895 }900896901897 hv_set_drvdata(dev, &dm_device);···918914 VM_PKT_DATA_INBAND,919915 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);920916 if (ret)921921- goto probe_error1;917917+ goto probe_error2;922918923919 t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);924920 if (t == 0) {925921 ret = -ETIMEDOUT;926926- goto probe_error1;922922+ goto probe_error2;927923 }928924929925 /*···932928 */933929 if (dm_device.state == DM_INIT_ERROR) {934930 ret = -ETIMEDOUT;935935- goto probe_error1;931931+ goto probe_error2;936932 }937933 /*938934 * Now submit our capabilities to the host.···965961 VM_PKT_DATA_INBAND,966962 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);967963 if (ret)968968- goto probe_error1;964964+ goto probe_error2;969965970966 t = wait_for_completion_timeout(&dm_device.host_event, 5*HZ);971967 if (t == 0) {972968 ret = -ETIMEDOUT;973973- goto probe_error1;969969+ goto probe_error2;974970 }975971976972 /*···979975 */980976 if (dm_device.state == DM_INIT_ERROR) {981977 ret = -ETIMEDOUT;982982- goto probe_error1;978978+ goto probe_error2;983979 }984980985981 dm_device.state = DM_INITIALIZED;986982987983 return 0;988984989989-probe_error1:985985+probe_error2:990986 kthread_stop(dm_device.thread);991987992992-probe_error0:988988+probe_error1:993989 vmbus_close(dev->channel);990990+probe_error0:991991+ kfree(send_buffer);994992 return ret;995993}996994···100599910061000 vmbus_close(dev->channel);10071001 kthread_stop(dm->thread);10021002+ kfree(send_buffer);1008100310091004 return 0;10101005}
···556556 mutex_lock(&info->lock);557557558558 format = __find_format(info, fh, fmt->which, info->res_type);559559- if (!format)559559+ if (format)560560 fmt->format = *format;561561 else562562 ret = -EINVAL;
···593593{594594 struct media_entity *source, *sink;595595 unsigned int flags = MEDIA_LNK_FL_ENABLED;596596- int i, ret;596596+ int i, ret = 0;597597598598 for (i = 0; i < FIMC_LITE_MAX_DEVS; i++) {599599 struct fimc_lite *fimc = fmd->fimc_lite[i];
+37-51
drivers/media/platform/s5p-mfc/s5p_mfc.c
···412412}413413414414/* Error handling for interrupt */415415-static void s5p_mfc_handle_error(struct s5p_mfc_ctx *ctx,416416- unsigned int reason, unsigned int err)415415+static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,416416+ struct s5p_mfc_ctx *ctx, unsigned int reason, unsigned int err)417417{418418- struct s5p_mfc_dev *dev;419418 unsigned long flags;420419421421- /* If no context is available then all necessary422422- * processing has been done. */423423- if (ctx == NULL)424424- return;425425-426426- dev = ctx->dev;427420 mfc_err("Interrupt Error: %08x\n", err);428428- s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);429429- wake_up_dev(dev, reason, err);430421431431- /* Error recovery is dependent on the state of context */432432- switch (ctx->state) {433433- case MFCINST_INIT:434434- /* This error had to happen while acquireing instance */435435- case MFCINST_GOT_INST:436436- /* This error had to happen while parsing the header */437437- case MFCINST_HEAD_PARSED:438438- /* This error had to happen while setting dst buffers */439439- case MFCINST_RETURN_INST:440440- /* This error had to happen while releasing instance */441441- clear_work_bit(ctx);442442- wake_up_ctx(ctx, reason, err);443443- if (test_and_clear_bit(0, &dev->hw_lock) == 0)444444- BUG();445445- s5p_mfc_clock_off();446446- ctx->state = MFCINST_ERROR;447447- break;448448- case MFCINST_FINISHING:449449- case MFCINST_FINISHED:450450- case MFCINST_RUNNING:451451- /* It is higly probable that an error occured452452- * while decoding a frame */453453- clear_work_bit(ctx);454454- ctx->state = MFCINST_ERROR;455455- /* Mark all dst buffers as having an error */456456- spin_lock_irqsave(&dev->irqlock, flags);457457- s5p_mfc_hw_call(dev->mfc_ops, cleanup_queue, &ctx->dst_queue,458458- &ctx->vq_dst);459459- /* Mark all src buffers as having an error */460460- s5p_mfc_hw_call(dev->mfc_ops, cleanup_queue, &ctx->src_queue,461461- &ctx->vq_src);462462- spin_unlock_irqrestore(&dev->irqlock, flags);463463- if (test_and_clear_bit(0, &dev->hw_lock) == 0)464464- BUG();465465- s5p_mfc_clock_off();466466- break;467467- default:468468- mfc_err("Encountered an error interrupt which had not been handled\n");469469- break;422422+ if (ctx != NULL) {423423+ /* Error recovery is dependent on the state of context */424424+ switch (ctx->state) {425425+ case MFCINST_RES_CHANGE_INIT:426426+ case MFCINST_RES_CHANGE_FLUSH:427427+ case MFCINST_RES_CHANGE_END:428428+ case MFCINST_FINISHING:429429+ case MFCINST_FINISHED:430430+ case MFCINST_RUNNING:431431+ /* It is higly probable that an error occured432432+ * while decoding a frame */433433+ clear_work_bit(ctx);434434+ ctx->state = MFCINST_ERROR;435435+ /* Mark all dst buffers as having an error */436436+ spin_lock_irqsave(&dev->irqlock, flags);437437+ s5p_mfc_hw_call(dev->mfc_ops, cleanup_queue,438438+ &ctx->dst_queue, &ctx->vq_dst);439439+ /* Mark all src buffers as having an error */440440+ s5p_mfc_hw_call(dev->mfc_ops, cleanup_queue,441441+ &ctx->src_queue, &ctx->vq_src);442442+ spin_unlock_irqrestore(&dev->irqlock, flags);443443+ wake_up_ctx(ctx, reason, err);444444+ break;445445+ default:446446+ clear_work_bit(ctx);447447+ ctx->state = MFCINST_ERROR;448448+ wake_up_ctx(ctx, reason, err);449449+ break;450450+ }470451 }452452+ if (test_and_clear_bit(0, &dev->hw_lock) == 0)453453+ BUG();454454+ s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);455455+ s5p_mfc_clock_off();456456+ wake_up_dev(dev, reason, err);471457 return;472458}473459···618632 dev->warn_start)619633 s5p_mfc_handle_frame(ctx, reason, err);620634 else621621- s5p_mfc_handle_error(ctx, reason, err);635635+ s5p_mfc_handle_error(dev, ctx, reason, err);622636 clear_bit(0, &dev->enter_suspend);623637 break;624638
···921921 * In videobuf we use our internal V4l2_planes struct for922922 * single-planar buffers as well, for simplicity.923923 */924924- if (V4L2_TYPE_IS_OUTPUT(b->type))924924+ if (V4L2_TYPE_IS_OUTPUT(b->type)) {925925 v4l2_planes[0].bytesused = b->bytesused;926926+ v4l2_planes[0].data_offset = 0;927927+ }926928927929 if (b->memory == V4L2_MEMORY_USERPTR) {928930 v4l2_planes[0].m.userptr = b->m.userptr;
+20-12
drivers/mfd/vexpress-sysreg.c
···313313}314314315315316316-void __init vexpress_sysreg_early_init(void __iomem *base)316316+void __init vexpress_sysreg_setup(struct device_node *node)317317{318318- struct device_node *node = of_find_compatible_node(NULL, NULL,319319- "arm,vexpress-sysreg");320320-321321- if (node)322322- base = of_iomap(node, 0);323323-324324- if (WARN_ON(!base))318318+ if (WARN_ON(!vexpress_sysreg_base))325319 return;326326-327327- vexpress_sysreg_base = base;328320329321 if (readl(vexpress_sysreg_base + SYS_MISC) & SYS_MISC_MASTERSITE)330322 vexpress_master_site = VEXPRESS_SITE_DB2;···328336 WARN_ON(!vexpress_sysreg_config_bridge);329337}330338339339+void __init vexpress_sysreg_early_init(void __iomem *base)340340+{341341+ vexpress_sysreg_base = base;342342+ vexpress_sysreg_setup(NULL);343343+}344344+331345void __init vexpress_sysreg_of_early_init(void)332346{333333- vexpress_sysreg_early_init(NULL);347347+ struct device_node *node = of_find_compatible_node(NULL, NULL,348348+ "arm,vexpress-sysreg");349349+350350+ if (node) {351351+ vexpress_sysreg_base = of_iomap(node, 0);352352+ vexpress_sysreg_setup(node);353353+ } else {354354+ pr_info("vexpress-sysreg: No Device Tree node found.");355355+ }334356}335357336358···432426 return -EBUSY;433427 }434428435435- if (!vexpress_sysreg_base)429429+ if (!vexpress_sysreg_base) {436430 vexpress_sysreg_base = devm_ioremap(&pdev->dev, res->start,437431 resource_size(res));432432+ vexpress_sysreg_setup(pdev->dev.of_node);433433+ }438434439435 if (!vexpress_sysreg_base) {440436 dev_err(&pdev->dev, "Failed to obtain base address!\n");
+36-1
drivers/misc/ti-st/st_kim.c
···468468 if (pdata->chip_enable)469469 pdata->chip_enable(kim_gdata);470470471471+ /* Configure BT nShutdown to HIGH state */472472+ gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);473473+ mdelay(5); /* FIXME: a proper toggle */474474+ gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);475475+ mdelay(100);471476 /* re-initialize the completion */472477 INIT_COMPLETION(kim_gdata->ldisc_installed);473478 /* send notification to UIM */···514509 * (b) upon failure to either install ldisc or download firmware.515510 * The function is responsible to (a) notify UIM about un-installation,516511 * (b) flush UART if the ldisc was installed.517517- * (c) invoke platform's chip disabling routine.512512+ * (c) reset BT_EN - pull down nshutdown at the end.513513+ * (d) invoke platform's chip disabling routine.518514 */519515long st_kim_stop(void *kim_data)520516{···546540 pr_err(" timed out waiting for ldisc to be un-installed");547541 err = -ETIMEDOUT;548542 }543543+544544+ /* By default configure BT nShutdown to LOW state */545545+ gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);546546+ mdelay(1);547547+ gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);548548+ mdelay(1);549549+ gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);549550550551 /* platform specific disable */551552 if (pdata->chip_disable)···746733 /* refer to itself */747734 kim_gdata->core_data->kim_data = kim_gdata;748735736736+ /* Claim the chip enable nShutdown gpio from the system */737737+ kim_gdata->nshutdown = pdata->nshutdown_gpio;738738+ err = gpio_request(kim_gdata->nshutdown, "kim");739739+ if (unlikely(err)) {740740+ pr_err(" gpio %ld request failed ", kim_gdata->nshutdown);741741+ return err;742742+ }743743+744744+ /* Configure nShutdown GPIO as output=0 */745745+ err = gpio_direction_output(kim_gdata->nshutdown, 0);746746+ if (unlikely(err)) {747747+ pr_err(" unable to configure gpio %ld", kim_gdata->nshutdown);748748+ return err;749749+ }749750 /* get reference of pdev for request_firmware750751 */751752 kim_gdata->kim_pdev = pdev;···806779807780static int kim_remove(struct platform_device *pdev)808781{782782+ /* free the GPIOs requested */783783+ struct ti_st_plat_data *pdata = pdev->dev.platform_data;809784 struct kim_data_s *kim_gdata;810785811786 kim_gdata = dev_get_drvdata(&pdev->dev);787787+788788+ /* Free the Bluetooth/FM/GPIO789789+ * nShutdown gpio from the system790790+ */791791+ gpio_free(pdata->nshutdown_gpio);792792+ pr_info("nshutdown GPIO Freed");812793813794 debugfs_remove_recursive(kim_debugfs_dir);814795 sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp);
+30-62
drivers/mmc/host/mvsdio.c
···5050 struct timer_list timer;5151 struct mmc_host *mmc;5252 struct device *dev;5353- struct resource *res;5454- int irq;5553 struct clk *clk;5654 int gpio_card_detect;5755 int gpio_write_protect;···716718 if (!r || irq < 0 || !mvsd_data)717719 return -ENXIO;718720719719- r = request_mem_region(r->start, SZ_1K, DRIVER_NAME);720720- if (!r)721721- return -EBUSY;722722-723721 mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev);724722 if (!mmc) {725723 ret = -ENOMEM;···725731 host = mmc_priv(mmc);726732 host->mmc = mmc;727733 host->dev = &pdev->dev;728728- host->res = r;729734 host->base_clock = mvsd_data->clock / 2;735735+ host->clk = ERR_PTR(-EINVAL);730736731737 mmc->ops = &mvsd_ops;732738···746752747753 spin_lock_init(&host->lock);748754749749- host->base = ioremap(r->start, SZ_4K);755755+ host->base = devm_request_and_ioremap(&pdev->dev, r);750756 if (!host->base) {751757 ret = -ENOMEM;752758 goto out;···759765760766 mvsd_power_down(host);761767762762- ret = request_irq(irq, mvsd_irq, 0, DRIVER_NAME, host);768768+ ret = devm_request_irq(&pdev->dev, irq, mvsd_irq, 0, DRIVER_NAME, host);763769 if (ret) {764770 pr_err("%s: cannot assign irq %d\n", DRIVER_NAME, irq);765771 goto out;766766- } else767767- host->irq = irq;772772+ }768773769774 /* Not all platforms can gate the clock, so it is not770775 an error if the clock does not exists. */771771- host->clk = clk_get(&pdev->dev, NULL);772772- if (!IS_ERR(host->clk)) {776776+ host->clk = devm_clk_get(&pdev->dev, NULL);777777+ if (!IS_ERR(host->clk))773778 clk_prepare_enable(host->clk);774774- }775779776780 if (mvsd_data->gpio_card_detect) {777777- ret = gpio_request(mvsd_data->gpio_card_detect,778778- DRIVER_NAME " cd");781781+ ret = devm_gpio_request_one(&pdev->dev,782782+ mvsd_data->gpio_card_detect,783783+ GPIOF_IN, DRIVER_NAME " cd");779784 if (ret == 0) {780780- gpio_direction_input(mvsd_data->gpio_card_detect);781785 irq = gpio_to_irq(mvsd_data->gpio_card_detect);782782- ret = request_irq(irq, mvsd_card_detect_irq,783783- IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING,784784- DRIVER_NAME " cd", host);786786+ ret = devm_request_irq(&pdev->dev, irq,787787+ mvsd_card_detect_irq,788788+ IRQ_TYPE_EDGE_RISING |789789+ IRQ_TYPE_EDGE_FALLING,790790+ DRIVER_NAME " cd", host);785791 if (ret == 0)786792 host->gpio_card_detect =787793 mvsd_data->gpio_card_detect;788794 else789789- gpio_free(mvsd_data->gpio_card_detect);795795+ devm_gpio_free(&pdev->dev,796796+ mvsd_data->gpio_card_detect);790797 }791798 }792799 if (!host->gpio_card_detect)793800 mmc->caps |= MMC_CAP_NEEDS_POLL;794801795802 if (mvsd_data->gpio_write_protect) {796796- ret = gpio_request(mvsd_data->gpio_write_protect,797797- DRIVER_NAME " wp");803803+ ret = devm_gpio_request_one(&pdev->dev,804804+ mvsd_data->gpio_write_protect,805805+ GPIOF_IN, DRIVER_NAME " wp");798806 if (ret == 0) {799799- gpio_direction_input(mvsd_data->gpio_write_protect);800807 host->gpio_write_protect =801808 mvsd_data->gpio_write_protect;802809 }···819824 return 0;820825821826out:822822- if (host) {823823- if (host->irq)824824- free_irq(host->irq, host);825825- if (host->gpio_card_detect) {826826- free_irq(gpio_to_irq(host->gpio_card_detect), host);827827- gpio_free(host->gpio_card_detect);828828- }829829- if (host->gpio_write_protect)830830- gpio_free(host->gpio_write_protect);831831- if (host->base)832832- iounmap(host->base);833833- }834834- if (r)835835- release_resource(r);836836- if (mmc)837837- if (!IS_ERR_OR_NULL(host->clk)) {827827+ if (mmc) {828828+ if (!IS_ERR(host->clk))838829 clk_disable_unprepare(host->clk);839839- clk_put(host->clk);840840- }841830 mmc_free_host(mmc);831831+ }842832843833 return ret;844834}···832852{833853 struct mmc_host *mmc = platform_get_drvdata(pdev);834854835835- if (mmc) {836836- struct mvsd_host *host = mmc_priv(mmc);855855+ struct mvsd_host *host = mmc_priv(mmc);837856838838- if (host->gpio_card_detect) {839839- free_irq(gpio_to_irq(host->gpio_card_detect), host);840840- gpio_free(host->gpio_card_detect);841841- }842842- mmc_remove_host(mmc);843843- free_irq(host->irq, host);844844- if (host->gpio_write_protect)845845- gpio_free(host->gpio_write_protect);846846- del_timer_sync(&host->timer);847847- mvsd_power_down(host);848848- iounmap(host->base);849849- release_resource(host->res);857857+ mmc_remove_host(mmc);858858+ del_timer_sync(&host->timer);859859+ mvsd_power_down(host);850860851851- if (!IS_ERR(host->clk)) {852852- clk_disable_unprepare(host->clk);853853- clk_put(host->clk);854854- }855855- mmc_free_host(mmc);856856- }861861+ if (!IS_ERR(host->clk))862862+ clk_disable_unprepare(host->clk);863863+ mmc_free_host(mmc);864864+857865 platform_set_drvdata(pdev, NULL);858866 return 0;859867}
···771771{772772 struct pci_dev *child;773773774774+ if (aspm_force)775775+ return;776776+774777 /*775778 * Clear any ASPM setup that the firmware has carried out on this bus776779 */
+1-1
drivers/staging/iio/adc/mxs-lradc.c
···239239 struct mxs_lradc *lradc = iio_priv(iio);240240 const uint32_t chan_value = LRADC_CH_ACCUMULATE |241241 ((LRADC_DELAY_TIMER_LOOP - 1) << LRADC_CH_NUM_SAMPLES_OFFSET);242242- int i, j = 0;242242+ unsigned int i, j = 0;243243244244 for_each_set_bit(i, iio->active_scan_mask, iio->masklength) {245245 lradc->buffer[j] = readl(lradc->base + LRADC_CH(j));
···441441 return pty_get_pktmode(tty, (int __user *)arg);442442 case TIOCSIG: /* Send signal to other side of pty */443443 return pty_signal(tty, (int) arg);444444+ case TIOCGPTN: /* TTY returns ENOTTY, but glibc expects EINVAL here */445445+ return -EINVAL;444446 }445447 return -ENOIOCTLCMD;446448}
···604604 vt8500_port->uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;605605606606 vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0);607607- if (vt8500_port->clk) {607607+ if (!IS_ERR(vt8500_port->clk)) {608608 vt8500_port->uart.uartclk = clk_get_rate(vt8500_port->clk);609609 } else {610610 /* use the default of 24Mhz if not specified and warn */
···148148 Variation of ARC USB block used in some Freescale chips.149149150150config USB_EHCI_MXC151151- bool "Support for Freescale i.MX on-chip EHCI USB controller"151151+ tristate "Support for Freescale i.MX on-chip EHCI USB controller"152152 depends on USB_EHCI_HCD && ARCH_MXC153153 select USB_EHCI_ROOT_HUB_TT154154 ---help---
···3838#endif39394040/* statistics can be kept for tuning/monitoring */4141+#ifdef DEBUG4242+#define EHCI_STATS4343+#endif4444+4145struct ehci_stats {4246 /* irq usage */4347 unsigned long normal;···225221#ifdef DEBUG226222 struct dentry *debug_dir;227223#endif224224+225225+ /* platform-specific data -- must come last */226226+ unsigned long priv[0] __aligned(sizeof(s64));228227};229228230229/* convert between an HCD pointer and the corresponding EHCI_HCD */
+9-6
drivers/usb/host/uhci-hcd.c
···447447 return IRQ_NONE;448448 uhci_writew(uhci, status, USBSTS); /* Clear it */449449450450+ spin_lock(&uhci->lock);451451+ if (unlikely(!uhci->is_initialized)) /* not yet configured */452452+ goto done;453453+450454 if (status & ~(USBSTS_USBINT | USBSTS_ERROR | USBSTS_RD)) {451455 if (status & USBSTS_HSE)452456 dev_err(uhci_dev(uhci),···459455 dev_err(uhci_dev(uhci),460456 "host controller process error, something bad happened!\n");461457 if (status & USBSTS_HCH) {462462- spin_lock(&uhci->lock);463458 if (uhci->rh_state >= UHCI_RH_RUNNING) {464459 dev_err(uhci_dev(uhci),465460 "host controller halted, very bad!\n");···475472 * pending unlinks */476473 mod_timer(&hcd->rh_timer, jiffies);477474 }478478- spin_unlock(&uhci->lock);479475 }480476 }481477482482- if (status & USBSTS_RD)478478+ if (status & USBSTS_RD) {479479+ spin_unlock(&uhci->lock);483480 usb_hcd_poll_rh_status(hcd);484484- else {485485- spin_lock(&uhci->lock);481481+ } else {486482 uhci_scan_schedule(uhci);483483+ done:487484 spin_unlock(&uhci->lock);488485 }489486···664661 */665662 mb();666663664664+ spin_lock_irq(&uhci->lock);667665 configure_hc(uhci);668666 uhci->is_initialized = 1;669669- spin_lock_irq(&uhci->lock);670667 start_rh(uhci);671668 spin_unlock_irq(&uhci->lock);672669 return 0;
···2525static int vcpu_online(unsigned int cpu)2626{2727 int err;2828- char dir[32], state[32];2828+ char dir[16], state[16];29293030 sprintf(dir, "cpu/%u", cpu);3131- err = xenbus_scanf(XBT_NIL, dir, "availability", "%s", state);3131+ err = xenbus_scanf(XBT_NIL, dir, "availability", "%15s", state);3232 if (err != 1) {3333 if (!xen_initial_domain())3434 printk(KERN_ERR "XENBUS: Unable to read cpu state\n");
+88-42
drivers/xen/gntdev.c
···5656static atomic_t pages_mapped = ATOMIC_INIT(0);57575858static int use_ptemod;5959+#define populate_freeable_maps use_ptemod59606061struct gntdev_priv {6262+ /* maps with visible offsets in the file descriptor */6163 struct list_head maps;6262- /* lock protects maps from concurrent changes */6464+ /* maps that are not visible; will be freed on munmap.6565+ * Only populated if populate_freeable_maps == 1 */6666+ struct list_head freeable_maps;6767+ /* lock protects maps and freeable_maps */6368 spinlock_t lock;6469 struct mm_struct *mm;6570 struct mmu_notifier mn;···198193 return NULL;199194}200195201201-static void gntdev_put_map(struct grant_map *map)196196+static void gntdev_put_map(struct gntdev_priv *priv, struct grant_map *map)202197{203198 if (!map)204199 return;···211206 if (map->notify.flags & UNMAP_NOTIFY_SEND_EVENT) {212207 notify_remote_via_evtchn(map->notify.event);213208 evtchn_put(map->notify.event);209209+ }210210+211211+ if (populate_freeable_maps && priv) {212212+ spin_lock(&priv->lock);213213+ list_del(&map->next);214214+ spin_unlock(&priv->lock);214215 }215216216217 if (map->pages && !use_ptemod)···312301313302 if (map->notify.flags & UNMAP_NOTIFY_CLEAR_BYTE) {314303 int pgno = (map->notify.addr >> PAGE_SHIFT);315315- if (pgno >= offset && pgno < offset + pages && use_ptemod) {316316- void __user *tmp = (void __user *)317317- map->vma->vm_start + map->notify.addr;318318- err = copy_to_user(tmp, &err, 1);319319- if (err)320320- return -EFAULT;321321- map->notify.flags &= ~UNMAP_NOTIFY_CLEAR_BYTE;322322- } else if (pgno >= offset && pgno < offset + pages) {323323- uint8_t *tmp = kmap(map->pages[pgno]);304304+ if (pgno >= offset && pgno < offset + pages) {305305+ /* No need for kmap, pages are in lowmem */306306+ uint8_t *tmp = pfn_to_kaddr(page_to_pfn(map->pages[pgno]));324307 tmp[map->notify.addr & (PAGE_SIZE-1)] = 0;325325- kunmap(map->pages[pgno]);326308 map->notify.flags &= ~UNMAP_NOTIFY_CLEAR_BYTE;327309 }328310 }···380376static void gntdev_vma_close(struct vm_area_struct *vma)381377{382378 struct grant_map *map = vma->vm_private_data;379379+ struct file *file = vma->vm_file;380380+ struct gntdev_priv *priv = file->private_data;383381384382 pr_debug("gntdev_vma_close %p\n", vma);385385- map->vma = NULL;383383+ if (use_ptemod) {384384+ /* It is possible that an mmu notifier could be running385385+ * concurrently, so take priv->lock to ensure that the vma won't386386+ * vanishing during the unmap_grant_pages call, since we will387387+ * spin here until that completes. Such a concurrent call will388388+ * not do any unmapping, since that has been done prior to389389+ * closing the vma, but it may still iterate the unmap_ops list.390390+ */391391+ spin_lock(&priv->lock);392392+ map->vma = NULL;393393+ spin_unlock(&priv->lock);394394+ }386395 vma->vm_private_data = NULL;387387- gntdev_put_map(map);396396+ gntdev_put_map(priv, map);388397}389398390399static struct vm_operations_struct gntdev_vmops = {···407390408391/* ------------------------------------------------------------------ */409392393393+static void unmap_if_in_range(struct grant_map *map,394394+ unsigned long start, unsigned long end)395395+{396396+ unsigned long mstart, mend;397397+ int err;398398+399399+ if (!map->vma)400400+ return;401401+ if (map->vma->vm_start >= end)402402+ return;403403+ if (map->vma->vm_end <= start)404404+ return;405405+ mstart = max(start, map->vma->vm_start);406406+ mend = min(end, map->vma->vm_end);407407+ pr_debug("map %d+%d (%lx %lx), range %lx %lx, mrange %lx %lx\n",408408+ map->index, map->count,409409+ map->vma->vm_start, map->vma->vm_end,410410+ start, end, mstart, mend);411411+ err = unmap_grant_pages(map,412412+ (mstart - map->vma->vm_start) >> PAGE_SHIFT,413413+ (mend - mstart) >> PAGE_SHIFT);414414+ WARN_ON(err);415415+}416416+410417static void mn_invl_range_start(struct mmu_notifier *mn,411418 struct mm_struct *mm,412419 unsigned long start, unsigned long end)413420{414421 struct gntdev_priv *priv = container_of(mn, struct gntdev_priv, mn);415422 struct grant_map *map;416416- unsigned long mstart, mend;417417- int err;418423419424 spin_lock(&priv->lock);420425 list_for_each_entry(map, &priv->maps, next) {421421- if (!map->vma)422422- continue;423423- if (map->vma->vm_start >= end)424424- continue;425425- if (map->vma->vm_end <= start)426426- continue;427427- mstart = max(start, map->vma->vm_start);428428- mend = min(end, map->vma->vm_end);429429- pr_debug("map %d+%d (%lx %lx), range %lx %lx, mrange %lx %lx\n",430430- map->index, map->count,431431- map->vma->vm_start, map->vma->vm_end,432432- start, end, mstart, mend);433433- err = unmap_grant_pages(map,434434- (mstart - map->vma->vm_start) >> PAGE_SHIFT,435435- (mend - mstart) >> PAGE_SHIFT);436436- WARN_ON(err);426426+ unmap_if_in_range(map, start, end);427427+ }428428+ list_for_each_entry(map, &priv->freeable_maps, next) {429429+ unmap_if_in_range(map, start, end);437430 }438431 spin_unlock(&priv->lock);439432}···464437465438 spin_lock(&priv->lock);466439 list_for_each_entry(map, &priv->maps, next) {440440+ if (!map->vma)441441+ continue;442442+ pr_debug("map %d+%d (%lx %lx)\n",443443+ map->index, map->count,444444+ map->vma->vm_start, map->vma->vm_end);445445+ err = unmap_grant_pages(map, /* offset */ 0, map->count);446446+ WARN_ON(err);447447+ }448448+ list_for_each_entry(map, &priv->freeable_maps, next) {467449 if (!map->vma)468450 continue;469451 pr_debug("map %d+%d (%lx %lx)\n",···502466 return -ENOMEM;503467504468 INIT_LIST_HEAD(&priv->maps);469469+ INIT_LIST_HEAD(&priv->freeable_maps);505470 spin_lock_init(&priv->lock);506471507472 if (use_ptemod) {···537500 while (!list_empty(&priv->maps)) {538501 map = list_entry(priv->maps.next, struct grant_map, next);539502 list_del(&map->next);540540- gntdev_put_map(map);503503+ gntdev_put_map(NULL /* already removed */, map);541504 }505505+ WARN_ON(!list_empty(&priv->freeable_maps));542506543507 if (use_ptemod)544508 mmu_notifier_unregister(&priv->mn, priv->mm);···567529568530 if (unlikely(atomic_add_return(op.count, &pages_mapped) > limit)) {569531 pr_debug("can't map: over limit\n");570570- gntdev_put_map(map);532532+ gntdev_put_map(NULL, map);571533 return err;572534 }573535574536 if (copy_from_user(map->grants, &u->refs,575537 sizeof(map->grants[0]) * op.count) != 0) {576576- gntdev_put_map(map);577577- return err;538538+ gntdev_put_map(NULL, map);539539+ return -EFAULT;578540 }579541580542 spin_lock(&priv->lock);···603565 map = gntdev_find_map_index(priv, op.index >> PAGE_SHIFT, op.count);604566 if (map) {605567 list_del(&map->next);568568+ if (populate_freeable_maps)569569+ list_add_tail(&map->next, &priv->freeable_maps);606570 err = 0;607571 }608572 spin_unlock(&priv->lock);609573 if (map)610610- gntdev_put_map(map);574574+ gntdev_put_map(priv, map);611575 return err;612576}613577···619579 struct ioctl_gntdev_get_offset_for_vaddr op;620580 struct vm_area_struct *vma;621581 struct grant_map *map;582582+ int rv = -EINVAL;622583623584 if (copy_from_user(&op, u, sizeof(op)) != 0)624585 return -EFAULT;625586 pr_debug("priv %p, offset for vaddr %lx\n", priv, (unsigned long)op.vaddr);626587588588+ down_read(¤t->mm->mmap_sem);627589 vma = find_vma(current->mm, op.vaddr);628590 if (!vma || vma->vm_ops != &gntdev_vmops)629629- return -EINVAL;591591+ goto out_unlock;630592631593 map = vma->vm_private_data;632594 if (!map)633633- return -EINVAL;595595+ goto out_unlock;634596635597 op.offset = map->index << PAGE_SHIFT;636598 op.count = map->count;599599+ rv = 0;637600638638- if (copy_to_user(u, &op, sizeof(op)) != 0)601601+ out_unlock:602602+ up_read(¤t->mm->mmap_sem);603603+604604+ if (rv == 0 && copy_to_user(u, &op, sizeof(op)) != 0)639605 return -EFAULT;640640- return 0;606606+ return rv;641607}642608643609static long gntdev_ioctl_notify(struct gntdev_priv *priv, void __user *u)···824778out_put_map:825779 if (use_ptemod)826780 map->vma = NULL;827827- gntdev_put_map(map);781781+ gntdev_put_map(priv, map);828782 return err;829783}830784
+30-20
drivers/xen/grant-table.c
···5656/* External tools reserve first few grant table entries. */5757#define NR_RESERVED_ENTRIES 85858#define GNTTAB_LIST_END 0xffffffff5959-#define GREFS_PER_GRANT_FRAME \6060-(grant_table_version == 1 ? \6161-(PAGE_SIZE / sizeof(struct grant_entry_v1)) : \6262-(PAGE_SIZE / sizeof(union grant_entry_v2)))63596460static grant_ref_t **gnttab_list;6561static unsigned int nr_grant_frames;···150154static grant_status_t *grstatus;151155152156static int grant_table_version;157157+static int grefs_per_grant_frame;153158154159static struct gnttab_free_callback *gnttab_free_callback_list;155160···764767 unsigned int new_nr_grant_frames, extra_entries, i;765768 unsigned int nr_glist_frames, new_nr_glist_frames;766769767767- new_nr_grant_frames = nr_grant_frames + more_frames;768768- extra_entries = more_frames * GREFS_PER_GRANT_FRAME;770770+ BUG_ON(grefs_per_grant_frame == 0);769771770770- nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;772772+ new_nr_grant_frames = nr_grant_frames + more_frames;773773+ extra_entries = more_frames * grefs_per_grant_frame;774774+775775+ nr_glist_frames = (nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;771776 new_nr_glist_frames =772772- (new_nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;777777+ (new_nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;773778 for (i = nr_glist_frames; i < new_nr_glist_frames; i++) {774779 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC);775780 if (!gnttab_list[i])···779780 }780781781782782782- for (i = GREFS_PER_GRANT_FRAME * nr_grant_frames;783783- i < GREFS_PER_GRANT_FRAME * new_nr_grant_frames - 1; i++)783783+ for (i = grefs_per_grant_frame * nr_grant_frames;784784+ i < grefs_per_grant_frame * new_nr_grant_frames - 1; i++)784785 gnttab_entry(i) = i + 1;785786786787 gnttab_entry(i) = gnttab_free_head;787787- gnttab_free_head = GREFS_PER_GRANT_FRAME * nr_grant_frames;788788+ gnttab_free_head = grefs_per_grant_frame * nr_grant_frames;788789 gnttab_free_count += extra_entries;789790790791 nr_grant_frames = new_nr_grant_frames;···956957957958static unsigned nr_status_frames(unsigned nr_grant_frames)958959{959959- return (nr_grant_frames * GREFS_PER_GRANT_FRAME + SPP - 1) / SPP;960960+ BUG_ON(grefs_per_grant_frame == 0);961961+ return (nr_grant_frames * grefs_per_grant_frame + SPP - 1) / SPP;960962}961963962964static int gnttab_map_frames_v1(xen_pfn_t *frames, unsigned int nr_gframes)···11151115 rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1);11161116 if (rc == 0 && gsv.version == 2) {11171117 grant_table_version = 2;11181118+ grefs_per_grant_frame = PAGE_SIZE / sizeof(union grant_entry_v2);11181119 gnttab_interface = &gnttab_v2_ops;11191120 } else if (grant_table_version == 2) {11201121 /*···11281127 panic("we need grant tables version 2, but only version 1 is available");11291128 } else {11301129 grant_table_version = 1;11301130+ grefs_per_grant_frame = PAGE_SIZE / sizeof(struct grant_entry_v1);11311131 gnttab_interface = &gnttab_v1_ops;11321132 }11331133 printk(KERN_INFO "Grant tables using version %d layout.\n",11341134 grant_table_version);11351135}1136113611371137-int gnttab_resume(void)11371137+static int gnttab_setup(void)11381138{11391139 unsigned int max_nr_gframes;1140114011411141- gnttab_request_version();11421141 max_nr_gframes = gnttab_max_grant_frames();11431142 if (max_nr_gframes < nr_grant_frames)11441143 return -ENOSYS;···11611160 return 0;11621161}1163116211631163+int gnttab_resume(void)11641164+{11651165+ gnttab_request_version();11661166+ return gnttab_setup();11671167+}11681168+11641169int gnttab_suspend(void)11651170{11661171 gnttab_interface->unmap_frames();···11781171 int rc;11791172 unsigned int cur, extra;1180117311741174+ BUG_ON(grefs_per_grant_frame == 0);11811175 cur = nr_grant_frames;11821182- extra = ((req_entries + (GREFS_PER_GRANT_FRAME-1)) /11831183- GREFS_PER_GRANT_FRAME);11761176+ extra = ((req_entries + (grefs_per_grant_frame-1)) /11771177+ grefs_per_grant_frame);11841178 if (cur + extra > gnttab_max_grant_frames())11851179 return -ENOSPC;11861180···11991191 unsigned int nr_init_grefs;12001192 int ret;1201119311941194+ gnttab_request_version();12021195 nr_grant_frames = 1;12031196 boot_max_nr_grant_frames = __max_nr_grant_frames();1204119712051198 /* Determine the maximum number of frames required for the12061199 * grant reference free list on the current hypervisor.12071200 */12011201+ BUG_ON(grefs_per_grant_frame == 0);12081202 max_nr_glist_frames = (boot_max_nr_grant_frames *12091209- GREFS_PER_GRANT_FRAME / RPP);12031203+ grefs_per_grant_frame / RPP);1210120412111205 gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *),12121206 GFP_KERNEL);12131207 if (gnttab_list == NULL)12141208 return -ENOMEM;1215120912161216- nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;12101210+ nr_glist_frames = (nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;12171211 for (i = 0; i < nr_glist_frames; i++) {12181212 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);12191213 if (gnttab_list[i] == NULL) {···12241214 }12251215 }1226121612271227- if (gnttab_resume() < 0) {12171217+ if (gnttab_setup() < 0) {12281218 ret = -ENODEV;12291219 goto ini_nomem;12301220 }1231122112321232- nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME;12221222+ nr_init_grefs = nr_grant_frames * grefs_per_grant_frame;1233122312341224 for (i = NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++)12351225 gnttab_entry(i) = i + 1;
+47-42
drivers/xen/privcmd.c
···199199 LIST_HEAD(pagelist);200200 struct mmap_mfn_state state;201201202202- if (!xen_initial_domain())203203- return -EPERM;204204-205202 /* We only support privcmd_ioctl_mmap_batch for auto translated. */206203 if (xen_feature(XENFEAT_auto_translated_physmap))207204 return -ENOSYS;···258261 * -ENOENT if at least 1 -ENOENT has happened.259262 */260263 int global_error;261261- /* An array for individual errors */262262- int *err;264264+ int version;263265264266 /* User-space mfn array to store errors in the second pass for V1. */265267 xen_pfn_t __user *user_mfn;268268+ /* User-space int array to store errors in the second pass for V2. */269269+ int __user *user_err;266270};267271268272/* auto translated dom0 note: if domU being created is PV, then mfn is···286288 &cur_page);287289288290 /* Store error code for second pass. */289289- *(st->err++) = ret;291291+ if (st->version == 1) {292292+ if (ret < 0) {293293+ /*294294+ * V1 encodes the error codes in the 32bit top nibble of the295295+ * mfn (with its known limitations vis-a-vis 64 bit callers).296296+ */297297+ *mfnp |= (ret == -ENOENT) ?298298+ PRIVCMD_MMAPBATCH_PAGED_ERROR :299299+ PRIVCMD_MMAPBATCH_MFN_ERROR;300300+ }301301+ } else { /* st->version == 2 */302302+ *((int *) mfnp) = ret;303303+ }290304291305 /* And see if it affects the global_error. */292306 if (ret < 0) {···315305 return 0;316306}317307318318-static int mmap_return_errors_v1(void *data, void *state)308308+static int mmap_return_errors(void *data, void *state)319309{320320- xen_pfn_t *mfnp = data;321310 struct mmap_batch_state *st = state;322322- int err = *(st->err++);323311324324- /*325325- * V1 encodes the error codes in the 32bit top nibble of the326326- * mfn (with its known limitations vis-a-vis 64 bit callers).327327- */328328- *mfnp |= (err == -ENOENT) ?329329- PRIVCMD_MMAPBATCH_PAGED_ERROR :330330- PRIVCMD_MMAPBATCH_MFN_ERROR;331331- return __put_user(*mfnp, st->user_mfn++);312312+ if (st->version == 1) {313313+ xen_pfn_t mfnp = *((xen_pfn_t *) data);314314+ if (mfnp & PRIVCMD_MMAPBATCH_MFN_ERROR)315315+ return __put_user(mfnp, st->user_mfn++);316316+ else317317+ st->user_mfn++;318318+ } else { /* st->version == 2 */319319+ int err = *((int *) data);320320+ if (err)321321+ return __put_user(err, st->user_err++);322322+ else323323+ st->user_err++;324324+ }325325+326326+ return 0;332327}333328334329/* Allocate pfns that are then mapped with gmfns from foreign domid. Update···372357 struct vm_area_struct *vma;373358 unsigned long nr_pages;374359 LIST_HEAD(pagelist);375375- int *err_array = NULL;376360 struct mmap_batch_state state;377377-378378- if (!xen_initial_domain())379379- return -EPERM;380361381362 switch (version) {382363 case 1:···407396 goto out;408397 }409398410410- err_array = kcalloc(m.num, sizeof(int), GFP_KERNEL);411411- if (err_array == NULL) {412412- ret = -ENOMEM;413413- goto out;399399+ if (version == 2) {400400+ /* Zero error array now to only copy back actual errors. */401401+ if (clear_user(m.err, sizeof(int) * m.num)) {402402+ ret = -EFAULT;403403+ goto out;404404+ }414405 }415406416407 down_write(&mm->mmap_sem);···440427 state.va = m.addr;441428 state.index = 0;442429 state.global_error = 0;443443- state.err = err_array;430430+ state.version = version;444431445432 /* mmap_batch_fn guarantees ret == 0 */446433 BUG_ON(traverse_pages(m.num, sizeof(xen_pfn_t),···448435449436 up_write(&mm->mmap_sem);450437451451- if (version == 1) {452452- if (state.global_error) {453453- /* Write back errors in second pass. */454454- state.user_mfn = (xen_pfn_t *)m.arr;455455- state.err = err_array;456456- ret = traverse_pages(m.num, sizeof(xen_pfn_t),457457- &pagelist, mmap_return_errors_v1, &state);458458- } else459459- ret = 0;460460-461461- } else if (version == 2) {462462- ret = __copy_to_user(m.err, err_array, m.num * sizeof(int));463463- if (ret)464464- ret = -EFAULT;465465- }438438+ if (state.global_error) {439439+ /* Write back errors in second pass. */440440+ state.user_mfn = (xen_pfn_t *)m.arr;441441+ state.user_err = m.err;442442+ ret = traverse_pages(m.num, sizeof(xen_pfn_t),443443+ &pagelist, mmap_return_errors, &state);444444+ } else445445+ ret = 0;466446467447 /* If we have not had any EFAULT-like global errors then set the global468448 * error to -ENOENT if necessary. */···463457 ret = -ENOENT;464458465459out:466466- kfree(err_array);467460 free_page_list(&pagelist);468461469462 return ret;
+1-1
drivers/xen/xen-pciback/pciback.h
···124124static inline void xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev,125125 struct pci_dev *dev)126126{127127- if (xen_pcibk_backend && xen_pcibk_backend->free)127127+ if (xen_pcibk_backend && xen_pcibk_backend->release)128128 return xen_pcibk_backend->release(pdev, dev);129129}130130
-10
fs/Kconfig
···6868source "fs/autofs4/Kconfig"6969source "fs/fuse/Kconfig"70707171-config CUSE7272- tristate "Character device in Userspace support"7373- depends on FUSE_FS7474- help7575- This FUSE extension allows character devices to be7676- implemented in userspace.7777-7878- If you want to develop or use userspace character device7979- based on CUSE, answer Y or M.8080-8171config GENERIC_ACL8272 bool8373 select FS_POSIX_ACL
+4-2
fs/btrfs/extent-tree.c
···39973997 * We make the other tasks wait for the flush only when we can flush39983998 * all things.39993999 */40004000- if (ret && flush == BTRFS_RESERVE_FLUSH_ALL) {40004000+ if (ret && flush != BTRFS_RESERVE_NO_FLUSH) {40014001 flushing = true;40024002 space_info->flush = 1;40034003 }···55605560 int empty_cluster = 2 * 1024 * 1024;55615561 struct btrfs_space_info *space_info;55625562 int loop = 0;55635563- int index = 0;55635563+ int index = __get_raid_index(data);55645564 int alloc_type = (data & BTRFS_BLOCK_GROUP_DATA) ?55655565 RESERVE_ALLOC_NO_ACCOUNT : RESERVE_ALLOC;55665566 bool found_uncached_bg = false;···67886788 &wc->flags[level]);67896789 if (ret < 0) {67906790 btrfs_tree_unlock_rw(eb, path->locks[level]);67916791+ path->locks[level] = 0;67916792 return ret;67926793 }67936794 BUG_ON(wc->refs[level] == 0);67946795 if (wc->refs[level] == 1) {67956796 btrfs_tree_unlock_rw(eb, path->locks[level]);67976797+ path->locks[level] = 0;67966798 return 1;67976799 }67986800 }
···18621862{18631863 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;18641864 struct btrfs_free_space *info;18651865- int ret = 0;18651865+ int ret;18661866+ bool re_search = false;1866186718671868 spin_lock(&ctl->tree_lock);1868186918691870again:18711871+ ret = 0;18701872 if (!bytes)18711873 goto out_lock;18721874···18811879 info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset),18821880 1, 0);18831881 if (!info) {18841884- /* the tree logging code might be calling us before we18851885- * have fully loaded the free space rbtree for this18861886- * block group. So it is possible the entry won't18871887- * be in the rbtree yet at all. The caching code18881888- * will make sure not to put it in the rbtree if18891889- * the logging code has pinned it.18821882+ /*18831883+ * If we found a partial bit of our free space in a18841884+ * bitmap but then couldn't find the other part this may18851885+ * be a problem, so WARN about it.18901886 */18871887+ WARN_ON(re_search);18911888 goto out_lock;18921889 }18931890 }1894189118921892+ re_search = false;18951893 if (!info->bitmap) {18961894 unlink_free_space(ctl, info);18971895 if (offset == info->offset) {···19371935 }1938193619391937 ret = remove_from_bitmap(ctl, info, &offset, &bytes);19401940- if (ret == -EAGAIN)19381938+ if (ret == -EAGAIN) {19391939+ re_search = true;19411940 goto again;19411941+ }19421942 BUG_ON(ret); /* logic error */19431943out_lock:19441944 spin_unlock(&ctl->tree_lock);
+102-35
fs/btrfs/inode.c
···8888 [S_IFLNK >> S_SHIFT] = BTRFS_FT_SYMLINK,8989};90909191-static int btrfs_setsize(struct inode *inode, loff_t newsize);9191+static int btrfs_setsize(struct inode *inode, struct iattr *attr);9292static int btrfs_truncate(struct inode *inode);9393static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);9494static noinline int cow_file_range(struct inode *inode,···24782478 continue;24792479 }24802480 nr_truncate++;24812481+24822482+ /* 1 for the orphan item deletion. */24832483+ trans = btrfs_start_transaction(root, 1);24842484+ if (IS_ERR(trans)) {24852485+ ret = PTR_ERR(trans);24862486+ goto out;24872487+ }24882488+ ret = btrfs_orphan_add(trans, inode);24892489+ btrfs_end_transaction(trans, root);24902490+ if (ret)24912491+ goto out;24922492+24812493 ret = btrfs_truncate(inode);24822494 } else {24832495 nr_unlink++;···36773665 block_end - cur_offset, 0);36783666 if (IS_ERR(em)) {36793667 err = PTR_ERR(em);36683668+ em = NULL;36803669 break;36813670 }36823671 last_byte = min(extent_map_end(em), block_end);···37613748 return err;37623749}3763375037643764-static int btrfs_setsize(struct inode *inode, loff_t newsize)37513751+static int btrfs_setsize(struct inode *inode, struct iattr *attr)37653752{37663753 struct btrfs_root *root = BTRFS_I(inode)->root;37673754 struct btrfs_trans_handle *trans;37683755 loff_t oldsize = i_size_read(inode);37563756+ loff_t newsize = attr->ia_size;37573757+ int mask = attr->ia_valid;37693758 int ret;3770375937713760 if (newsize == oldsize)37723761 return 0;37623762+37633763+ /*37643764+ * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a37653765+ * special case where we need to update the times despite not having37663766+ * these flags set. For all other operations the VFS set these flags37673767+ * explicitly if it wants a timestamp update.37683768+ */37693769+ if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME))))37703770+ inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);3773377137743772 if (newsize > oldsize) {37753773 truncate_pagecache(inode, oldsize, newsize);···38073783 set_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,38083784 &BTRFS_I(inode)->runtime_flags);3809378537863786+ /*37873787+ * 1 for the orphan item we're going to add37883788+ * 1 for the orphan item deletion.37893789+ */37903790+ trans = btrfs_start_transaction(root, 2);37913791+ if (IS_ERR(trans))37923792+ return PTR_ERR(trans);37933793+37943794+ /*37953795+ * We need to do this in case we fail at _any_ point during the37963796+ * actual truncate. Once we do the truncate_setsize we could37973797+ * invalidate pages which forces any outstanding ordered io to37983798+ * be instantly completed which will give us extents that need37993799+ * to be truncated. If we fail to get an orphan inode down we38003800+ * could have left over extents that were never meant to live,38013801+ * so we need to garuntee from this point on that everything38023802+ * will be consistent.38033803+ */38043804+ ret = btrfs_orphan_add(trans, inode);38053805+ btrfs_end_transaction(trans, root);38063806+ if (ret)38073807+ return ret;38083808+38103809 /* we don't support swapfiles, so vmtruncate shouldn't fail */38113810 truncate_setsize(inode, newsize);38123811 ret = btrfs_truncate(inode);38123812+ if (ret && inode->i_nlink)38133813+ btrfs_orphan_del(NULL, inode);38133814 }3814381538153816 return ret;···38543805 return err;3855380638563807 if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) {38573857- err = btrfs_setsize(inode, attr->ia_size);38083808+ err = btrfs_setsize(inode, attr);38583809 if (err)38593810 return err;38603811 }···56215572 return em;56225573 if (em) {56235574 /*56245624- * if our em maps to a hole, there might56255625- * actually be delalloc bytes behind it55755575+ * if our em maps to55765576+ * - a hole or55775577+ * - a pre-alloc extent,55785578+ * there might actually be delalloc bytes behind it.56265579 */56275627- if (em->block_start != EXTENT_MAP_HOLE)55805580+ if (em->block_start != EXTENT_MAP_HOLE &&55815581+ !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))56285582 return em;56295583 else56305584 hole_em = em;···57095657 */57105658 em->block_start = hole_em->block_start;57115659 em->block_len = hole_len;56605660+ if (test_bit(EXTENT_FLAG_PREALLOC, &hole_em->flags))56615661+ set_bit(EXTENT_FLAG_PREALLOC, &em->flags);57125662 } else {57135663 em->start = range_start;57145664 em->len = found;···6969691569706916 /*69716917 * 1 for the truncate slack space69726972- * 1 for the orphan item we're going to add69736973- * 1 for the orphan item deletion69746918 * 1 for updating the inode.69756919 */69766976- trans = btrfs_start_transaction(root, 4);69206920+ trans = btrfs_start_transaction(root, 2);69776921 if (IS_ERR(trans)) {69786922 err = PTR_ERR(trans);69796923 goto out;···69816929 ret = btrfs_block_rsv_migrate(&root->fs_info->trans_block_rsv, rsv,69826930 min_size);69836931 BUG_ON(ret);69846984-69856985- ret = btrfs_orphan_add(trans, inode);69866986- if (ret) {69876987- btrfs_end_transaction(trans, root);69886988- goto out;69896989- }6990693269916933 /*69926934 * setattr is responsible for setting the ordered_data_close flag,···70507004 ret = btrfs_orphan_del(trans, inode);70517005 if (ret)70527006 err = ret;70537053- } else if (ret && inode->i_nlink > 0) {70547054- /*70557055- * Failed to do the truncate, remove us from the in memory70567056- * orphan list.70577057- */70587058- ret = btrfs_orphan_del(NULL, inode);70597007 }7060700870617009 if (trans) {···75717531 */75727532int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput)75737533{75747574- struct list_head *head = &root->fs_info->delalloc_inodes;75757534 struct btrfs_inode *binode;75767535 struct inode *inode;75777536 struct btrfs_delalloc_work *work, *next;75787537 struct list_head works;75387538+ struct list_head splice;75797539 int ret = 0;7580754075817541 if (root->fs_info->sb->s_flags & MS_RDONLY)75827542 return -EROFS;7583754375847544 INIT_LIST_HEAD(&works);75857585-75457545+ INIT_LIST_HEAD(&splice);75467546+again:75867547 spin_lock(&root->fs_info->delalloc_lock);75877587- while (!list_empty(head)) {75887588- binode = list_entry(head->next, struct btrfs_inode,75487548+ list_splice_init(&root->fs_info->delalloc_inodes, &splice);75497549+ while (!list_empty(&splice)) {75507550+ binode = list_entry(splice.next, struct btrfs_inode,75897551 delalloc_inodes);75527552+75537553+ list_del_init(&binode->delalloc_inodes);75547554+75907555 inode = igrab(&binode->vfs_inode);75917556 if (!inode)75927592- list_del_init(&binode->delalloc_inodes);75577557+ continue;75587558+75597559+ list_add_tail(&binode->delalloc_inodes,75607560+ &root->fs_info->delalloc_inodes);75937561 spin_unlock(&root->fs_info->delalloc_lock);75947594- if (inode) {75957595- work = btrfs_alloc_delalloc_work(inode, 0, delay_iput);75967596- if (!work) {75977597- ret = -ENOMEM;75987598- goto out;75997599- }76007600- list_add_tail(&work->list, &works);76017601- btrfs_queue_worker(&root->fs_info->flush_workers,76027602- &work->work);75627562+75637563+ work = btrfs_alloc_delalloc_work(inode, 0, delay_iput);75647564+ if (unlikely(!work)) {75657565+ ret = -ENOMEM;75667566+ goto out;76037567 }75687568+ list_add_tail(&work->list, &works);75697569+ btrfs_queue_worker(&root->fs_info->flush_workers,75707570+ &work->work);75717571+76047572 cond_resched();76057573 spin_lock(&root->fs_info->delalloc_lock);75747574+ }75757575+ spin_unlock(&root->fs_info->delalloc_lock);75767576+75777577+ list_for_each_entry_safe(work, next, &works, list) {75787578+ list_del_init(&work->list);75797579+ btrfs_wait_and_free_delalloc_work(work);75807580+ }75817581+75827582+ spin_lock(&root->fs_info->delalloc_lock);75837583+ if (!list_empty(&root->fs_info->delalloc_inodes)) {75847584+ spin_unlock(&root->fs_info->delalloc_lock);75857585+ goto again;76067586 }76077587 spin_unlock(&root->fs_info->delalloc_lock);76087588···76387578 atomic_read(&root->fs_info->async_delalloc_pages) == 0));76397579 }76407580 atomic_dec(&root->fs_info->async_submit_draining);75817581+ return 0;76417582out:76427583 list_for_each_entry_safe(work, next, &works, list) {76437584 list_del_init(&work->list);76447585 btrfs_wait_and_free_delalloc_work(work);75867586+ }75877587+75887588+ if (!list_empty_careful(&splice)) {75897589+ spin_lock(&root->fs_info->delalloc_lock);75907590+ list_splice_tail(&splice, &root->fs_info->delalloc_inodes);75917591+ spin_unlock(&root->fs_info->delalloc_lock);76457592 }76467593 return ret;76477594}
+94-35
fs/btrfs/ioctl.c
···13391339 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running,13401340 1)) {13411341 pr_info("btrfs: dev add/delete/balance/replace/resize operation in progress\n");13421342- return -EINPROGRESS;13421342+ mnt_drop_write_file(file);13431343+ return -EINVAL;13431344 }1344134513451346 mutex_lock(&root->fs_info->volume_mutex);···13631362 printk(KERN_INFO "btrfs: resizing devid %llu\n",13641363 (unsigned long long)devid);13651364 }13651365+13661366 device = btrfs_find_device(root->fs_info, devid, NULL, NULL);13671367 if (!device) {13681368 printk(KERN_INFO "btrfs: resizer unable to find device %llu\n",···13711369 ret = -EINVAL;13721370 goto out_free;13731371 }13741374- if (device->fs_devices && device->fs_devices->seeding) {13721372+13731373+ if (!device->writeable) {13751374 printk(KERN_INFO "btrfs: resizer unable to apply on "13761376- "seeding device %llu\n",13751375+ "readonly device %llu\n",13771376 (unsigned long long)devid);13781377 ret = -EINVAL;13791378 goto out_free;···14461443 kfree(vol_args);14471444out:14481445 mutex_unlock(&root->fs_info->volume_mutex);14491449- mnt_drop_write_file(file);14501446 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);14471447+ mnt_drop_write_file(file);14511448 return ret;14521449}14531450···20982095 err = inode_permission(inode, MAY_WRITE | MAY_EXEC);20992096 if (err)21002097 goto out_dput;21012101-21022102- /* check if subvolume may be deleted by a non-root user */21032103- err = btrfs_may_delete(dir, dentry, 1);21042104- if (err)21052105- goto out_dput;21062098 }20992099+21002100+ /* check if subvolume may be deleted by a user */21012101+ err = btrfs_may_delete(dir, dentry, 1);21022102+ if (err)21032103+ goto out_dput;2107210421082105 if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) {21092106 err = -EINVAL;···21862183 struct btrfs_ioctl_defrag_range_args *range;21872184 int ret;2188218521892189- if (btrfs_root_readonly(root))21902190- return -EROFS;21862186+ ret = mnt_want_write_file(file);21872187+ if (ret)21882188+ return ret;2191218921922190 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running,21932191 1)) {21942192 pr_info("btrfs: dev add/delete/balance/replace/resize operation in progress\n");21952195- return -EINPROGRESS;21932193+ mnt_drop_write_file(file);21942194+ return -EINVAL;21962195 }21972197- ret = mnt_want_write_file(file);21982198- if (ret) {21992199- atomic_set(&root->fs_info->mutually_exclusive_operation_running,22002200- 0);22012201- return ret;21962196+21972197+ if (btrfs_root_readonly(root)) {21982198+ ret = -EROFS;21992199+ goto out;22022200 }2203220122042202 switch (inode->i_mode & S_IFMT) {···22512247 ret = -EINVAL;22522248 }22532249out:22542254- mnt_drop_write_file(file);22552250 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);22512251+ mnt_drop_write_file(file);22562252 return ret;22572253}22582254···22672263 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running,22682264 1)) {22692265 pr_info("btrfs: dev add/delete/balance/replace/resize operation in progress\n");22702270- return -EINPROGRESS;22662266+ return -EINVAL;22712267 }2272226822732269 mutex_lock(&root->fs_info->volume_mutex);···23042300 1)) {23052301 pr_info("btrfs: dev add/delete/balance/replace/resize operation in progress\n");23062302 mnt_drop_write_file(file);23072307- return -EINPROGRESS;23032303+ return -EINVAL;23082304 }2309230523102306 mutex_lock(&root->fs_info->volume_mutex);···23202316 kfree(vol_args);23212317out:23222318 mutex_unlock(&root->fs_info->volume_mutex);23232323- mnt_drop_write_file(file);23242319 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);23202320+ mnt_drop_write_file(file);23252321 return ret;23262322}23272323···34413437 struct btrfs_fs_info *fs_info = root->fs_info;34423438 struct btrfs_ioctl_balance_args *bargs;34433439 struct btrfs_balance_control *bctl;34403440+ bool need_unlock; /* for mut. excl. ops lock */34443441 int ret;34453445- int need_to_clear_lock = 0;3446344234473443 if (!capable(CAP_SYS_ADMIN))34483444 return -EPERM;···34513447 if (ret)34523448 return ret;3453344934543454- mutex_lock(&fs_info->volume_mutex);34503450+again:34513451+ if (!atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1)) {34523452+ mutex_lock(&fs_info->volume_mutex);34533453+ mutex_lock(&fs_info->balance_mutex);34543454+ need_unlock = true;34553455+ goto locked;34563456+ }34573457+34583458+ /*34593459+ * mut. excl. ops lock is locked. Three possibilites:34603460+ * (1) some other op is running34613461+ * (2) balance is running34623462+ * (3) balance is paused -- special case (think resume)34633463+ */34553464 mutex_lock(&fs_info->balance_mutex);34653465+ if (fs_info->balance_ctl) {34663466+ /* this is either (2) or (3) */34673467+ if (!atomic_read(&fs_info->balance_running)) {34683468+ mutex_unlock(&fs_info->balance_mutex);34693469+ if (!mutex_trylock(&fs_info->volume_mutex))34703470+ goto again;34713471+ mutex_lock(&fs_info->balance_mutex);34723472+34733473+ if (fs_info->balance_ctl &&34743474+ !atomic_read(&fs_info->balance_running)) {34753475+ /* this is (3) */34763476+ need_unlock = false;34773477+ goto locked;34783478+ }34793479+34803480+ mutex_unlock(&fs_info->balance_mutex);34813481+ mutex_unlock(&fs_info->volume_mutex);34823482+ goto again;34833483+ } else {34843484+ /* this is (2) */34853485+ mutex_unlock(&fs_info->balance_mutex);34863486+ ret = -EINPROGRESS;34873487+ goto out;34883488+ }34893489+ } else {34903490+ /* this is (1) */34913491+ mutex_unlock(&fs_info->balance_mutex);34923492+ pr_info("btrfs: dev add/delete/balance/replace/resize operation in progress\n");34933493+ ret = -EINVAL;34943494+ goto out;34953495+ }34963496+34973497+locked:34983498+ BUG_ON(!atomic_read(&fs_info->mutually_exclusive_operation_running));3456349934573500 if (arg) {34583501 bargs = memdup_user(arg, sizeof(*bargs));34593502 if (IS_ERR(bargs)) {34603503 ret = PTR_ERR(bargs);34613461- goto out;35043504+ goto out_unlock;34623505 }3463350634643507 if (bargs->flags & BTRFS_BALANCE_RESUME) {···35253474 bargs = NULL;35263475 }3527347635283528- if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running,35293529- 1)) {35303530- pr_info("btrfs: dev add/delete/balance/replace/resize operation in progress\n");34773477+ if (fs_info->balance_ctl) {35313478 ret = -EINPROGRESS;35323479 goto out_bargs;35333480 }35343534- need_to_clear_lock = 1;3535348135363482 bctl = kzalloc(sizeof(*bctl), GFP_NOFS);35373483 if (!bctl) {···35493501 }3550350235513503do_balance:35523552- ret = btrfs_balance(bctl, bargs);35533504 /*35543554- * bctl is freed in __cancel_balance or in free_fs_info if35553555- * restriper was paused all the way until unmount35053505+ * Ownership of bctl and mutually_exclusive_operation_running35063506+ * goes to to btrfs_balance. bctl is freed in __cancel_balance,35073507+ * or, if restriper was paused all the way until unmount, in35083508+ * free_fs_info. mutually_exclusive_operation_running is35093509+ * cleared in __cancel_balance.35563510 */35113511+ need_unlock = false;35123512+35133513+ ret = btrfs_balance(bctl, bargs);35143514+35573515 if (arg) {35583516 if (copy_to_user(arg, bargs, sizeof(*bargs)))35593517 ret = -EFAULT;···3567351335683514out_bargs:35693515 kfree(bargs);35703570-out:35713571- if (need_to_clear_lock)35723572- atomic_set(&root->fs_info->mutually_exclusive_operation_running,35733573- 0);35163516+out_unlock:35743517 mutex_unlock(&fs_info->balance_mutex);35753518 mutex_unlock(&fs_info->volume_mutex);35193519+ if (need_unlock)35203520+ atomic_set(&fs_info->mutually_exclusive_operation_running, 0);35213521+out:35763522 mnt_drop_write_file(file);35773523 return ret;35783524}···37503696 if (IS_ERR(sa)) {37513697 ret = PTR_ERR(sa);37523698 goto drop_write;36993699+ }37003700+37013701+ if (!sa->qgroupid) {37023702+ ret = -EINVAL;37033703+ goto out;37533704 }3754370537553706 trans = btrfs_join_transaction(root);
+19-1
fs/btrfs/qgroup.c
···379379380380 ret = add_relation_rb(fs_info, found_key.objectid,381381 found_key.offset);382382+ if (ret == -ENOENT) {383383+ printk(KERN_WARNING384384+ "btrfs: orphan qgroup relation 0x%llx->0x%llx\n",385385+ (unsigned long long)found_key.objectid,386386+ (unsigned long long)found_key.offset);387387+ ret = 0; /* ignore the error */388388+ }382389 if (ret)383390 goto out;384391next2:···963956 struct btrfs_fs_info *fs_info, u64 qgroupid)964957{965958 struct btrfs_root *quota_root;959959+ struct btrfs_qgroup *qgroup;966960 int ret = 0;967961968962 quota_root = fs_info->quota_root;969963 if (!quota_root)970964 return -EINVAL;971965966966+ /* check if there are no relations to this qgroup */967967+ spin_lock(&fs_info->qgroup_lock);968968+ qgroup = find_qgroup_rb(fs_info, qgroupid);969969+ if (qgroup) {970970+ if (!list_empty(&qgroup->groups) || !list_empty(&qgroup->members)) {971971+ spin_unlock(&fs_info->qgroup_lock);972972+ return -EBUSY;973973+ }974974+ }975975+ spin_unlock(&fs_info->qgroup_lock);976976+972977 ret = del_qgroup_item(trans, quota_root, qgroupid);973978974979 spin_lock(&fs_info->qgroup_lock);975980 del_qgroup_rb(quota_root->fs_info, qgroupid);976976-977981 spin_unlock(&fs_info->qgroup_lock);978982979983 return ret;
+3-1
fs/btrfs/send.c
···18141814 (unsigned long)nce->ino);18151815 if (!nce_head) {18161816 nce_head = kmalloc(sizeof(*nce_head), GFP_NOFS);18171817- if (!nce_head)18171817+ if (!nce_head) {18181818+ kfree(nce);18181819 return -ENOMEM;18201820+ }18191821 INIT_LIST_HEAD(nce_head);1820182218211823 ret = radix_tree_insert(&sctx->name_cache, nce->ino, nce_head);
···14681468 goto cleanup_transaction;14691469 }1470147014711471- if (cur_trans->aborted) {14711471+ /* Stop the commit early if ->aborted is set */14721472+ if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {14721473 ret = cur_trans->aborted;14731474 goto cleanup_transaction;14741475 }···15751574 wait_event(cur_trans->writer_wait,15761575 atomic_read(&cur_trans->num_writers) == 1);1577157615771577+ /* ->aborted might be set after the previous check, so check it */15781578+ if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {15791579+ ret = cur_trans->aborted;15801580+ goto cleanup_transaction;15811581+ }15781582 /*15791583 * the reloc mutex makes sure that we stop15801584 * the balancing code from coming in and moving···1658165216591653 ret = commit_cowonly_roots(trans, root);16601654 if (ret) {16551655+ mutex_unlock(&root->fs_info->tree_log_mutex);16561656+ mutex_unlock(&root->fs_info->reloc_mutex);16571657+ goto cleanup_transaction;16581658+ }16591659+16601660+ /*16611661+ * The tasks which save the space cache and inode cache may also16621662+ * update ->aborted, check it.16631663+ */16641664+ if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {16651665+ ret = cur_trans->aborted;16611666 mutex_unlock(&root->fs_info->tree_log_mutex);16621667 mutex_unlock(&root->fs_info->reloc_mutex);16631668 goto cleanup_transaction;
+8-2
fs/btrfs/tree-log.c
···33573357 if (skip_csum)33583358 return 0;3359335933603360+ if (em->compress_type) {33613361+ csum_offset = 0;33623362+ csum_len = block_len;33633363+ }33643364+33603365 /* block start is already adjusted for the file extent offset. */33613366 ret = btrfs_lookup_csums_range(log->fs_info->csum_root,33623367 em->block_start + csum_offset,···34153410 em = list_entry(extents.next, struct extent_map, list);3416341134173412 list_del_init(&em->list);34183418- clear_bit(EXTENT_FLAG_LOGGING, &em->flags);3419341334203414 /*34213415 * If we had an error we just need to delete everybody from our34223416 * private list.34233417 */34243418 if (ret) {34193419+ clear_em_logging(tree, em);34253420 free_extent_map(em);34263421 continue;34273422 }···34293424 write_unlock(&tree->lock);3430342534313426 ret = log_one_extent(trans, inode, root, em, path);34323432- free_extent_map(em);34333427 write_lock(&tree->lock);34283428+ clear_em_logging(tree, em);34293429+ free_extent_map(em);34343430 }34353431 WARN_ON(!list_empty(&extents));34363432 write_unlock(&tree->lock);
···214214 goto retry;215215 }216216 new->ino = ino;217217- INIT_LIST_HEAD(&new->list);218217219218 /* add new_oentry into list which is sorted by inode number */220219 if (orphan) {···771772 sbi->n_orphans = 0;772773}773774774774-int create_checkpoint_caches(void)775775+int __init create_checkpoint_caches(void)775776{776777 orphan_entry_slab = f2fs_kmem_cache_create("f2fs_orphan_entry",777778 sizeof(struct orphan_inode_entry), NULL);
···78787979 sbi->bg_gc++;80808181- if (f2fs_gc(sbi, 1) == GC_NONE)8181+ if (f2fs_gc(sbi) == GC_NONE)8282 wait_ms = GC_THREAD_NOGC_SLEEP_TIME;8383 else if (wait_ms == GC_THREAD_NOGC_SLEEP_TIME)8484 wait_ms = GC_THREAD_MAX_SLEEP_TIME;···424424}425425426426/*427427- * Calculate start block index that this node page contains427427+ * Calculate start block index indicating the given node offset.428428+ * Be careful, caller should give this node offset only indicating direct node429429+ * blocks. If any node offsets, which point the other types of node blocks such430430+ * as indirect or double indirect node blocks, are given, it must be a caller's431431+ * bug.428432 */429433block_t start_bidx_of_node(unsigned int node_ofs)430434{···655651 return ret;656652}657653658658-int f2fs_gc(struct f2fs_sb_info *sbi, int nGC)654654+int f2fs_gc(struct f2fs_sb_info *sbi)659655{660660- unsigned int segno;661661- int old_free_secs, cur_free_secs;662662- int gc_status, nfree;663656 struct list_head ilist;657657+ unsigned int segno, i;664658 int gc_type = BG_GC;659659+ int gc_status = GC_NONE;665660666661 INIT_LIST_HEAD(&ilist);667662gc_more:668668- nfree = 0;669669- gc_status = GC_NONE;663663+ if (!(sbi->sb->s_flags & MS_ACTIVE))664664+ goto stop;670665671666 if (has_not_enough_free_secs(sbi))672672- old_free_secs = reserved_sections(sbi);673673- else674674- old_free_secs = free_sections(sbi);667667+ gc_type = FG_GC;675668676676- while (sbi->sb->s_flags & MS_ACTIVE) {677677- int i;678678- if (has_not_enough_free_secs(sbi))679679- gc_type = FG_GC;669669+ if (!__get_victim(sbi, &segno, gc_type, NO_CHECK_TYPE))670670+ goto stop;680671681681- cur_free_secs = free_sections(sbi) + nfree;682682-683683- /* We got free space successfully. */684684- if (nGC < cur_free_secs - old_free_secs)672672+ for (i = 0; i < sbi->segs_per_sec; i++) {673673+ /*674674+ * do_garbage_collect will give us three gc_status:675675+ * GC_ERROR, GC_DONE, and GC_BLOCKED.676676+ * If GC is finished uncleanly, we have to return677677+ * the victim to dirty segment list.678678+ */679679+ gc_status = do_garbage_collect(sbi, segno + i, &ilist, gc_type);680680+ if (gc_status != GC_DONE)685681 break;686686-687687- if (!__get_victim(sbi, &segno, gc_type, NO_CHECK_TYPE))688688- break;689689-690690- for (i = 0; i < sbi->segs_per_sec; i++) {691691- /*692692- * do_garbage_collect will give us three gc_status:693693- * GC_ERROR, GC_DONE, and GC_BLOCKED.694694- * If GC is finished uncleanly, we have to return695695- * the victim to dirty segment list.696696- */697697- gc_status = do_garbage_collect(sbi, segno + i,698698- &ilist, gc_type);699699- if (gc_status != GC_DONE)700700- goto stop;701701- nfree++;702702- }703682 }704704-stop:705705- if (has_not_enough_free_secs(sbi) || gc_status == GC_BLOCKED) {683683+ if (has_not_enough_free_secs(sbi)) {706684 write_checkpoint(sbi, (gc_status == GC_BLOCKED), false);707707- if (nfree)685685+ if (has_not_enough_free_secs(sbi))708686 goto gc_more;709687 }688688+stop:710689 mutex_unlock(&sbi->gc_mutex);711690712691 put_gc_inode(&ilist);713713- BUG_ON(!list_empty(&ilist));714692 return gc_status;715693}716694···701715 DIRTY_I(sbi)->v_ops = &default_v_ops;702716}703717704704-int create_gc_caches(void)718718+int __init create_gc_caches(void)705719{706720 winode_slab = f2fs_kmem_cache_create("f2fs_gc_inodes",707721 sizeof(struct inode_entry), NULL);
+3
fs/f2fs/inode.c
···217217 inode->i_ino == F2FS_META_INO(sbi))218218 return 0;219219220220+ if (wbc)221221+ f2fs_balance_fs(sbi);222222+220223 node_page = get_node_page(sbi, inode->i_ino);221224 if (IS_ERR(node_page))222225 return PTR_ERR(node_page);
+12-7
fs/f2fs/node.c
···11241124 return 0;11251125}1126112611271127+/*11281128+ * It is very important to gather dirty pages and write at once, so that we can11291129+ * submit a big bio without interfering other data writes.11301130+ * Be default, 512 pages (2MB), a segment size, is quite reasonable.11311131+ */11321132+#define COLLECT_DIRTY_NODES 51211271133static int f2fs_write_node_pages(struct address_space *mapping,11281134 struct writeback_control *wbc)11291135{···11371131 struct block_device *bdev = sbi->sb->s_bdev;11381132 long nr_to_write = wbc->nr_to_write;1139113311401140- if (wbc->for_kupdate)11411141- return 0;11421142-11431143- if (get_pages(sbi, F2FS_DIRTY_NODES) == 0)11441144- return 0;11451145-11341134+ /* First check balancing cached NAT entries */11461135 if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK)) {11471136 write_checkpoint(sbi, false, false);11481137 return 0;11491138 }11391139+11401140+ /* collect a number of dirty node pages and write together */11411141+ if (get_pages(sbi, F2FS_DIRTY_NODES) < COLLECT_DIRTY_NODES)11421142+ return 0;1150114311511144 /* if mounting is failed, skip writing node pages */11521145 wbc->nr_to_write = bio_get_nr_vecs(bdev);···17371732 kfree(nm_i);17381733}1739173417401740-int create_node_manager_caches(void)17351735+int __init create_node_manager_caches(void)17411736{17421737 nat_entry_slab = f2fs_kmem_cache_create("nat_entry",17431738 sizeof(struct nat_entry), NULL);
···3131 */3232 if (has_not_enough_free_secs(sbi)) {3333 mutex_lock(&sbi->gc_mutex);3434- f2fs_gc(sbi, 1);3434+ f2fs_gc(sbi);3535 }3636}3737
+72-25
fs/f2fs/super.c
···5353 {Opt_err, NULL},5454};55555656+void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...)5757+{5858+ struct va_format vaf;5959+ va_list args;6060+6161+ va_start(args, fmt);6262+ vaf.fmt = fmt;6363+ vaf.va = &args;6464+ printk("%sF2FS-fs (%s): %pV\n", level, sb->s_id, &vaf);6565+ va_end(args);6666+}6767+5668static void init_once(void *foo)5769{5870 struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo;···137125138126 if (sync)139127 write_checkpoint(sbi, false, false);128128+ else129129+ f2fs_balance_fs(sbi);140130141131 return 0;142132}···261247 .get_parent = f2fs_get_parent,262248};263249264264-static int parse_options(struct f2fs_sb_info *sbi, char *options)250250+static int parse_options(struct super_block *sb, struct f2fs_sb_info *sbi,251251+ char *options)265252{266253 substring_t args[MAX_OPT_ARGS];267254 char *p;···301286 break;302287#else303288 case Opt_nouser_xattr:304304- pr_info("nouser_xattr options not supported\n");289289+ f2fs_msg(sb, KERN_INFO,290290+ "nouser_xattr options not supported");305291 break;306292#endif307293#ifdef CONFIG_F2FS_FS_POSIX_ACL···311295 break;312296#else313297 case Opt_noacl:314314- pr_info("noacl options not supported\n");298298+ f2fs_msg(sb, KERN_INFO, "noacl options not supported");315299 break;316300#endif317301 case Opt_active_logs:···325309 set_opt(sbi, DISABLE_EXT_IDENTIFY);326310 break;327311 default:328328- pr_err("Unrecognized mount option \"%s\" or missing value\n",329329- p);312312+ f2fs_msg(sb, KERN_ERR,313313+ "Unrecognized mount option \"%s\" or missing value",314314+ p);330315 return -EINVAL;331316 }332317 }···354337 return result;355338}356339357357-static int sanity_check_raw_super(struct f2fs_super_block *raw_super)340340+static int sanity_check_raw_super(struct super_block *sb,341341+ struct f2fs_super_block *raw_super)358342{359343 unsigned int blocksize;360344361361- if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic))345345+ if (F2FS_SUPER_MAGIC != le32_to_cpu(raw_super->magic)) {346346+ f2fs_msg(sb, KERN_INFO,347347+ "Magic Mismatch, valid(0x%x) - read(0x%x)",348348+ F2FS_SUPER_MAGIC, le32_to_cpu(raw_super->magic));362349 return 1;350350+ }363351364352 /* Currently, support only 4KB block size */365353 blocksize = 1 << le32_to_cpu(raw_super->log_blocksize);366366- if (blocksize != PAGE_CACHE_SIZE)354354+ if (blocksize != PAGE_CACHE_SIZE) {355355+ f2fs_msg(sb, KERN_INFO,356356+ "Invalid blocksize (%u), supports only 4KB\n",357357+ blocksize);367358 return 1;359359+ }368360 if (le32_to_cpu(raw_super->log_sectorsize) !=369369- F2FS_LOG_SECTOR_SIZE)361361+ F2FS_LOG_SECTOR_SIZE) {362362+ f2fs_msg(sb, KERN_INFO, "Invalid log sectorsize");370363 return 1;364364+ }371365 if (le32_to_cpu(raw_super->log_sectors_per_block) !=372372- F2FS_LOG_SECTORS_PER_BLOCK)366366+ F2FS_LOG_SECTORS_PER_BLOCK) {367367+ f2fs_msg(sb, KERN_INFO, "Invalid log sectors per block");373368 return 1;369369+ }374370 return 0;375371}376372···443413 if (!sbi)444414 return -ENOMEM;445415446446- /* set a temporary block size */447447- if (!sb_set_blocksize(sb, F2FS_BLKSIZE))416416+ /* set a block size */417417+ if (!sb_set_blocksize(sb, F2FS_BLKSIZE)) {418418+ f2fs_msg(sb, KERN_ERR, "unable to set blocksize");448419 goto free_sbi;420420+ }449421450422 /* read f2fs raw super block */451423 raw_super_buf = sb_bread(sb, 0);452424 if (!raw_super_buf) {453425 err = -EIO;426426+ f2fs_msg(sb, KERN_ERR, "unable to read superblock");454427 goto free_sbi;455428 }456429 raw_super = (struct f2fs_super_block *)···471438 set_opt(sbi, POSIX_ACL);472439#endif473440 /* parse mount options */474474- if (parse_options(sbi, (char *)data))441441+ if (parse_options(sb, sbi, (char *)data))475442 goto free_sb_buf;476443477444 /* sanity checking of raw super */478478- if (sanity_check_raw_super(raw_super))445445+ if (sanity_check_raw_super(sb, raw_super)) {446446+ f2fs_msg(sb, KERN_ERR, "Can't find a valid F2FS filesystem");479447 goto free_sb_buf;448448+ }480449481450 sb->s_maxbytes = max_file_size(le32_to_cpu(raw_super->log_blocksize));482451 sb->s_max_links = F2FS_LINK_MAX;···512477 /* get an inode for meta space */513478 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));514479 if (IS_ERR(sbi->meta_inode)) {480480+ f2fs_msg(sb, KERN_ERR, "Failed to read F2FS meta data inode");515481 err = PTR_ERR(sbi->meta_inode);516482 goto free_sb_buf;517483 }518484519485 err = get_valid_checkpoint(sbi);520520- if (err)486486+ if (err) {487487+ f2fs_msg(sb, KERN_ERR, "Failed to get valid F2FS checkpoint");521488 goto free_meta_inode;489489+ }522490523491 /* sanity checking of checkpoint */524492 err = -EINVAL;525525- if (sanity_check_ckpt(raw_super, sbi->ckpt))493493+ if (sanity_check_ckpt(raw_super, sbi->ckpt)) {494494+ f2fs_msg(sb, KERN_ERR, "Invalid F2FS checkpoint");526495 goto free_cp;496496+ }527497528498 sbi->total_valid_node_count =529499 le32_to_cpu(sbi->ckpt->valid_node_count);···542502 INIT_LIST_HEAD(&sbi->dir_inode_list);543503 spin_lock_init(&sbi->dir_inode_lock);544504545545- /* init super block */546546- if (!sb_set_blocksize(sb, sbi->blocksize))547547- goto free_cp;548548-549505 init_orphan_info(sbi);550506551507 /* setup f2fs internal modules */552508 err = build_segment_manager(sbi);553553- if (err)509509+ if (err) {510510+ f2fs_msg(sb, KERN_ERR,511511+ "Failed to initialize F2FS segment manager");554512 goto free_sm;513513+ }555514 err = build_node_manager(sbi);556556- if (err)515515+ if (err) {516516+ f2fs_msg(sb, KERN_ERR,517517+ "Failed to initialize F2FS node manager");557518 goto free_nm;519519+ }558520559521 build_gc_manager(sbi);560522561523 /* get an inode for node space */562524 sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));563525 if (IS_ERR(sbi->node_inode)) {526526+ f2fs_msg(sb, KERN_ERR, "Failed to read node inode");564527 err = PTR_ERR(sbi->node_inode);565528 goto free_nm;566529 }···576533 /* read root inode and dentry */577534 root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));578535 if (IS_ERR(root)) {536536+ f2fs_msg(sb, KERN_ERR, "Failed to read root inode");579537 err = PTR_ERR(root);580538 goto free_node_inode;581539 }···640596 .fs_flags = FS_REQUIRES_DEV,641597};642598643643-static int init_inodecache(void)599599+static int __init init_inodecache(void)644600{645601 f2fs_inode_cachep = f2fs_kmem_cache_create("f2fs_inode_cache",646602 sizeof(struct f2fs_inode_info), NULL);···675631 err = create_checkpoint_caches();676632 if (err)677633 goto fail;678678- return register_filesystem(&f2fs_fs_type);634634+ err = register_filesystem(&f2fs_fs_type);635635+ if (err)636636+ goto fail;637637+ f2fs_create_root_stats();679638fail:680639 return err;681640}682641683642static void __exit exit_f2fs_fs(void)684643{685685- destroy_root_stats();644644+ f2fs_destroy_root_stats();686645 unregister_filesystem(&f2fs_fs_type);687646 destroy_checkpoint_caches();688647 destroy_gc_caches();
+2
fs/f2fs/xattr.c
···318318 if (name_len > 255 || value_len > MAX_VALUE_LEN)319319 return -ERANGE;320320321321+ f2fs_balance_fs(sbi);322322+321323 mutex_lock_op(sbi, NODE_NEW);322324 if (!fi->i_xattr_nid) {323325 /* Allocate new attribute block */
+14-2
fs/fuse/Kconfig
···44 With FUSE it is possible to implement a fully functional filesystem55 in a userspace program.6677- There's also companion library: libfuse. This library along with88- utilities is available from the FUSE homepage:77+ There's also a companion library: libfuse2. This library is available88+ from the FUSE homepage:99 <http://fuse.sourceforge.net/>1010+ although chances are your distribution already has that library1111+ installed if you've installed the "fuse" package itself.10121113 See <file:Documentation/filesystems/fuse.txt> for more information.1214 See <file:Documentation/Changes> for needed library/utility version.13151416 If you want to develop a userspace FS, or if you want to use1517 a filesystem based on FUSE, answer Y or M.1818+1919+config CUSE2020+ tristate "Character device in Userspace support"2121+ depends on FUSE_FS2222+ help2323+ This FUSE extension allows character devices to be2424+ implemented in userspace.2525+2626+ If you want to develop or use a userspace character device2727+ based on CUSE, answer Y or M.
+22-14
fs/fuse/cuse.c
···4545#include <linux/miscdevice.h>4646#include <linux/mutex.h>4747#include <linux/slab.h>4848-#include <linux/spinlock.h>4948#include <linux/stat.h>5049#include <linux/module.h>5150···6263 bool unrestricted_ioctl;6364};64656565-static DEFINE_SPINLOCK(cuse_lock); /* protects cuse_conntbl */6666+static DEFINE_MUTEX(cuse_lock); /* protects registration */6667static struct list_head cuse_conntbl[CUSE_CONNTBL_LEN];6768static struct class *cuse_class;6869···113114 int rc;114115115116 /* look up and get the connection */116116- spin_lock(&cuse_lock);117117+ mutex_lock(&cuse_lock);117118 list_for_each_entry(pos, cuse_conntbl_head(devt), list)118119 if (pos->dev->devt == devt) {119120 fuse_conn_get(&pos->fc);120121 cc = pos;121122 break;122123 }123123- spin_unlock(&cuse_lock);124124+ mutex_unlock(&cuse_lock);124125125126 /* dead? */126127 if (!cc)···266267static int cuse_parse_devinfo(char *p, size_t len, struct cuse_devinfo *devinfo)267268{268269 char *end = p + len;269269- char *key, *val;270270+ char *uninitialized_var(key), *uninitialized_var(val);270271 int rc;271272272273 while (true) {···304305 */305306static void cuse_process_init_reply(struct fuse_conn *fc, struct fuse_req *req)306307{307307- struct cuse_conn *cc = fc_to_cc(fc);308308+ struct cuse_conn *cc = fc_to_cc(fc), *pos;308309 struct cuse_init_out *arg = req->out.args[0].value;309310 struct page *page = req->pages[0];310311 struct cuse_devinfo devinfo = { };311312 struct device *dev;312313 struct cdev *cdev;313314 dev_t devt;314314- int rc;315315+ int rc, i;315316316317 if (req->out.h.error ||317318 arg->major != FUSE_KERNEL_VERSION || arg->minor < 11) {···355356 dev_set_drvdata(dev, cc);356357 dev_set_name(dev, "%s", devinfo.name);357358359359+ mutex_lock(&cuse_lock);360360+361361+ /* make sure the device-name is unique */362362+ for (i = 0; i < CUSE_CONNTBL_LEN; ++i) {363363+ list_for_each_entry(pos, &cuse_conntbl[i], list)364364+ if (!strcmp(dev_name(pos->dev), dev_name(dev)))365365+ goto err_unlock;366366+ }367367+358368 rc = device_add(dev);359369 if (rc)360360- goto err_device;370370+ goto err_unlock;361371362372 /* register cdev */363373 rc = -ENOMEM;364374 cdev = cdev_alloc();365375 if (!cdev)366366- goto err_device;376376+ goto err_unlock;367377368378 cdev->owner = THIS_MODULE;369379 cdev->ops = &cuse_frontend_fops;···385377 cc->cdev = cdev;386378387379 /* make the device available */388388- spin_lock(&cuse_lock);389380 list_add(&cc->list, cuse_conntbl_head(devt));390390- spin_unlock(&cuse_lock);381381+ mutex_unlock(&cuse_lock);391382392383 /* announce device availability */393384 dev_set_uevent_suppress(dev, 0);···398391399392err_cdev:400393 cdev_del(cdev);401401-err_device:394394+err_unlock:395395+ mutex_unlock(&cuse_lock);402396 put_device(dev);403397err_region:404398 unregister_chrdev_region(devt, 1);···528520 int rc;529521530522 /* remove from the conntbl, no more access from this point on */531531- spin_lock(&cuse_lock);523523+ mutex_lock(&cuse_lock);532524 list_del_init(&cc->list);533533- spin_unlock(&cuse_lock);525525+ mutex_unlock(&cuse_lock);534526535527 /* remove device */536528 if (cc->dev)
-5
fs/fuse/dev.c
···692692 struct page *oldpage = *pagep;693693 struct page *newpage;694694 struct pipe_buffer *buf = cs->pipebufs;695695- struct address_space *mapping;696696- pgoff_t index;697695698696 unlock_request(cs->fc, cs->req);699697 fuse_copy_finish(cs);···721723722724 if (fuse_check_page(newpage) != 0)723725 goto out_fallback_unlock;724724-725725- mapping = oldpage->mapping;726726- index = oldpage->index;727726728727 /*729728 * This is a new and locked page, it shouldn't be mapped or
···652652 u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */653653 };654654655655- /* Identify Device Data Log (30h), SATA Settings (page 08h) */656656- u8 sata_settings[ATA_SECT_SIZE];655655+ /* DEVSLP Timing Variables from Identify Device Data Log */656656+ u8 devslp_timing[ATA_LOG_DEVSLP_SIZE];657657658658 /* error history */659659 int spdn_cnt;
+5-5
include/linux/module.h
···199199 struct module *source, *target;200200};201201202202-enum module_state203203-{204204- MODULE_STATE_LIVE,205205- MODULE_STATE_COMING,206206- MODULE_STATE_GOING,202202+enum module_state {203203+ MODULE_STATE_LIVE, /* Normal state. */204204+ MODULE_STATE_COMING, /* Full formed, running module_init. */205205+ MODULE_STATE_GOING, /* Going away. */206206+ MODULE_STATE_UNFORMED, /* Still setting it up. */207207};208208209209/**
-1
include/linux/ptrace.h
···4545extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);4646extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);4747extern void ptrace_disable(struct task_struct *);4848-extern int ptrace_check_attach(struct task_struct *task, bool ignore_state);4948extern int ptrace_request(struct task_struct *child, long request,5049 unsigned long addr, unsigned long data);5150extern void ptrace_notify(int exit_code);
···5050#define PORT_LPC3220 22 /* NXP LPC32xx SoC "Standard" UART */5151#define PORT_8250_CIR 23 /* CIR infrared port, has its own driver */5252#define PORT_XR17V35X 24 /* Exar XR17V35x UARTs */5353-#define PORT_MAX_8250 24 /* max port ID */5353+#define PORT_BRCM_TRUMANAGE 245454+#define PORT_MAX_8250 25 /* max port ID */54555556/*5657 * ARM specific type numbers. These are not currently guaranteed
+4
init/do_mounts_initrd.c
···3636static int init_linuxrc(struct subprocess_info *info, struct cred *new)3737{3838 sys_unshare(CLONE_FS | CLONE_FILES);3939+ /* stdin/stdout/stderr for /linuxrc */4040+ sys_open("/dev/console", O_RDWR, 0);4141+ sys_dup(0);4242+ sys_dup(0);3943 /* move initrd over / and chdir/chroot in initrd root */4044 sys_chdir("/root");4145 sys_mount(".", "/", NULL, MS_MOVE, NULL);
+2-2
init/main.c
···802802 (const char __user *const __user *)envp_init);803803}804804805805-static void __init kernel_init_freeable(void);805805+static noinline void __init kernel_init_freeable(void);806806807807static int __ref kernel_init(void *unused)808808{···845845 "See Linux Documentation/init.txt for guidance.");846846}847847848848-static void __init kernel_init_freeable(void)848848+static noinline void __init kernel_init_freeable(void)849849{850850 /*851851 * Wait until kthreadd is all set-up.
+20-7
kernel/async.c
···8686 */8787static async_cookie_t __lowest_in_progress(struct async_domain *running)8888{8989+ async_cookie_t first_running = next_cookie; /* infinity value */9090+ async_cookie_t first_pending = next_cookie; /* ditto */8991 struct async_entry *entry;90929393+ /*9494+ * Both running and pending lists are sorted but not disjoint.9595+ * Take the first cookies from both and return the min.9696+ */9197 if (!list_empty(&running->domain)) {9298 entry = list_first_entry(&running->domain, typeof(*entry), list);9393- return entry->cookie;9999+ first_running = entry->cookie;94100 }951019696- list_for_each_entry(entry, &async_pending, list)9797- if (entry->running == running)9898- return entry->cookie;102102+ list_for_each_entry(entry, &async_pending, list) {103103+ if (entry->running == running) {104104+ first_pending = entry->cookie;105105+ break;106106+ }107107+ }99108100100- return next_cookie; /* "infinity" value */109109+ return min(first_running, first_pending);101110}102111103112static async_cookie_t lowest_in_progress(struct async_domain *running)···127118{128119 struct async_entry *entry =129120 container_of(work, struct async_entry, work);121121+ struct async_entry *pos;130122 unsigned long flags;131123 ktime_t uninitialized_var(calltime), delta, rettime;132124 struct async_domain *running = entry->running;133125134134- /* 1) move self to the running queue */126126+ /* 1) move self to the running queue, make sure it stays sorted */135127 spin_lock_irqsave(&async_lock, flags);136136- list_move_tail(&entry->list, &running->domain);128128+ list_for_each_entry_reverse(pos, &running->domain, list)129129+ if (entry->cookie < pos->cookie)130130+ break;131131+ list_move_tail(&entry->list, &pos->list);137132 spin_unlock_irqrestore(&async_lock, flags);138133139134 /* 2) run (and print duration) */
+15-8
kernel/compat.c
···535535 return 0;536536}537537538538-asmlinkage long539539-compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options,540540- struct compat_rusage __user *ru)538538+COMPAT_SYSCALL_DEFINE4(wait4,539539+ compat_pid_t, pid,540540+ compat_uint_t __user *, stat_addr,541541+ int, options,542542+ struct compat_rusage __user *, ru)541543{542544 if (!ru) {543545 return sys_wait4(pid, stat_addr, options, NULL);···566564 }567565}568566569569-asmlinkage long compat_sys_waitid(int which, compat_pid_t pid,570570- struct compat_siginfo __user *uinfo, int options,571571- struct compat_rusage __user *uru)567567+COMPAT_SYSCALL_DEFINE5(waitid,568568+ int, which, compat_pid_t, pid,569569+ struct compat_siginfo __user *, uinfo, int, options,570570+ struct compat_rusage __user *, uru)572571{573572 siginfo_t info;574573 struct rusage ru;···587584 return ret;588585589586 if (uru) {590590- ret = put_compat_rusage(&ru, uru);587587+ /* sys_waitid() overwrites everything in ru */588588+ if (COMPAT_USE_64BIT_TIME)589589+ ret = copy_to_user(uru, &ru, sizeof(ru));590590+ else591591+ ret = put_compat_rusage(&ru, uru);591592 if (ret)592593 return ret;593594 }···1001994 sigset_from_compat(&s, &s32);10029951003996 if (uts) {10041004- if (get_compat_timespec(&t, uts))997997+ if (compat_get_timespec(&t, uts))1005998 return -EFAULT;1006999 }10071000
···188188 ongoing or failed initialization etc. */189189static inline int strong_try_module_get(struct module *mod)190190{191191+ BUG_ON(mod && mod->state == MODULE_STATE_UNFORMED);191192 if (mod && mod->state == MODULE_STATE_COMING)192193 return -EBUSY;193194 if (try_module_get(mod))···344343#endif345344 };346345346346+ if (mod->state == MODULE_STATE_UNFORMED)347347+ continue;348348+347349 if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))348350 return true;349351 }···454450EXPORT_SYMBOL_GPL(find_symbol);455451456452/* Search for module by name: must hold module_mutex. */457457-struct module *find_module(const char *name)453453+static struct module *find_module_all(const char *name,454454+ bool even_unformed)458455{459456 struct module *mod;460457461458 list_for_each_entry(mod, &modules, list) {459459+ if (!even_unformed && mod->state == MODULE_STATE_UNFORMED)460460+ continue;462461 if (strcmp(mod->name, name) == 0)463462 return mod;464463 }465464 return NULL;465465+}466466+467467+struct module *find_module(const char *name)468468+{469469+ return find_module_all(name, false);466470}467471EXPORT_SYMBOL_GPL(find_module);468472···537525 preempt_disable();538526539527 list_for_each_entry_rcu(mod, &modules, list) {528528+ if (mod->state == MODULE_STATE_UNFORMED)529529+ continue;540530 if (!mod->percpu_size)541531 continue;542532 for_each_possible_cpu(cpu) {···10621048 case MODULE_STATE_GOING:10631049 state = "going";10641050 break;10511051+ default:10521052+ BUG();10651053 }10661054 return sprintf(buffer, "%s\n", state);10671055}···1802178618031787 mutex_lock(&module_mutex);18041788 list_for_each_entry_rcu(mod, &modules, list) {17891789+ if (mod->state == MODULE_STATE_UNFORMED)17901790+ continue;18051791 if ((mod->module_core) && (mod->core_text_size)) {18061792 set_page_attributes(mod->module_core,18071793 mod->module_core + mod->core_text_size,···1825180718261808 mutex_lock(&module_mutex);18271809 list_for_each_entry_rcu(mod, &modules, list) {18101810+ if (mod->state == MODULE_STATE_UNFORMED)18111811+ continue;18281812 if ((mod->module_core) && (mod->core_text_size)) {18291813 set_page_attributes(mod->module_core,18301814 mod->module_core + mod->core_text_size,···25472527 err = -EFBIG;25482528 goto out;25492529 }25302530+25312531+ /* Don't hand 0 to vmalloc, it whines. */25322532+ if (stat.size == 0) {25332533+ err = -EINVAL;25342534+ goto out;25352535+ }25362536+25502537 info->hdr = vmalloc(stat.size);25512538 if (!info->hdr) {25522539 err = -ENOMEM;···30172990 bool ret;3018299130192992 mutex_lock(&module_mutex);30203020- mod = find_module(name);30213021- ret = !mod || mod->state != MODULE_STATE_COMING;29932993+ mod = find_module_all(name, true);29942994+ ret = !mod || mod->state == MODULE_STATE_LIVE29952995+ || mod->state == MODULE_STATE_GOING;30222996 mutex_unlock(&module_mutex);3023299730242998 return ret;···31643136 goto free_copy;31653137 }3166313831393139+ /*31403140+ * We try to place it in the list now to make sure it's unique31413141+ * before we dedicate too many resources. In particular,31423142+ * temporary percpu memory exhaustion.31433143+ */31443144+ mod->state = MODULE_STATE_UNFORMED;31453145+again:31463146+ mutex_lock(&module_mutex);31473147+ if ((old = find_module_all(mod->name, true)) != NULL) {31483148+ if (old->state == MODULE_STATE_COMING31493149+ || old->state == MODULE_STATE_UNFORMED) {31503150+ /* Wait in case it fails to load. */31513151+ mutex_unlock(&module_mutex);31523152+ err = wait_event_interruptible(module_wq,31533153+ finished_loading(mod->name));31543154+ if (err)31553155+ goto free_module;31563156+ goto again;31573157+ }31583158+ err = -EEXIST;31593159+ mutex_unlock(&module_mutex);31603160+ goto free_module;31613161+ }31623162+ list_add_rcu(&mod->list, &modules);31633163+ mutex_unlock(&module_mutex);31643164+31673165#ifdef CONFIG_MODULE_SIG31683166 mod->sig_ok = info->sig_ok;31693167 if (!mod->sig_ok)···31993145 /* Now module is in final location, initialize linked lists, etc. */32003146 err = module_unload_init(mod);32013147 if (err)32023202- goto free_module;31483148+ goto unlink_mod;3203314932043150 /* Now we've got everything in the final locations, we can32053151 * find optional sections. */···32343180 goto free_arch_cleanup;32353181 }3236318232373237- /* Mark state as coming so strong_try_module_get() ignores us. */32383238- mod->state = MODULE_STATE_COMING;32393239-32403240- /* Now sew it into the lists so we can get lockdep and oops32413241- * info during argument parsing. No one should access us, since32423242- * strong_try_module_get() will fail.32433243- * lockdep/oops can run asynchronous, so use the RCU list insertion32443244- * function to insert in a way safe to concurrent readers.32453245- * The mutex protects against concurrent writers.32463246- */32473247-again:32483248- mutex_lock(&module_mutex);32493249- if ((old = find_module(mod->name)) != NULL) {32503250- if (old->state == MODULE_STATE_COMING) {32513251- /* Wait in case it fails to load. */32523252- mutex_unlock(&module_mutex);32533253- err = wait_event_interruptible(module_wq,32543254- finished_loading(mod->name));32553255- if (err)32563256- goto free_arch_cleanup;32573257- goto again;32583258- }32593259- err = -EEXIST;32603260- goto unlock;32613261- }32623262-32633263- /* This has to be done once we're sure module name is unique. */32643183 dynamic_debug_setup(info->debug, info->num_debug);3265318432663266- /* Find duplicate symbols */31853185+ mutex_lock(&module_mutex);31863186+ /* Find duplicate symbols (must be called under lock). */32673187 err = verify_export_symbols(mod);32683188 if (err < 0)32693269- goto ddebug;31893189+ goto ddebug_cleanup;3270319031913191+ /* This relies on module_mutex for list integrity. */32713192 module_bug_finalize(info->hdr, info->sechdrs, mod);32723272- list_add_rcu(&mod->list, &modules);31933193+31943194+ /* Mark state as coming so strong_try_module_get() ignores us,31953195+ * but kallsyms etc. can see us. */31963196+ mod->state = MODULE_STATE_COMING;31973197+32733198 mutex_unlock(&module_mutex);3274319932753200 /* Module is ready to execute: parsing args may do that. */32763201 err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp,32773202 -32768, 32767, &ddebug_dyndbg_module_param_cb);32783203 if (err < 0)32793279- goto unlink;32043204+ goto bug_cleanup;3280320532813206 /* Link in to syfs. */32823207 err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp);32833208 if (err < 0)32843284- goto unlink;32093209+ goto bug_cleanup;3285321032863211 /* Get rid of temporary copy. */32873212 free_copy(info);···3270323732713238 return do_init_module(mod);3272323932733273- unlink:32403240+ bug_cleanup:32413241+ /* module_bug_cleanup needs module_mutex protection */32743242 mutex_lock(&module_mutex);32753275- /* Unlink carefully: kallsyms could be walking list. */32763276- list_del_rcu(&mod->list);32773243 module_bug_cleanup(mod);32783278- wake_up_all(&module_wq);32793279- ddebug:32803280- dynamic_debug_remove(info->debug);32813281- unlock:32443244+ ddebug_cleanup:32823245 mutex_unlock(&module_mutex);32463246+ dynamic_debug_remove(info->debug);32833247 synchronize_sched();32843248 kfree(mod->args);32853249 free_arch_cleanup:···32853255 free_modinfo(mod);32863256 free_unload:32873257 module_unload_free(mod);32583258+ unlink_mod:32593259+ mutex_lock(&module_mutex);32603260+ /* Unlink carefully: kallsyms could be walking list. */32613261+ list_del_rcu(&mod->list);32623262+ wake_up_all(&module_wq);32633263+ mutex_unlock(&module_mutex);32883264 free_module:32893265 module_deallocate(mod, info);32903266 free_copy:···3413337734143378 preempt_disable();34153379 list_for_each_entry_rcu(mod, &modules, list) {33803380+ if (mod->state == MODULE_STATE_UNFORMED)33813381+ continue;34163382 if (within_module_init(addr, mod) ||34173383 within_module_core(addr, mod)) {34183384 if (modname)···3438340034393401 preempt_disable();34403402 list_for_each_entry_rcu(mod, &modules, list) {34033403+ if (mod->state == MODULE_STATE_UNFORMED)34043404+ continue;34413405 if (within_module_init(addr, mod) ||34423406 within_module_core(addr, mod)) {34433407 const char *sym;···3464342434653425 preempt_disable();34663426 list_for_each_entry_rcu(mod, &modules, list) {34273427+ if (mod->state == MODULE_STATE_UNFORMED)34283428+ continue;34673429 if (within_module_init(addr, mod) ||34683430 within_module_core(addr, mod)) {34693431 const char *sym;···3493345134943452 preempt_disable();34953453 list_for_each_entry_rcu(mod, &modules, list) {34543454+ if (mod->state == MODULE_STATE_UNFORMED)34553455+ continue;34963456 if (symnum < mod->num_symtab) {34973457 *value = mod->symtab[symnum].st_value;34983458 *type = mod->symtab[symnum].st_info;···35373493 ret = mod_find_symname(mod, colon+1);35383494 *colon = ':';35393495 } else {35403540- list_for_each_entry_rcu(mod, &modules, list)34963496+ list_for_each_entry_rcu(mod, &modules, list) {34973497+ if (mod->state == MODULE_STATE_UNFORMED)34983498+ continue;35413499 if ((ret = mod_find_symname(mod, name)) != 0)35423500 break;35013501+ }35433502 }35443503 preempt_enable();35453504 return ret;···35573510 int ret;3558351135593512 list_for_each_entry(mod, &modules, list) {35133513+ if (mod->state == MODULE_STATE_UNFORMED)35143514+ continue;35603515 for (i = 0; i < mod->num_symtab; i++) {35613516 ret = fn(data, mod->strtab + mod->symtab[i].st_name,35623517 mod, mod->symtab[i].st_value);···35743525{35753526 int bx = 0;3576352735283528+ BUG_ON(mod->state == MODULE_STATE_UNFORMED);35773529 if (mod->taints ||35783530 mod->state == MODULE_STATE_GOING ||35793531 mod->state == MODULE_STATE_COMING) {···36153565{36163566 struct module *mod = list_entry(p, struct module, list);36173567 char buf[8];35683568+35693569+ /* We always ignore unformed modules. */35703570+ if (mod->state == MODULE_STATE_UNFORMED)35713571+ return 0;3618357236193573 seq_printf(m, "%s %u",36203574 mod->name, mod->init_size + mod->core_size);···3680362636813627 preempt_disable();36823628 list_for_each_entry_rcu(mod, &modules, list) {36293629+ if (mod->state == MODULE_STATE_UNFORMED)36303630+ continue;36833631 if (mod->num_exentries == 0)36843632 continue;36853633···37303674 if (addr < module_addr_min || addr > module_addr_max)37313675 return NULL;3732367637333733- list_for_each_entry_rcu(mod, &modules, list)36773677+ list_for_each_entry_rcu(mod, &modules, list) {36783678+ if (mod->state == MODULE_STATE_UNFORMED)36793679+ continue;37343680 if (within_module_core(addr, mod)37353681 || within_module_init(addr, mod))37363682 return mod;36833683+ }37373684 return NULL;37383685}37393686EXPORT_SYMBOL_GPL(__module_address);···37893730 printk(KERN_DEFAULT "Modules linked in:");37903731 /* Most callers should already have preempt disabled, but make sure */37913732 preempt_disable();37923792- list_for_each_entry_rcu(mod, &modules, list)37333733+ list_for_each_entry_rcu(mod, &modules, list) {37343734+ if (mod->state == MODULE_STATE_UNFORMED)37353735+ continue;37933736 printk(" %s%s", mod->name, module_flags(mod, buf));37373737+ }37943738 preempt_enable();37953739 if (last_unloaded_module[0])37963740 printk(" [last unloaded: %s]", last_unloaded_module);
+59-15
kernel/ptrace.c
···117117 * TASK_KILLABLE sleeps.118118 */119119 if (child->jobctl & JOBCTL_STOP_PENDING || task_is_traced(child))120120- signal_wake_up(child, task_is_traced(child));120120+ ptrace_signal_wake_up(child, true);121121122122 spin_unlock(&child->sighand->siglock);123123+}124124+125125+/* Ensure that nothing can wake it up, even SIGKILL */126126+static bool ptrace_freeze_traced(struct task_struct *task)127127+{128128+ bool ret = false;129129+130130+ /* Lockless, nobody but us can set this flag */131131+ if (task->jobctl & JOBCTL_LISTENING)132132+ return ret;133133+134134+ spin_lock_irq(&task->sighand->siglock);135135+ if (task_is_traced(task) && !__fatal_signal_pending(task)) {136136+ task->state = __TASK_TRACED;137137+ ret = true;138138+ }139139+ spin_unlock_irq(&task->sighand->siglock);140140+141141+ return ret;142142+}143143+144144+static void ptrace_unfreeze_traced(struct task_struct *task)145145+{146146+ if (task->state != __TASK_TRACED)147147+ return;148148+149149+ WARN_ON(!task->ptrace || task->parent != current);150150+151151+ spin_lock_irq(&task->sighand->siglock);152152+ if (__fatal_signal_pending(task))153153+ wake_up_state(task, __TASK_TRACED);154154+ else155155+ task->state = TASK_TRACED;156156+ spin_unlock_irq(&task->sighand->siglock);123157}124158125159/**···173139 * RETURNS:174140 * 0 on success, -ESRCH if %child is not ready.175141 */176176-int ptrace_check_attach(struct task_struct *child, bool ignore_state)142142+static int ptrace_check_attach(struct task_struct *child, bool ignore_state)177143{178144 int ret = -ESRCH;179145···185151 * be changed by us so it's not changing right after this.186152 */187153 read_lock(&tasklist_lock);188188- if ((child->ptrace & PT_PTRACED) && child->parent == current) {154154+ if (child->ptrace && child->parent == current) {155155+ WARN_ON(child->state == __TASK_TRACED);189156 /*190157 * child->sighand can't be NULL, release_task()191158 * does ptrace_unlink() before __exit_signal().192159 */193193- spin_lock_irq(&child->sighand->siglock);194194- WARN_ON_ONCE(task_is_stopped(child));195195- if (ignore_state || (task_is_traced(child) &&196196- !(child->jobctl & JOBCTL_LISTENING)))160160+ if (ignore_state || ptrace_freeze_traced(child))197161 ret = 0;198198- spin_unlock_irq(&child->sighand->siglock);199162 }200163 read_unlock(&tasklist_lock);201164202202- if (!ret && !ignore_state)203203- ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;165165+ if (!ret && !ignore_state) {166166+ if (!wait_task_inactive(child, __TASK_TRACED)) {167167+ /*168168+ * This can only happen if may_ptrace_stop() fails and169169+ * ptrace_stop() changes ->state back to TASK_RUNNING,170170+ * so we should not worry about leaking __TASK_TRACED.171171+ */172172+ WARN_ON(child->state == __TASK_TRACED);173173+ ret = -ESRCH;174174+ }175175+ }204176205205- /* All systems go.. */206177 return ret;207178}208179···356317 */357318 if (task_is_stopped(task) &&358319 task_set_jobctl_pending(task, JOBCTL_TRAP_STOP | JOBCTL_TRAPPING))359359- signal_wake_up(task, 1);320320+ signal_wake_up_state(task, __TASK_STOPPED);360321361322 spin_unlock(&task->sighand->siglock);362323···776737 * tracee into STOP.777738 */778739 if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP)))779779- signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);740740+ ptrace_signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);780741781742 unlock_task_sighand(child, &flags);782743 ret = 0;···802763 * start of this trap and now. Trigger re-trap.803764 */804765 if (child->jobctl & JOBCTL_TRAP_NOTIFY)805805- signal_wake_up(child, true);766766+ ptrace_signal_wake_up(child, true);806767 ret = 0;807768 }808769 unlock_task_sighand(child, &flags);···939900 goto out_put_task_struct;940901941902 ret = arch_ptrace(child, request, addr, data);903903+ if (ret || request != PTRACE_DETACH)904904+ ptrace_unfreeze_traced(child);942905943906 out_put_task_struct:944907 put_task_struct(child);···1080103910811040 ret = ptrace_check_attach(child, request == PTRACE_KILL ||10821041 request == PTRACE_INTERRUPT);10831083- if (!ret)10421042+ if (!ret) {10841043 ret = compat_arch_ptrace(child, request, addr, data);10441044+ if (ret || request != PTRACE_DETACH)10451045+ ptrace_unfreeze_traced(child);10461046+ }1085104710861048 out_put_task_struct:10871049 put_task_struct(child);
···680680 * No need to set need_resched since signal event passing681681 * goes through ->blocked682682 */683683-void signal_wake_up(struct task_struct *t, int resume)683683+void signal_wake_up_state(struct task_struct *t, unsigned int state)684684{685685- unsigned int mask;686686-687685 set_tsk_thread_flag(t, TIF_SIGPENDING);688688-689686 /*690690- * For SIGKILL, we want to wake it up in the stopped/traced/killable687687+ * TASK_WAKEKILL also means wake it up in the stopped/traced/killable691688 * case. We don't check t->state here because there is a race with it692689 * executing another processor and just now entering stopped state.693690 * By using wake_up_state, we ensure the process will wake up and694691 * handle its death signal.695692 */696696- mask = TASK_INTERRUPTIBLE;697697- if (resume)698698- mask |= TASK_WAKEKILL;699699- if (!wake_up_state(t, mask))693693+ if (!wake_up_state(t, state | TASK_INTERRUPTIBLE))700694 kick_process(t);701695}702696···838844 assert_spin_locked(&t->sighand->siglock);839845840846 task_set_jobctl_pending(t, JOBCTL_TRAP_NOTIFY);841841- signal_wake_up(t, t->jobctl & JOBCTL_LISTENING);847847+ ptrace_signal_wake_up(t, t->jobctl & JOBCTL_LISTENING);842848}843849844850/*···17941800 * If SIGKILL was already sent before the caller unlocked17951801 * ->siglock we must see ->core_state != NULL. Otherwise it17961802 * is safe to enter schedule().18031803+ *18041804+ * This is almost outdated, a task with the pending SIGKILL can't18051805+ * block in TASK_TRACED. But PTRACE_EVENT_EXIT can be reported18061806+ * after SIGKILL was already dequeued.17971807 */17981808 if (unlikely(current->mm->core_state) &&17991809 unlikely(current->mm == current->parent->mm))···19231925 if (gstop_done)19241926 do_notify_parent_cldstop(current, false, why);1925192719281928+ /* tasklist protects us from ptrace_freeze_traced() */19261929 __set_current_state(TASK_RUNNING);19271930 if (clear_code)19281931 current->exit_code = 0;···3115311631163117#ifdef CONFIG_COMPAT31173118#ifdef CONFIG_GENERIC_SIGALTSTACK31183118-asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,31193119- compat_stack_t __user *uoss_ptr)31193119+COMPAT_SYSCALL_DEFINE2(sigaltstack,31203120+ const compat_stack_t __user *, uss_ptr,31213121+ compat_stack_t __user *, uoss_ptr)31203122{31213123 stack_t uss, uoss;31223124 int ret;
+1-1
kernel/trace/ftrace.c
···3998399839993999struct notifier_block ftrace_module_nb = {40004000 .notifier_call = ftrace_module_notify,40014001- .priority = 0,40014001+ .priority = INT_MAX, /* Run before anything that can use kprobes */40024002};4003400340044004extern unsigned long __start_mcount_loc[];
+1
lib/bug.c
···5555}56565757#ifdef CONFIG_MODULES5858+/* Updates are protected by module mutex */5859static LIST_HEAD(module_bug_list);59606061static const struct bug_entry *module_find_bug(unsigned long bugaddr)