Lines Matching refs:msgq

26 nvkm_falcon_msgq_open(struct nvkm_falcon_msgq *msgq)  in nvkm_falcon_msgq_open()  argument
28 mutex_lock(&msgq->mutex); in nvkm_falcon_msgq_open()
29 msgq->position = nvkm_falcon_rd32(msgq->qmgr->falcon, msgq->tail_reg); in nvkm_falcon_msgq_open()
33 nvkm_falcon_msgq_close(struct nvkm_falcon_msgq *msgq, bool commit) in nvkm_falcon_msgq_close() argument
35 struct nvkm_falcon *falcon = msgq->qmgr->falcon; in nvkm_falcon_msgq_close()
38 nvkm_falcon_wr32(falcon, msgq->tail_reg, msgq->position); in nvkm_falcon_msgq_close()
40 mutex_unlock(&msgq->mutex); in nvkm_falcon_msgq_close()
44 nvkm_falcon_msgq_empty(struct nvkm_falcon_msgq *msgq) in nvkm_falcon_msgq_empty() argument
46 u32 head = nvkm_falcon_rd32(msgq->qmgr->falcon, msgq->head_reg); in nvkm_falcon_msgq_empty()
47 u32 tail = nvkm_falcon_rd32(msgq->qmgr->falcon, msgq->tail_reg); in nvkm_falcon_msgq_empty()
52 nvkm_falcon_msgq_pop(struct nvkm_falcon_msgq *msgq, void *data, u32 size) in nvkm_falcon_msgq_pop() argument
54 struct nvkm_falcon *falcon = msgq->qmgr->falcon; in nvkm_falcon_msgq_pop()
57 head = nvkm_falcon_rd32(falcon, msgq->head_reg); in nvkm_falcon_msgq_pop()
59 if (head < msgq->position) in nvkm_falcon_msgq_pop()
60 msgq->position = msgq->offset; in nvkm_falcon_msgq_pop()
62 tail = msgq->position; in nvkm_falcon_msgq_pop()
66 FLCNQ_ERR(msgq, "requested %d bytes, but only %d available", in nvkm_falcon_msgq_pop()
72 msgq->position += ALIGN(size, QUEUE_ALIGNMENT); in nvkm_falcon_msgq_pop()
77 nvkm_falcon_msgq_read(struct nvkm_falcon_msgq *msgq, struct nvfw_falcon_msg *hdr) in nvkm_falcon_msgq_read() argument
81 nvkm_falcon_msgq_open(msgq); in nvkm_falcon_msgq_read()
83 if (nvkm_falcon_msgq_empty(msgq)) in nvkm_falcon_msgq_read()
86 ret = nvkm_falcon_msgq_pop(msgq, hdr, HDR_SIZE); in nvkm_falcon_msgq_read()
88 FLCNQ_ERR(msgq, "failed to read message header"); in nvkm_falcon_msgq_read()
93 FLCNQ_ERR(msgq, "message too big, %d bytes", hdr->size); in nvkm_falcon_msgq_read()
101 ret = nvkm_falcon_msgq_pop(msgq, (hdr + 1), read_size); in nvkm_falcon_msgq_read()
103 FLCNQ_ERR(msgq, "failed to read message data"); in nvkm_falcon_msgq_read()
110 nvkm_falcon_msgq_close(msgq, (ret >= 0)); in nvkm_falcon_msgq_read()
115 nvkm_falcon_msgq_exec(struct nvkm_falcon_msgq *msgq, struct nvfw_falcon_msg *hdr) in nvkm_falcon_msgq_exec() argument
119 seq = &msgq->qmgr->seq.id[hdr->seq_id]; in nvkm_falcon_msgq_exec()
121 FLCNQ_ERR(msgq, "message for unknown sequence %08x", seq->id); in nvkm_falcon_msgq_exec()
131 nvkm_falcon_qmgr_seq_release(msgq->qmgr, seq); in nvkm_falcon_msgq_exec()
140 nvkm_falcon_msgq_recv(struct nvkm_falcon_msgq *msgq) in nvkm_falcon_msgq_recv() argument
149 while (nvkm_falcon_msgq_read(msgq, hdr) > 0) in nvkm_falcon_msgq_recv()
150 nvkm_falcon_msgq_exec(msgq, hdr); in nvkm_falcon_msgq_recv()
154 nvkm_falcon_msgq_recv_initmsg(struct nvkm_falcon_msgq *msgq, in nvkm_falcon_msgq_recv_initmsg() argument
157 struct nvkm_falcon *falcon = msgq->qmgr->falcon; in nvkm_falcon_msgq_recv_initmsg()
161 msgq->head_reg = falcon->func->msgq.head; in nvkm_falcon_msgq_recv_initmsg()
162 msgq->tail_reg = falcon->func->msgq.tail; in nvkm_falcon_msgq_recv_initmsg()
163 msgq->offset = nvkm_falcon_rd32(falcon, falcon->func->msgq.tail); in nvkm_falcon_msgq_recv_initmsg()
165 nvkm_falcon_msgq_open(msgq); in nvkm_falcon_msgq_recv_initmsg()
166 ret = nvkm_falcon_msgq_pop(msgq, data, size); in nvkm_falcon_msgq_recv_initmsg()
172 nvkm_falcon_msgq_close(msgq, ret == 0); in nvkm_falcon_msgq_recv_initmsg()
177 nvkm_falcon_msgq_init(struct nvkm_falcon_msgq *msgq, in nvkm_falcon_msgq_init() argument
180 const struct nvkm_falcon_func *func = msgq->qmgr->falcon->func; in nvkm_falcon_msgq_init()
182 msgq->head_reg = func->msgq.head + index * func->msgq.stride; in nvkm_falcon_msgq_init()
183 msgq->tail_reg = func->msgq.tail + index * func->msgq.stride; in nvkm_falcon_msgq_init()
184 msgq->offset = offset; in nvkm_falcon_msgq_init()
186 FLCNQ_DBG(msgq, "initialised @ index %d offset 0x%08x size 0x%08x", in nvkm_falcon_msgq_init()
187 index, msgq->offset, size); in nvkm_falcon_msgq_init()
193 struct nvkm_falcon_msgq *msgq = *pmsgq; in nvkm_falcon_msgq_del() local
194 if (msgq) { in nvkm_falcon_msgq_del()
204 struct nvkm_falcon_msgq *msgq = *pmsgq; in nvkm_falcon_msgq_new() local
206 if (!(msgq = *pmsgq = kzalloc(sizeof(*msgq), GFP_KERNEL))) in nvkm_falcon_msgq_new()
209 msgq->qmgr = qmgr; in nvkm_falcon_msgq_new()
210 msgq->name = name; in nvkm_falcon_msgq_new()
211 mutex_init(&msgq->mutex); in nvkm_falcon_msgq_new()