int __intel_wakeref_get_first(struct intel_wakeref *wf); void __intel_wakeref_put_last(struct intel_wakeref *wf, unsignedlong flags);
/** * intel_wakeref_get: Acquire the wakeref * @wf: the wakeref * * Acquire a hold on the wakeref. The first user to do so, will acquire * the runtime pm wakeref and then call the intel_wakeref_ops->get() * underneath the wakeref mutex. * * Note that intel_wakeref_ops->get() is allowed to fail, in which case * the runtime-pm wakeref will be released and the acquisition unwound, * and an error reported. * * Returns: 0 if the wakeref was acquired successfully, or a negative error * code otherwise.
*/ staticinlineint
intel_wakeref_get(struct intel_wakeref *wf)
{
might_sleep(); if (unlikely(!atomic_inc_not_zero(&wf->count))) return __intel_wakeref_get_first(wf);
return 0;
}
/** * __intel_wakeref_get: Acquire the wakeref, again * @wf: the wakeref * * Increment the wakeref counter, only valid if it is already held by * the caller. * * See intel_wakeref_get().
*/ staticinlinevoid
__intel_wakeref_get(struct intel_wakeref *wf)
{
INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0);
atomic_inc(&wf->count);
}
/** * intel_wakeref_get_if_active: Acquire the wakeref * @wf: the wakeref * * Acquire a hold on the wakeref, but only if the wakeref is already * active. * * Returns: true if the wakeref was acquired, false otherwise.
*/ staticinlinebool
intel_wakeref_get_if_active(struct intel_wakeref *wf)
{ return atomic_inc_not_zero(&wf->count);
}
/** * __intel_wakeref_put: Release the wakeref * @wf: the wakeref * @flags: control flags * * Release our hold on the wakeref. When there are no more users, * the runtime pm wakeref will be released after the intel_wakeref_ops->put() * callback is called underneath the wakeref mutex. * * Note that intel_wakeref_ops->put() is allowed to fail, in which case the * runtime-pm wakeref is retained. *
*/ staticinlinevoid
__intel_wakeref_put(struct intel_wakeref *wf, unsignedlong flags) #define INTEL_WAKEREF_PUT_ASYNC BIT(INTEL_WAKEREF_PUT_ASYNC_BIT) #define INTEL_WAKEREF_PUT_DELAY \
GENMASK(BITS_PER_LONG - 1, __INTEL_WAKEREF_PUT_LAST_BIT__)
{
INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0); if (unlikely(!atomic_add_unless(&wf->count, -1, 1)))
__intel_wakeref_put_last(wf, flags);
}
/** * intel_wakeref_lock: Lock the wakeref (mutex) * @wf: the wakeref * * Locks the wakeref to prevent it being acquired or released. New users * can still adjust the counter, but the wakeref itself (and callback) * cannot be acquired or released.
*/ staticinlinevoid
intel_wakeref_lock(struct intel_wakeref *wf)
__acquires(wf->mutex)
{
mutex_lock(&wf->mutex);
}
/** * intel_wakeref_unlock: Unlock the wakeref * @wf: the wakeref * * Releases a previously acquired intel_wakeref_lock().
*/ staticinlinevoid
intel_wakeref_unlock(struct intel_wakeref *wf)
__releases(wf->mutex)
{
mutex_unlock(&wf->mutex);
}
/** * intel_wakeref_unlock_wait: Wait until the active callback is complete * @wf: the wakeref * * Waits for the active callback (under the @wf->mutex or another CPU) is * complete.
*/ staticinlinevoid
intel_wakeref_unlock_wait(struct intel_wakeref *wf)
{
mutex_lock(&wf->mutex);
mutex_unlock(&wf->mutex);
flush_delayed_work(&wf->work);
}
/** * intel_wakeref_is_active: Query whether the wakeref is currently held * @wf: the wakeref * * Returns: true if the wakeref is currently held.
*/ staticinlinebool
intel_wakeref_is_active(conststruct intel_wakeref *wf)
{ return READ_ONCE(wf->wakeref);
}
/** * __intel_wakeref_defer_park: Defer the current park callback * @wf: the wakeref
*/ staticinlinevoid
__intel_wakeref_defer_park(struct intel_wakeref *wf)
{
lockdep_assert_held(&wf->mutex);
INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count));
atomic_set_release(&wf->count, 1);
}
/** * intel_wakeref_wait_for_idle: Wait until the wakeref is idle * @wf: the wakeref * * Wait for the earlier asynchronous release of the wakeref. Note * this will wait for any third party as well, so make sure you only wait * when you have control over the wakeref and trust no one else is acquiring * it. * * Return: 0 on success, error code if killed.
*/ int intel_wakeref_wait_for_idle(struct intel_wakeref *wf);
/** * intel_wakeref_auto: Delay the runtime-pm autosuspend * @wf: the wakeref * @timeout: relative timeout in jiffies * * The runtime-pm core uses a suspend delay after the last wakeref * is released before triggering runtime suspend of the device. That * delay is configurable via sysfs with little regard to the device * characteristics. Instead, we want to tune the autosuspend based on our * HW knowledge. intel_wakeref_auto() delays the sleep by the supplied * timeout. * * Pass @timeout = 0 to cancel a previous autosuspend by executing the * suspend immediately.
*/ void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsignedlong timeout);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.