Merge tag 'docs-5.19-2' of git://git.lwn.net/linux
[linux-2.6-block.git] / drivers / gpu / host1x / intr.h
CommitLineData
9952f691 1/* SPDX-License-Identifier: GPL-2.0-only */
7ede0b0b
TB
2/*
3 * Tegra host1x Interrupt Management
4 *
5 * Copyright (c) 2010-2013, NVIDIA Corporation.
7ede0b0b
TB
6 */
7
8#ifndef __HOST1X_INTR_H
9#define __HOST1X_INTR_H
10
11#include <linux/interrupt.h>
12#include <linux/workqueue.h>
13
ac330f45 14struct host1x_syncpt;
7ede0b0b
TB
15struct host1x;
16
17enum host1x_intr_action {
6579324a
TB
18 /*
19 * Perform cleanup after a submit has completed.
20 * 'data' points to a channel
21 */
22 HOST1X_INTR_ACTION_SUBMIT_COMPLETE = 0,
23
7ede0b0b
TB
24 /*
25 * Wake up a task.
26 * 'data' points to a wait_queue_head_t
27 */
28 HOST1X_INTR_ACTION_WAKEUP,
29
30 /*
31 * Wake up a interruptible task.
32 * 'data' points to a wait_queue_head_t
33 */
34 HOST1X_INTR_ACTION_WAKEUP_INTERRUPTIBLE,
35
687db220
MP
36 HOST1X_INTR_ACTION_SIGNAL_FENCE,
37
7ede0b0b
TB
38 HOST1X_INTR_ACTION_COUNT
39};
40
41struct host1x_syncpt_intr {
42 spinlock_t lock;
43 struct list_head wait_head;
44 char thresh_irq_name[12];
45 struct work_struct work;
46};
47
48struct host1x_waitlist {
49 struct list_head list;
50 struct kref refcount;
51 u32 thresh;
52 enum host1x_intr_action action;
53 atomic_t state;
54 void *data;
55 int count;
56};
57
58/*
59 * Schedule an action to be taken when a sync point reaches the given threshold.
60 *
61 * @id the sync point
62 * @thresh the threshold
63 * @action the action to take
64 * @data a pointer to extra data depending on action, see above
65 * @waiter waiter structure - assumes ownership
66 * @ref must be passed if cancellation is possible, else NULL
67 *
68 * This is a non-blocking api.
69 */
ac330f45
TR
70int host1x_intr_add_action(struct host1x *host, struct host1x_syncpt *syncpt,
71 u32 thresh, enum host1x_intr_action action,
72 void *data, struct host1x_waitlist *waiter,
73 void **ref);
7ede0b0b
TB
74
75/*
76 * Unreference an action submitted to host1x_intr_add_action().
77 * You must call this if you passed non-NULL as ref.
78 * @ref the ref returned from host1x_intr_add_action()
ecfb888a 79 * @flush wait until any pending handlers have completed before returning.
7ede0b0b 80 */
ecfb888a
MP
81void host1x_intr_put_ref(struct host1x *host, unsigned int id, void *ref,
82 bool flush);
7ede0b0b
TB
83
84/* Initialize host1x sync point interrupt */
85int host1x_intr_init(struct host1x *host, unsigned int irq_sync);
86
87/* Deinitialize host1x sync point interrupt */
88void host1x_intr_deinit(struct host1x *host);
89
90/* Enable host1x sync point interrupt */
91void host1x_intr_start(struct host1x *host);
92
93/* Disable host1x sync point interrupt */
94void host1x_intr_stop(struct host1x *host);
95
96irqreturn_t host1x_syncpt_thresh_fn(void *dev_id);
97#endif