3 * (C) COPYRIGHT 2014 ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the
6 * GNU General Public License version 2 as published by the Free Software
7 * Foundation, and any use by you of this program is subject to the terms
10 * A copy of the licence is included with the program, and can also be obtained
11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12 * Boston, MA 02110-1301, USA.
19 * Base kernel disjoint events helper functions
22 #include <mali_kbase.h>
24 void kbase_disjoint_init(struct kbase_device *kbdev)
26 KBASE_DEBUG_ASSERT(kbdev != NULL);
28 atomic_set(&kbdev->disjoint_event.count, 0);
29 atomic_set(&kbdev->disjoint_event.state, 0);
32 /* increment the disjoint event count */
33 void kbase_disjoint_event(struct kbase_device *kbdev)
35 KBASE_DEBUG_ASSERT(kbdev != NULL);
37 atomic_inc(&kbdev->disjoint_event.count);
40 /* increment the state and the event counter */
41 void kbase_disjoint_state_up(struct kbase_device *kbdev)
43 KBASE_DEBUG_ASSERT(kbdev != NULL);
45 atomic_inc(&kbdev->disjoint_event.state);
47 kbase_disjoint_event(kbdev);
50 /* decrement the state */
51 void kbase_disjoint_state_down(struct kbase_device *kbdev)
53 KBASE_DEBUG_ASSERT(kbdev != NULL);
54 KBASE_DEBUG_ASSERT(atomic_read(&kbdev->disjoint_event.state) > 0);
56 kbase_disjoint_event(kbdev);
58 atomic_dec(&kbdev->disjoint_event.state);
61 /* increments the count only if the state is > 0 */
62 void kbase_disjoint_event_potential(struct kbase_device *kbdev)
64 KBASE_DEBUG_ASSERT(kbdev != NULL);
66 if (atomic_read(&kbdev->disjoint_event.state))
67 kbase_disjoint_event(kbdev);
70 u32 kbase_disjoint_event_get(struct kbase_device *kbdev)
72 KBASE_DEBUG_ASSERT(kbdev != NULL);
74 return atomic_read(&kbdev->disjoint_event.count);
76 KBASE_EXPORT_TEST_API(kbase_disjoint_event_get);