Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e4def20 authored by David Howells's avatar David Howells
Browse files

Pass mode to wait_on_atomic_t() action funcs and provide default actions



Make wait_on_atomic_t() pass the TASK_* mode onto its action function as an
extra argument and make it 'unsigned int throughout.

Also, consolidate a bunch of identical action functions into a default
function that can do the appropriate thing for the mode.

Also, change the argument name in the bit_wait*() function declarations to
reflect the fact that it's the mode and not the bit number.

[Peter Z gives this a grudging ACK, but thinks that the whole atomic_t wait
should be done differently, though he's not immediately sure as to how]

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
parent 81445e63
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -1233,18 +1233,6 @@ static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
	return NOTIFY_OK;
}

static int wait_on_fp_mode_switch(atomic_t *p)
{
	/*
	 * The FP mode for this task is currently being switched. That may
	 * involve modifications to the format of this tasks FP context which
	 * make it unsafe to proceed with execution for the moment. Instead,
	 * schedule some other task.
	 */
	schedule();
	return 0;
}

static int enable_restore_fp_context(int msa)
{
	int err, was_fpu_owner, prior_msa;
@@ -1254,7 +1242,7 @@ static int enable_restore_fp_context(int msa)
	 * complete before proceeding.
	 */
	wait_on_atomic_t(&current->mm->context.fp_mode_switching,
			 wait_on_fp_mode_switch, TASK_KILLABLE);
			 atomic_t_wait, TASK_KILLABLE);

	if (!used_math()) {
		/* First time FP context user. */
+1 −7
Original line number Diff line number Diff line
@@ -263,12 +263,6 @@ static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_aux(struct drm_dp_aux *aux)
	return aux_dev;
}

static int auxdev_wait_atomic_t(atomic_t *p)
{
	schedule();
	return 0;
}

void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
{
	struct drm_dp_aux_dev *aux_dev;
@@ -283,7 +277,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
	mutex_unlock(&aux_idr_mutex);

	atomic_dec(&aux_dev->usecount);
	wait_on_atomic_t(&aux_dev->usecount, auxdev_wait_atomic_t,
	wait_on_atomic_t(&aux_dev->usecount, atomic_t_wait,
			 TASK_UNINTERRUPTIBLE);

	minor = aux_dev->index;
+2 −8
Original line number Diff line number Diff line
@@ -271,13 +271,7 @@ struct igt_wakeup {
	u32 seqno;
};

static int wait_atomic(atomic_t *p)
{
	schedule();
	return 0;
}

static int wait_atomic_timeout(atomic_t *p)
static int wait_atomic_timeout(atomic_t *p, unsigned int mode)
{
	return schedule_timeout(10 * HZ) ? 0 : -ETIMEDOUT;
}
@@ -348,7 +342,7 @@ static void igt_wake_all_sync(atomic_t *ready,
	atomic_set(ready, 0);
	wake_up_all(wq);

	wait_on_atomic_t(set, wait_atomic, TASK_UNINTERRUPTIBLE);
	wait_on_atomic_t(set, atomic_t_wait, TASK_UNINTERRUPTIBLE);
	atomic_set(ready, count);
	atomic_set(done, count);
}
+1 −7
Original line number Diff line number Diff line
@@ -88,12 +88,6 @@ int hfi_core_init(struct venus_core *core)
	return ret;
}

static int core_deinit_wait_atomic_t(atomic_t *p)
{
	schedule();
	return 0;
}

int hfi_core_deinit(struct venus_core *core, bool blocking)
{
	int ret = 0, empty;
@@ -112,7 +106,7 @@ int hfi_core_deinit(struct venus_core *core, bool blocking)

	if (!empty) {
		mutex_unlock(&core->lock);
		wait_on_atomic_t(&core->insts_count, core_deinit_wait_atomic_t,
		wait_on_atomic_t(&core->insts_count, atomic_t_wait,
				 TASK_UNINTERRUPTIBLE);
		mutex_lock(&core->lock);
	}
+1 −7
Original line number Diff line number Diff line
@@ -41,12 +41,6 @@ static void afs_charge_preallocation(struct work_struct *);

static DECLARE_WORK(afs_charge_preallocation_work, afs_charge_preallocation);

static int afs_wait_atomic_t(atomic_t *p)
{
	schedule();
	return 0;
}

/*
 * open an RxRPC socket and bind it to be a server for callback notifications
 * - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT
@@ -121,7 +115,7 @@ void afs_close_socket(void)
	}

	_debug("outstanding %u", atomic_read(&afs_outstanding_calls));
	wait_on_atomic_t(&afs_outstanding_calls, afs_wait_atomic_t,
	wait_on_atomic_t(&afs_outstanding_calls, atomic_t_wait,
			 TASK_UNINTERRUPTIBLE);
	_debug("no outstanding calls");

Loading