Home | History | Annotate | Download | only in i915

Lines Matching defs:wf

19 static void rpm_get(struct intel_wakeref *wf)
21 wf->wakeref = intel_runtime_pm_get(wf->rpm);
24 static void rpm_put(struct intel_wakeref *wf)
26 intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref);
28 intel_runtime_pm_put(wf->rpm, wakeref);
31 DRM_WAKEUP_ALL(&wf->wq, &wf->mutex);
34 int __intel_wakeref_get_first(struct intel_wakeref *wf)
42 mutex_lock_nested(&wf->mutex, SINGLE_DEPTH_NESTING);
43 if (!atomic_read(&wf->count)) {
46 rpm_get(wf);
48 err = wf->ops->get(wf);
50 rpm_put(wf);
51 mutex_unlock(&wf->mutex);
55 smp_mb__before_atomic(); /* release wf->count */
57 atomic_inc(&wf->count);
58 mutex_unlock(&wf->mutex);
60 INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0);
64 static void ____intel_wakeref_put_last(struct intel_wakeref *wf)
66 INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0);
67 if (unlikely(!atomic_dec_and_test(&wf->count))) {
68 mutex_unlock(&wf->mutex);
73 if (likely(!wf->ops->put(wf))) {
74 rpm_put(wf);
77 mutex_unlock(&wf->mutex);
80 void __intel_wakeref_put_last(struct intel_wakeref *wf, unsigned long flags)
82 INTEL_WAKEREF_BUG_ON(work_pending(&wf->work));
85 if (flags & INTEL_WAKEREF_PUT_ASYNC || !mutex_trylock(&wf->mutex)) {
86 schedule_work(&wf->work);
90 ____intel_wakeref_put_last(wf);
95 struct intel_wakeref *wf = container_of(wrk, typeof(*wf), work);
97 if (atomic_add_unless(&wf->count, -1, 1))
100 mutex_lock(&wf->mutex);
101 ____intel_wakeref_put_last(wf);
104 void __intel_wakeref_init(struct intel_wakeref *wf,
109 wf->rpm = rpm;
110 wf->ops = ops;
112 __mutex_init(&wf->mutex, "wakeref.mutex", &key->mutex);
113 atomic_set(&wf->count, 0);
114 wf->wakeref = 0;
115 DRM_INIT_WAITQUEUE(&wf->wq, "i915wake");
117 INIT_WORK(&wf->work, __intel_wakeref_put_work);
118 lockdep_init_map(&wf->work.lockdep_map, "wakeref.work", &key->work, 0);
122 intel_wakeref_fini(struct intel_wakeref *wf)
125 DRM_DESTROY_WAITQUEUE(&wf->wq);
126 mutex_destroy(&wf->mutex);
129 int intel_wakeref_wait_for_idle(struct intel_wakeref *wf)
135 mutex_lock(&wf->mutex);
136 DRM_WAIT_UNTIL(err, &wf->wq, &wf->mutex, !intel_wakeref_is_active(wf));
137 mutex_unlock(&wf->mutex);
141 intel_wakeref_unlock_wait(wf);
147 struct intel_wakeref_auto *wf = from_timer(wf, t, timer);
151 if (!refcount_dec_and_lock_irqsave(&wf->count, &wf->lock, &flags))
154 wakeref = fetch_and_zero(&wf->wakeref);
155 spin_unlock_irqrestore(&wf->lock, flags);
157 intel_runtime_pm_put(wf->rpm, wakeref);
160 void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
163 spin_lock_init(&wf->lock);
164 timer_setup(&wf->timer, wakeref_auto_timeout, 0);
165 refcount_set(&wf->count, 0);
166 wf->wakeref = 0;
167 wf->rpm = rpm;
170 void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
175 if (del_timer_sync(&wf->timer))
176 wakeref_auto_timeout(&wf->timer);
181 assert_rpm_wakelock_held(wf->rpm);
183 if (!refcount_inc_not_zero(&wf->count)) {
184 spin_lock_irqsave(&wf->lock, flags);
185 if (!refcount_inc_not_zero(&wf->count)) {
186 INTEL_WAKEREF_BUG_ON(wf->wakeref);
187 wf->wakeref = intel_runtime_pm_get_if_in_use(wf->rpm);
188 refcount_set(&wf->count, 1);
190 spin_unlock_irqrestore(&wf->lock, flags);
196 * elided callback to keep the wf->count balanced.
198 if (mod_timer(&wf->timer, jiffies + timeout))
199 wakeref_auto_timeout(&wf->timer);
202 void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf)
204 intel_wakeref_auto(wf, 0);
205 INTEL_WAKEREF_BUG_ON(wf->wakeref);
206 spin_lock_destroy(&wf->lock);