Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.2.
 1/* SPDX-License-Identifier: MIT */
 2/*
 3 * Copyright © 2022 Intel Corporation
 4 */
 5
 6#ifndef _XE_FORCE_WAKE_H_
 7#define _XE_FORCE_WAKE_H_
 8
 9#include "xe_assert.h"
10#include "xe_force_wake_types.h"
11
12struct xe_gt;
13
14void xe_force_wake_init_gt(struct xe_gt *gt,
15			   struct xe_force_wake *fw);
16void xe_force_wake_init_engines(struct xe_gt *gt,
17				struct xe_force_wake *fw);
18unsigned int __must_check xe_force_wake_get(struct xe_force_wake *fw,
19					    enum xe_force_wake_domains domains);
20void xe_force_wake_put(struct xe_force_wake *fw, unsigned int fw_ref);
21
22static inline int
23xe_force_wake_ref(struct xe_force_wake *fw,
24		  enum xe_force_wake_domains domain)
25{
26	xe_gt_assert(fw->gt, domain != XE_FORCEWAKE_ALL);
27	return fw->domains[ffs(domain) - 1].ref;
28}
29
30/**
31 * xe_force_wake_assert_held - asserts domain is awake
32 * @fw : xe_force_wake structure
33 * @domain: xe_force_wake_domains apart from XE_FORCEWAKE_ALL
34 *
35 * xe_force_wake_assert_held() is designed to confirm a particular
36 * forcewake domain's wakefulness; it doesn't verify the wakefulness of
37 * multiple domains. Make sure the caller doesn't input multiple
38 * domains(XE_FORCEWAKE_ALL) as a parameter.
39 */
40static inline void
41xe_force_wake_assert_held(struct xe_force_wake *fw,
42			  enum xe_force_wake_domains domain)
43{
44	xe_gt_assert(fw->gt, domain != XE_FORCEWAKE_ALL);
45	xe_gt_assert(fw->gt, fw->awake_domains & domain);
46}
47
48/**
49 * xe_force_wake_ref_has_domain - verifies if the domains are in fw_ref
50 * @fw_ref : the force_wake reference
51 * @domain : forcewake domain to verify
52 *
53 * This function confirms whether the @fw_ref includes a reference to the
54 * specified @domain.
55 *
56 * Return: true if domain is refcounted.
57 */
58static inline bool
59xe_force_wake_ref_has_domain(unsigned int fw_ref, enum xe_force_wake_domains domain)
60{
61	return fw_ref & domain;
62}
63
64#endif