1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2019 Intel Corporation
6 #ifndef __INTEL_BREADCRUMBS_TYPES__
7 #define __INTEL_BREADCRUMBS_TYPES__
9 #include <linux/irq_work.h>
10 #include <linux/kref.h>
11 #include <linux/list.h>
12 #include <linux/spinlock.h>
13 #include <linux/types.h>
15 #include "intel_engine_types.h"
18 * Rather than have every client wait upon all user interrupts,
19 * with the herd waking after every interrupt and each doing the
20 * heavyweight seqno dance, we delegate the task (of being the
21 * bottom-half of the user interrupt) to the first client. After
22 * every interrupt, we wake up one client, who does the heavyweight
23 * coherent seqno read and either goes back to sleep (if incomplete),
24 * or wakes up all the completed clients in parallel, before then
25 * transferring the bottom-half status to the next client in the queue.
27 * Compared to walking the entire list of waiters in a single dedicated
28 * bottom-half, we reduce the latency of the first waiter by avoiding
29 * a context switch, but incur additional coherent seqno reads when
30 * following the chain of request breadcrumbs. Since it is most likely
31 * that we have a single client waiting on each seqno, then reducing
32 * the overhead of waking that client is much preferred.
34 struct intel_breadcrumbs {
38 spinlock_t signalers_lock; /* protects the list of signalers */
39 struct list_head signalers;
40 struct llist_head signaled_requests;
41 atomic_t signaler_active;
43 spinlock_t irq_lock; /* protects the interrupt from hardirq context */
44 struct irq_work irq_work; /* for use from inside irq_lock */
45 unsigned int irq_enabled;
48 /* Not all breadcrumbs are attached to physical HW */
49 intel_engine_mask_t engine_mask;
50 struct intel_engine_cs *irq_engine;
51 bool (*irq_enable)(struct intel_breadcrumbs *b);
52 void (*irq_disable)(struct intel_breadcrumbs *b);
55 #endif /* __INTEL_BREADCRUMBS_TYPES__ */