1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_FALCON_QMGR_H__
3 #define __NVKM_FALCON_QMGR_H__
4 #include <core/falcon.h>
6 #define HDR_SIZE sizeof(struct nv_falcon_msg)
7 #define QUEUE_ALIGNMENT 4
8 /* max size of the messages we can receive */
9 #define MSG_BUF_SIZE 128
12 * struct nvkm_falcon_qmgr_seq - keep track of ongoing commands
14 * Every time a command is sent, a sequence is assigned to it so the
15 * corresponding message can be matched. Upon receiving the message, a callback
16 * can be called and/or a completion signaled.
19 * @state: current state
20 * @callback: callback to call upon receiving matching message
21 * @completion: completion to signal after callback is called
23 struct nvkm_falcon_qmgr_seq
{
32 nvkm_falcon_qmgr_callback callback
;
34 struct completion done
;
39 * We can have an arbitrary number of sequences, but realistically we will
40 * probably not use that much simultaneously.
42 #define NVKM_FALCON_QMGR_SEQ_NUM 16
44 struct nvkm_falcon_qmgr
{
45 struct nvkm_falcon
*falcon
;
49 struct nvkm_falcon_qmgr_seq id
[NVKM_FALCON_QMGR_SEQ_NUM
];
50 unsigned long tbl
[BITS_TO_LONGS(NVKM_FALCON_QMGR_SEQ_NUM
)];
54 struct nvkm_falcon_qmgr_seq
*
55 nvkm_falcon_qmgr_seq_acquire(struct nvkm_falcon_qmgr
*);
56 void nvkm_falcon_qmgr_seq_release(struct nvkm_falcon_qmgr
*,
57 struct nvkm_falcon_qmgr_seq
*);
59 struct nvkm_falcon_cmdq
{
60 struct nvkm_falcon_qmgr
*qmgr
;
63 struct completion ready
;
73 struct nvkm_falcon_msgq
{
74 struct nvkm_falcon_qmgr
*qmgr
;
85 #define FLCNQ_PRINTK(t,q,f,a...) \
86 FLCN_PRINTK(t, (q)->qmgr->falcon, "%s: "f, (q)->name, ##a)
87 #define FLCNQ_DBG(q,f,a...) FLCNQ_PRINTK(debug, (q), f, ##a)
88 #define FLCNQ_ERR(q,f,a...) FLCNQ_PRINTK(error, (q), f, ##a)