https://github.com/torvalds/linux
Revision 2266b058d3ab9dfc545305d68e754ad9c9a639a0 authored by Dave Airlie on 27 June 2012, 18:56:20 UTC, committed by Dave Airlie on 27 June 2012, 18:56:20 UTC
Daniel writes:
"Two tiny patches and one revert:
- Kill a bogus error message introduced in 3.4, further Bspec reading
  indicates that this is how the hw is supposed to work.
- Reorder one backlight register restore, fixing broken backlight on some
  machines after resume.
- Revert a hack from Jesse for ivb backlight control - it breaks the
  backlight controls on my shiny new ivb laptop."

* 'drm-intel-fixes' of git://people.freedesktop.org/~danvet/drm-intel:
  Revert "drm/i915: allow PCH PWM override on IVB"
  drm/i915: Fix eDP blank screen after S3 resume on HP desktops
  drm/i915: rip out the PM_IIR WARN
2 parent s e9bf5f3 + 7aa1e7f
Raw File
Tip revision: 2266b058d3ab9dfc545305d68e754ad9c9a639a0 authored by Dave Airlie on 27 June 2012, 18:56:20 UTC
Merge branch 'drm-intel-fixes' of git://people.freedesktop.org/~danvet/drm-intel into drm-fixes
Tip revision: 2266b05
task_work.c
#include <linux/spinlock.h>
#include <linux/task_work.h>
#include <linux/tracehook.h>

int
task_work_add(struct task_struct *task, struct task_work *twork, bool notify)
{
	unsigned long flags;
	int err = -ESRCH;

#ifndef TIF_NOTIFY_RESUME
	if (notify)
		return -ENOTSUPP;
#endif
	/*
	 * We must not insert the new work if the task has already passed
	 * exit_task_work(). We rely on do_exit()->raw_spin_unlock_wait()
	 * and check PF_EXITING under pi_lock.
	 */
	raw_spin_lock_irqsave(&task->pi_lock, flags);
	if (likely(!(task->flags & PF_EXITING))) {
		hlist_add_head(&twork->hlist, &task->task_works);
		err = 0;
	}
	raw_spin_unlock_irqrestore(&task->pi_lock, flags);

	/* test_and_set_bit() implies mb(), see tracehook_notify_resume(). */
	if (likely(!err) && notify)
		set_notify_resume(task);
	return err;
}

struct task_work *
task_work_cancel(struct task_struct *task, task_work_func_t func)
{
	unsigned long flags;
	struct task_work *twork;
	struct hlist_node *pos;

	raw_spin_lock_irqsave(&task->pi_lock, flags);
	hlist_for_each_entry(twork, pos, &task->task_works, hlist) {
		if (twork->func == func) {
			hlist_del(&twork->hlist);
			goto found;
		}
	}
	twork = NULL;
 found:
	raw_spin_unlock_irqrestore(&task->pi_lock, flags);

	return twork;
}

void task_work_run(void)
{
	struct task_struct *task = current;
	struct hlist_head task_works;
	struct hlist_node *pos;

	raw_spin_lock_irq(&task->pi_lock);
	hlist_move_list(&task->task_works, &task_works);
	raw_spin_unlock_irq(&task->pi_lock);

	if (unlikely(hlist_empty(&task_works)))
		return;
	/*
	 * We use hlist to save the space in task_struct, but we want fifo.
	 * Find the last entry, the list should be short, then process them
	 * in reverse order.
	 */
	for (pos = task_works.first; pos->next; pos = pos->next)
		;

	for (;;) {
		struct hlist_node **pprev = pos->pprev;
		struct task_work *twork = container_of(pos, struct task_work,
							hlist);
		twork->func(twork);

		if (pprev == &task_works.first)
			break;
		pos = container_of(pprev, struct hlist_node, next);
	}
}
back to top