static void __init setup_machine_fdt(phys_addr_t dt_phys) { void *dt_virt = fixmap_remap_fdt(dt_phys); if (!dt_virt || !early_init_dt_scan(dt_virt)) { pr_crit("\n" "Error: invalid device tree blob at physical address %pa (virtual address 0x%p)\n" "The dtb must be 8-byte aligned and must not exceed 2 MB in size\n" "\nPlease check your bootloader.", &dt_phys, dt_virt); while (true) cpu_relax(); } dump_stack_set_arch_desc("%s (DT)", of_flat_dt_get_machine_name()); }
/* * called on the thread which is asking for a CPU to be shutdown - * waits until shutdown has completed, or it is timed out. */ void __cpu_die(unsigned int cpu) { if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) { pr_crit("CPU%u: cpu didn't die\n", cpu); return; } pr_notice("CPU%u: shutdown\n", cpu); /* * Now that the dying CPU is beyond the point of no return w.r.t. * in-kernel synchronisation, try to get the firwmare to help us to * verify that it has really left the kernel before we consider * clobbering anything it might still be using. */ if (!op_cpu_kill(cpu)) pr_warn("CPU%d may not have shut down cleanly\n", cpu); }
static void msm_wfi_cpu_die(unsigned int cpu) { if (unlikely(cpu != smp_processor_id())) { pr_crit("%s: running on %u, should be %u\n", __func__, smp_processor_id(), cpu); BUG(); } for (;;) { lpm_cpu_hotplug_enter(cpu); if (secondary_holding_pen_release == cpu_logical_map(cpu)) { /*Proper wake up */ break; } pr_debug("CPU%u: spurious wakeup call\n", cpu); BUG(); } }
/* * ipi_cpu_stop - handle IPI from smp_send_stop() */ static void ipi_cpu_stop(unsigned int cpu) { if (system_state == SYSTEM_BOOTING || system_state == SYSTEM_RUNNING) { raw_spin_lock(&stop_lock); pr_crit("CPU%u: stopping\n", cpu); dump_stack(); raw_spin_unlock(&stop_lock); } set_cpu_online(cpu, false); local_irq_disable(); while (1) cpu_relax(); }
static void __init swordfish_init(void) { int rc; msm_acpu_clock_init(&swordfish_clock_data); #if defined(CONFIG_MSM_SERIAL_DEBUGGER) msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3, &msm_device_uart3.dev, 1); #endif msm_device_hsusb.dev.platform_data = &msm_hsusb_pdata; msm_device_touchscreen.dev.platform_data = &swordfish_ts_pdata; platform_add_devices(devices, ARRAY_SIZE(devices)); msm_hsusb_set_vbus_state(1); rc = swordfish_init_mmc(); if (rc) pr_crit("%s: MMC init failure (%d)\n", __func__, rc); }
/* * platform-specific code to shutdown a CPU * * Called with IRQs disabled */ void platform_cpu_die(unsigned int cpu) { if (unlikely(cpu != smp_processor_id())) { pr_crit("%s: running on %u, should be %u\n", __func__, smp_processor_id(), cpu); BUG(); } complete(&__get_cpu_var(msm_hotplug_devices).cpu_killed); /* * we're ready for shutdown now, so do it */ cpu_enter_lowpower(); platform_do_lowpower(cpu); pr_notice("CPU%u: %s: normal wakeup\n", cpu, __func__); cpu_leave_lowpower(); }
/* * bad_mode handles the impossible case in the exception vector. */ asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr) { siginfo_t info; void __user *pc = (void __user *)instruction_pointer(regs); console_verbose(); pr_crit("Bad mode in %s handler detected, code 0x%08x\n", handler[reason], esr); __show_regs(regs); info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLOPC; info.si_addr = pc; arm64_notify_die("Oops - bad mode", regs, &info, 0); }
/* * Main handler for inter-processor interrupts */ void handle_IPI(int ipinr, struct pt_regs *regs) { unsigned int cpu = smp_processor_id(); struct pt_regs *old_regs = set_irq_regs(regs); if (ipinr >= IPI_RESCHEDULE && ipinr < IPI_RESCHEDULE + NR_IPI) __inc_irq_stat(cpu, ipi_irqs[ipinr - IPI_RESCHEDULE]); switch (ipinr) { case IPI_RESCHEDULE: scheduler_ipi(); break; case IPI_CALL_FUNC: irq_enter(); generic_smp_call_function_interrupt(); irq_exit(); break; case IPI_CALL_FUNC_SINGLE: irq_enter(); generic_smp_call_function_single_interrupt(); irq_exit(); break; case IPI_CPU_STOP: irq_enter(); ipi_cpu_stop(cpu); irq_exit(); break; #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST case IPI_TIMER: irq_enter(); tick_receive_broadcast(); irq_exit(); break; #endif default: pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); break; } set_irq_regs(old_regs); }
/* * Set up both clocksource and clockevent support. */ void __init at91sam926x_pit_init(void) { unsigned long pit_rate; unsigned bits; int ret; mck = ERR_PTR(-ENOENT); /* For device tree enabled device: initialize here */ of_at91sam926x_pit_init(); /* * Use our actual MCK to figure out how many MCK/16 ticks per * 1/HZ period (instead of a compile-time constant LATCH). */ if (IS_ERR(mck)) mck = clk_get(NULL, "mck"); if (IS_ERR(mck)) panic("AT91: PIT: Unable to get mck clk\n"); pit_rate = clk_get_rate(mck) / 16; pit_cycle = (pit_rate + HZ/2) / HZ; WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0); /* Initialize and enable the timer */ at91sam926x_pit_reset(); /* * Register clocksource. The high order bits of PIV are unused, * so this isn't a 32-bit counter unless we get clockevent irqs. */ bits = 12 /* PICNT */ + ilog2(pit_cycle) /* PIV */; pit_clk.mask = CLOCKSOURCE_MASK(bits); clocksource_register_hz(&pit_clk, pit_rate); /* Set up irq handler */ ret = setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq); if (ret) pr_crit("AT91: PIT: Unable to setup IRQ\n"); /* Set up and register clockevents */ pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift); pit_clkevt.cpumask = cpumask_of(0); clockevents_register_device(&pit_clkevt); }
static int iop_wdt_release(struct inode *inode, struct file *file) { int state = 1; if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) if (test_bit(WDT_ENABLED, &wdt_status)) state = wdt_disable(); if (state != 0) { wdt_enable(); pr_crit("Device closed unexpectedly - reset in %lu seconds\n", iop_watchdog_timeout()); } clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status); return 0; }
static int __init wrn_wdt_init(void) { int ret; // that's enough, termios struct must be initialized in user space by the WRN Daemon filp_port = filp_open(serial_port, O_RDWR | O_NOCTTY | O_NDELAY, 0); if (IS_ERR(filp_port)) { ret = PTR_ERR(filp_port); pr_crit("Unable to open port %s: %d\n", serial_port, ret); } else { ret = misc_register(&wrn_wdt_miscdev); if (ret == 0) wdt_timeout(); } return ret; }
void platform_cpu_die(unsigned int cpu) { int spurious = 0; if (unlikely(cpu != smp_processor_id())) { pr_crit("%s: running on %u, should be %u\n", __func__, smp_processor_id(), cpu); BUG(); } cpu_enter_lowpower(); platform_do_lowpower(cpu, &spurious); pr_debug("CPU%u: %s: normal wakeup\n", cpu, __func__); cpu_leave_lowpower(); if (spurious) pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious); }
struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, int alloc_mode) { struct jffs2_full_dnode *fn; size_t retlen; uint32_t flash_ofs; struct kvec vecs[2]; int ret; int retried = 0; unsigned long cnt = 2; D1(if(je32_to_cpu(ri->hdr_crc) != crc32(0, ri, sizeof(struct jffs2_unknown_node)-4)) { pr_crit("Eep. CRC not correct in jffs2_write_dnode()\n"); BUG(); } );
static int exynos_notify(struct thermal_zone_device *dev, int count, enum thermal_trip_type type) { char tmustate_string[20]; char *envp[2]; if (type == THERMAL_TRIP_CRITICAL) { snprintf(tmustate_string, sizeof(tmustate_string), "TMUSTATE=%d", THERMAL_TRIP_CRITICAL); envp[0] = tmustate_string; envp[1] = NULL; pr_crit("Try S/W tripping, send uevent %s\n", envp[0]); return kobject_uevent_env(&dev->device.kobj, KOBJ_CHANGE, envp); } return 0; }
static int __init get_cpu_for_node(struct device_node *node) { struct device_node *cpu_node; int cpu; cpu_node = of_parse_phandle(node, "cpu", 0); if (!cpu_node) return -1; cpu = of_cpu_node_to_id(cpu_node); if (cpu >= 0) topology_parse_cpu_capacity(cpu_node, cpu); else pr_crit("Unable to find CPU node for %pOF\n", cpu_node); of_node_put(cpu_node); return cpu; }
static void modem_unlock_timeout(struct work_struct *work) { void __iomem *hwio_modem_reset_addr = ioremap_nocache(MODEM_HWIO_MSS_RESET_ADDR, 8); pr_crit("%s: Timeout waiting for modem to unlock.\n", MODULE_NAME); /* We don't want it happens */ BUG_ON(!hwio_modem_reset_addr); /* Set MSS_MODEM_RESET to 0x0 since the unlock didn't work */ writel_relaxed(0x0, hwio_modem_reset_addr); /* Write needs to go through before the modem is restarted. */ mb(); iounmap(hwio_modem_reset_addr); subsystem_restart("modem"); enable_irq(MARM_WDOG_EXPIRED); }
void ip_forward_options(struct sk_buff *skb) { struct ip_options * opt = &(IPCB(skb)->opt); unsigned char * optptr; struct rtable *rt = skb_rtable(skb); unsigned char *raw = skb_network_header(skb); if (opt->rr_needaddr) { optptr = (unsigned char *)raw + opt->rr; ip_rt_get_source(&optptr[optptr[2]-5], skb, rt); opt->is_changed = 1; } if (opt->srr_is_hit) { int srrptr, srrspace; optptr = raw + opt->srr; for ( srrptr=optptr[2], srrspace = optptr[1]; srrptr <= srrspace; srrptr += 4 ) { if (srrptr + 3 > srrspace) break; if (memcmp(&opt->nexthop, &optptr[srrptr-1], 4) == 0) break; } if (srrptr + 3 <= srrspace) { opt->is_changed = 1; ip_hdr(skb)->daddr = opt->nexthop; ip_rt_get_source(&optptr[srrptr-1], skb, rt); optptr[2] = srrptr+4; } else if (net_ratelimit()) pr_crit("%s(): Argh! Destination lost!\n", __func__); if (opt->ts_needaddr) { optptr = raw + opt->ts; ip_rt_get_source(&optptr[optptr[2]-9], skb, rt); opt->is_changed = 1; } } if (opt->is_changed) { opt->is_changed = 0; ip_send_check(ip_hdr(skb)); } }
/** * power_down - Shut the machine down for hibernation. * * Use the platform driver, if configured, to put the system into the sleep * state corresponding to hibernation, or try to power it off or reboot, * depending on the value of hibernation_mode. */ static void power_down(void) { #ifdef CONFIG_SUSPEND int error; if (hibernation_mode == HIBERNATION_SUSPEND) { error = suspend_devices_and_enter(PM_SUSPEND_MEM); if (error) { hibernation_mode = hibernation_ops ? HIBERNATION_PLATFORM : HIBERNATION_SHUTDOWN; } else { /* Restore swap signature. */ error = swsusp_unmark(); if (error) pr_err("Swap will be unusable! Try swapon -a.\n"); return; } } #endif switch (hibernation_mode) { case HIBERNATION_REBOOT: kernel_restart(NULL); break; case HIBERNATION_PLATFORM: hibernation_platform_enter(); /* Fall through */ case HIBERNATION_SHUTDOWN: if (pm_power_off) kernel_power_off(); break; } kernel_halt(); /* * Valid image is on the disk, if we continue we risk serious data * corruption after resume. */ pr_crit("Power down manually\n"); while (1) cpu_relax(); }
static cycle_t tim_c_read(struct clocksource *cs) { unsigned int hi; unsigned int next_hi; unsigned int lo; hi = readl(&tim_c->hi); for (;;) { lo = readl(&tim_c->lo); next_hi = readl(&tim_c->hi); if (next_hi == hi) break; hi = next_hi; } pr_crit("%s: read %llx\n", __func__, ((u64) hi << 32) | lo); return ((u64) hi << 32) | lo; }
/* * Kill the calling secondary CPU, early in bringup before it is turned * online. */ void cpu_die_early(void) { int cpu = smp_processor_id(); pr_crit("CPU%d: will not boot\n", cpu); /* Mark this CPU absent */ set_cpu_present(cpu, 0); #ifdef CONFIG_HOTPLUG_CPU update_cpu_boot_status(CPU_KILL_ME); /* Check if we can park ourselves */ if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_die) cpu_ops[cpu]->cpu_die(cpu); #endif update_cpu_boot_status(CPU_STUCK_IN_KERNEL); cpu_park_loop(); }
static ssize_t driver_read(struct file *instance, char *user, size_t count, loff_t * offset) { unsigned long not_copied, to_copy, copied; private_data *data = (private_data *) instance->private_data; wait_queue_head_t *wait_queue; atomic_t *wake_up; if (data->read_data == NULL) { data->read_data = (read_data *) kmalloc(sizeof(read_data), GFP_KERNEL); check_memory(data->read_data); init_waitqueue_head(&data->read_data->wait_queue); INIT_WORK(&data->work, thread_read); pr_debug("Create consumer thread for the first time...\n"); } // Init read_data wait_queue = &data->read_data->wait_queue; wake_up = &data->read_data->wake_up; atomic_set(wake_up, 0); if (!queue_work(worker_queue, &data->work)) { pr_crit("queue_work not successful ...\n"); } if (wait_event_interruptible(*wait_queue, atomic_read(wake_up))) return -ERESTART; if (data->ret < 0) { return data->ret; } to_copy = data->ret; not_copied = copy_to_user(user, data->read_data->user, to_copy); copied = to_copy - not_copied; pr_debug("not_copied: %lu to_copy: %lu. count %d. %lu bytes read\n", not_copied, to_copy, count, copied); kfree(data->read_data->user); return copied; }
static int __init pcpu_verify_alloc_info(const struct pcpu_alloc_info *ai) { size_t nr_pages, alloc_pages; /* all units must be in a single group */ if (ai->nr_groups != 1) { pr_crit("can't handle more than one group\n"); return -EINVAL; } nr_pages = (ai->groups[0].nr_units * ai->unit_size) >> PAGE_SHIFT; alloc_pages = roundup_pow_of_two(nr_pages); if (alloc_pages > nr_pages) pr_warn("wasting %zu pages per chunk\n", alloc_pages - nr_pages); return 0; }
/* * row_be_expire_adjust() - find the queue has max expire time * @rd: pointer to struct row_data * * Return index of the queues has max expire time, return -1 * if no queues expire. * */ static int row_be_expire_adjust(struct row_data *rd) { int start_idx = ROWQ_HIGH_PRIO_IDX; int end_idx = ROWQ_LOW_PRIO_IDX; int i = 0; unsigned int max_expire_time = 0; int expire_number = 0; unsigned int timeout = 0; int expire_index = -1; unsigned int expire_time = 0; unsigned long temp_jiffies = jiffies; struct request *check_req = NULL; for (i = start_idx; i < end_idx; i++) { if (list_empty(&rd->row_queues[i].fifo)) continue; /*lint -save -e115*/ check_req = list_entry_rq(rd->row_queues[i].fifo.next); expire_time = jiffies_to_msecs(temp_jiffies - check_req->fifo_time); if (i < ROWQ_REG_PRIO_IDX && expire_time > HP_EXPIRE_TIME) timeout = expire_time - HP_EXPIRE_TIME; else if (expire_time > RP_EXPIRE_TIME) timeout = expire_time - RP_EXPIRE_TIME; /*lint restore*/ if (timeout > 0) { expire_number++; if (timeout > max_expire_time) { max_expire_time = timeout; expire_index = i; } timeout = 0; } } if (expire_number <= 0) expire_index = -1; else if (printk_ratelimit()) pr_crit("ROW_LOG:max expire time:%u in Q%d(%d-%d-%d-%d-%d)!!!\n", max_expire_time, expire_index, rd->row_queues[0].nr_req, rd->row_queues[1].nr_req, rd->row_queues[2].nr_req, rd->row_queues[3].nr_req, rd->row_queues[4].nr_req); return expire_index; }
static enum handoff pll_clk_handoff(struct clk *c) { struct pll_shared_clk *pll = to_pll_shared_clk(c); unsigned int pll_lval; struct pll_rate *l; /* * Wait for the PLLs to be initialized and then read their frequency. */ do { pll_lval = readl_relaxed(PLL_MODE_REG(pll) + 4) & 0x3ff; cpu_relax(); udelay(50); } while (pll_lval == 0); /* Convert PLL L values to PLL Output rate */ for (l = pll_l_rate; l->rate != 0; l++) { if (l->lvalue == pll_lval) { c->rate = l->rate; break; } } if (!c->rate) { pr_crit("Unknown PLL's L value!\n"); BUG(); } if (!pll_clk_is_enabled(c)) return HANDOFF_DISABLED_CLK; /* * Do not call pll_clk_enable() since that function can assume * the PLL is not in use when it's called. */ remote_spin_lock(&pll_lock); pll_control->pll[PLL_BASE + pll->id].votes |= BIT(1); pll_control->pll[PLL_BASE + pll->id].on = 1; remote_spin_unlock(&pll_lock); return HANDOFF_ENABLED_CLK; }
/* * bad_el0_sync handles unexpected, but potentially recoverable synchronous * exceptions taken from EL0. Unlike bad_mode, this returns. */ asmlinkage void bad_el0_sync(struct pt_regs *regs, int reason, unsigned int esr) { siginfo_t info; void __user *pc = (void __user *)instruction_pointer(regs); console_verbose(); pr_crit("Bad EL0 synchronous exception detected on CPU%d, code 0x%08x -- %s\n", smp_processor_id(), esr, esr_get_class_string(esr)); __show_regs(regs); info.si_signo = SIGILL; info.si_errno = 0; info.si_code = ILL_ILLOPC; info.si_addr = pc; current->thread.fault_address = 0; current->thread.fault_code = 0; force_sig_info(info.si_signo, &info, current); }
void __init udplite4_register(void) { udp_table_init(&udplite_table, "UDP-Lite"); if (proto_register(&udplite_prot, 1)) goto out_register_err; if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0) goto out_unregister_proto; inet_register_protosw(&udplite4_protosw); if (udplite4_proc_init()) pr_err("%s: Cannot register /proc!\n", __func__); return; out_unregister_proto: proto_unregister(&udplite_prot); out_register_err: pr_crit("%s: Cannot add UDP-Lite protocol\n", __func__); }
/* Set the different timeouts needed by the SCU FW and start the * kernel watchdog */ static int watchdog_set_timeouts_and_start(int pretimeout, int timeout) { int ret, error = 0; struct ipc_wd_start { u32 pretimeout; u32 timeout; } ipc_wd_start = { pretimeout, timeout }; ret = rpmsg_send_command(watchdog_instance, IPC_WATCHDOG, SCU_WATCHDOG_START, (u8 *)&ipc_wd_start, NULL, sizeof(ipc_wd_start), 0); if (ret) { pr_crit("Error configuring and starting watchdog: %d\n", ret); error = -EIO; } return error; }
static void qpnp_tm_work(struct work_struct *work) { struct delayed_work *dwork = container_of(work, struct delayed_work, work); struct qpnp_tm_chip *chip = container_of(dwork, struct qpnp_tm_chip, irq_work); int rc; u8 reg; if (chip->adc_type == QPNP_TM_ADC_NONE) { rc = qpnp_tm_update_temp_no_adc(chip); if (rc < 0) goto bail; } else { rc = qpnp_tm_read(chip, QPNP_TM_REG_STATUS, ®, 1); if (rc < 0) goto bail; chip->stage = reg & STATUS_STAGE_MASK; rc = qpnp_tm_update_temp(chip); if (rc < 0) goto bail; } if (chip->stage != chip->prev_stage) { chip->prev_stage = chip->stage; pr_crit("%s: PMIC Temp Alarm - stage=%u, threshold=%u, temperature=%lu mC\n", chip->tm_name, chip->stage, chip->thresh, chip->temperature); thermal_zone_device_update(chip->tz_dev); /* Notify user space */ sysfs_notify(&chip->tz_dev->device.kobj, NULL, "type"); } bail: return; }
static int __init get_cpu_for_node(struct device_node *node) { struct device_node *cpu_node; int cpu; cpu_node = of_parse_phandle(node, "cpu", 0); if (!cpu_node) return -1; for_each_possible_cpu(cpu) { if (of_get_cpu_node(cpu, NULL) == cpu_node) { of_node_put(cpu_node); return cpu; } } pr_crit("Unable to find CPU node for %s\n", cpu_node->full_name); of_node_put(cpu_node); return -1; }
void __init page_ext_init_flatmem(void) { int nid, fail; if (!invoke_need_callbacks()) return; for_each_online_node(nid) { fail = alloc_node_page_ext(nid); if (fail) goto fail; } pr_info("allocated %ld bytes of page_ext\n", total_usage); invoke_init_callbacks(); return; fail: pr_crit("allocation of page_ext failed.\n"); panic("Out of memory"); }