drivers/gpu/drm/i915/intel_runtime_pm.h

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/intel_runtime_pm.h

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/i915/intel_runtime_pm.h
Extension
.h
Size
8160 bytes
Lines
233
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct intel_runtime_pm {
	atomic_t wakeref_count;
	struct device *kdev; /* points to i915->drm.dev */
	bool available;
	bool no_wakeref_tracking;

	/*
	 *  Protects access to lmem usefault list.
	 *  It is required, if we are outside of the runtime suspend path,
	 *  access to @lmem_userfault_list requires always first grabbing the
	 *  runtime pm, to ensure we can't race against runtime suspend.
	 *  Once we have that we also need to grab @lmem_userfault_lock,
	 *  at which point we have exclusive access.
	 *  The runtime suspend path is special since it doesn't really hold any locks,
	 *  but instead has exclusive access by virtue of all other accesses requiring
	 *  holding the runtime pm wakeref.
	 */
	spinlock_t lmem_userfault_lock;

	/*
	 *  Keep list of userfaulted gem obj, which require to release their
	 *  mmap mappings at runtime suspend path.
	 */
	struct list_head lmem_userfault_list;

	/* Manual runtime pm autosuspend delay for user GGTT/lmem mmaps */
	struct intel_wakeref_auto userfault_wakeref;

#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
	/*
	 * To aide detection of wakeref leaks and general misuse, we
	 * track all wakeref holders. With manual markup (i.e. returning
	 * a cookie to each rpm_get caller which they then supply to their
	 * paired rpm_put) we can remove corresponding pairs of and keep
	 * the array trimmed to active wakerefs.
	 */
	struct ref_tracker_dir debug;
#endif
};

#define BITS_PER_WAKEREF	\
	BITS_PER_TYPE(typeof_member(struct intel_runtime_pm, wakeref_count))
#define INTEL_RPM_WAKELOCK_SHIFT	(BITS_PER_WAKEREF / 2)
#define INTEL_RPM_WAKELOCK_BIAS		(1 << INTEL_RPM_WAKELOCK_SHIFT)
#define INTEL_RPM_RAW_WAKEREF_MASK	(INTEL_RPM_WAKELOCK_BIAS - 1)

static inline int
intel_rpm_raw_wakeref_count(int wakeref_count)
{
	return wakeref_count & INTEL_RPM_RAW_WAKEREF_MASK;
}

static inline int
intel_rpm_wakelock_count(int wakeref_count)
{
	return wakeref_count >> INTEL_RPM_WAKELOCK_SHIFT;
}

static inline bool
intel_runtime_pm_suspended(struct intel_runtime_pm *rpm)
{
	return pm_runtime_suspended(rpm->kdev);
}

static inline void
assert_rpm_device_not_suspended(struct intel_runtime_pm *rpm)
{
	WARN_ONCE(intel_runtime_pm_suspended(rpm),
		  "Device suspended during HW access\n");
}

static inline void
__assert_rpm_raw_wakeref_held(struct intel_runtime_pm *rpm, int wakeref_count)
{
	assert_rpm_device_not_suspended(rpm);
	WARN_ONCE(!intel_rpm_raw_wakeref_count(wakeref_count),
		  "RPM raw-wakeref not held\n");
}

static inline void
__assert_rpm_wakelock_held(struct intel_runtime_pm *rpm, int wakeref_count)
{
	__assert_rpm_raw_wakeref_held(rpm, wakeref_count);
	WARN_ONCE(!intel_rpm_wakelock_count(wakeref_count),
		  "RPM wakelock ref not held during HW access\n");
}

static inline void
assert_rpm_raw_wakeref_held(struct intel_runtime_pm *rpm)
{

Annotation

Implementation Notes