Skip to content
Snippets Groups Projects
Select Git revision
  • 02aaeb9b952f30b1ad6284d5d45be02030f679db
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

process.c

Blame
  • process.c 3.81 KiB
    /*
     * drivers/power/process.c - Functions for starting/stopping processes on 
     *                           suspend transitions.
     *
     * Originally from swsusp.
     */
    
    
    #undef DEBUG
    
    #include <linux/smp_lock.h>
    #include <linux/interrupt.h>
    #include <linux/suspend.h>
    #include <linux/module.h>
    #include <linux/syscalls.h>
    
    /* 
     * Timeout for stopping processes
     */
    #define TIMEOUT	(20 * HZ)
    
    
    static inline int freezeable(struct task_struct * p)
    {
    	if ((p == current) || 
    	    (p->flags & PF_NOFREEZE) ||
    	    (p->exit_state == EXIT_ZOMBIE) ||
    	    (p->exit_state == EXIT_DEAD) ||
    	    (p->state == TASK_STOPPED) ||
    	    (p->state == TASK_TRACED))
    		return 0;
    	return 1;
    }
    
    /* Refrigerator is place where frozen processes are stored :-). */
    void refrigerator(void)
    {
    	/* Hmm, should we be allowed to suspend when there are realtime
    	   processes around? */
    	long save;
    	save = current->state;
    	pr_debug("%s entered refrigerator\n", current->comm);
    	printk("=");
    
    	frozen_process(current);
    	spin_lock_irq(&current->sighand->siglock);
    	recalc_sigpending(); /* We sent fake signal, clean it up */
    	spin_unlock_irq(&current->sighand->siglock);
    
    	while (frozen(current)) {
    		current->state = TASK_UNINTERRUPTIBLE;
    		schedule();
    	}
    	pr_debug("%s left refrigerator\n", current->comm);
    	current->state = save;
    }
    
    static inline void freeze_process(struct task_struct *p)
    {
    	unsigned long flags;
    
    	if (!freezing(p)) {
    		freeze(p);
    		spin_lock_irqsave(&p->sighand->siglock, flags);
    		signal_wake_up(p, 0);
    		spin_unlock_irqrestore(&p->sighand->siglock, flags);
    	}
    }
    
    /* 0 = success, else # of processes that we failed to stop */