drivers/gpu/drm/i915/intel_wakeref.h
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/intel_wakeref.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/intel_wakeref.h- Extension
.h- Size
- 8686 bytes
- Lines
- 352
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/atomic.hlinux/bitfield.hlinux/bits.hlinux/lockdep.hlinux/mutex.hlinux/refcount.hlinux/ref_tracker.hlinux/timer.hlinux/workqueue.h
Detected Declarations
struct drm_printerstruct intel_runtime_pmstruct intel_wakerefstruct intel_wakeref_opsstruct intel_wakerefstruct intel_wakeref_lockclassstruct intel_wakeref_autofunction intel_wakeref_getfunction intel_wakeref_getfunction intel_wakeref_get_if_activefunction intel_wakeref_might_getfunction __intel_wakeref_putfunction intel_wakeref_putfunction intel_wakeref_put_asyncfunction intel_wakeref_put_delayfunction intel_wakeref_might_putfunction intel_wakeref_lockfunction intel_wakeref_lockfunction callbackfunction intel_wakeref_is_activefunction __intel_wakeref_defer_parkfunction intel_ref_tracker_allocfunction intel_ref_tracker_freefunction intel_wakeref_trackfunction intel_wakeref_untrackfunction intel_wakeref_trackfunction intel_wakeref_untrack
Annotated Snippet
struct intel_wakeref_ops {
int (*get)(struct intel_wakeref *wf);
int (*put)(struct intel_wakeref *wf);
};
struct intel_wakeref {
atomic_t count;
struct mutex mutex;
intel_wakeref_t wakeref;
struct drm_i915_private *i915;
const struct intel_wakeref_ops *ops;
struct delayed_work work;
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_WAKEREF)
struct ref_tracker_dir debug;
#endif
};
struct intel_wakeref_lockclass {
struct lock_class_key mutex;
struct lock_class_key work;
};
void __intel_wakeref_init(struct intel_wakeref *wf,
struct drm_i915_private *i915,
const struct intel_wakeref_ops *ops,
struct intel_wakeref_lockclass *key,
const char *name);
#define intel_wakeref_init(wf, i915, ops, name) do { \
static struct intel_wakeref_lockclass __key; \
\
__intel_wakeref_init((wf), (i915), (ops), &__key, name); \
} while (0)
int __intel_wakeref_get_first(struct intel_wakeref *wf);
void __intel_wakeref_put_last(struct intel_wakeref *wf, unsigned long 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.
*/
static inline int
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().
*/
static inline void
__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.
*/
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bitfield.h`, `linux/bits.h`, `linux/lockdep.h`, `linux/mutex.h`, `linux/refcount.h`, `linux/ref_tracker.h`, `linux/timer.h`.
- Detected declarations: `struct drm_printer`, `struct intel_runtime_pm`, `struct intel_wakeref`, `struct intel_wakeref_ops`, `struct intel_wakeref`, `struct intel_wakeref_lockclass`, `struct intel_wakeref_auto`, `function intel_wakeref_get`, `function intel_wakeref_get`, `function intel_wakeref_get_if_active`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.