Commit 2d063981 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/flcn/msgq: drop nvkm_msgqueue argument to functions

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 77b1ab61
...@@ -23,18 +23,16 @@ ...@@ -23,18 +23,16 @@
#include "qmgr.h" #include "qmgr.h"
static void static void
msg_queue_open(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue) msg_queue_open(struct nvkm_msgqueue_queue *queue)
{ {
struct nvkm_falcon *falcon = priv->falcon;
mutex_lock(&queue->mutex); mutex_lock(&queue->mutex);
queue->position = nvkm_falcon_rd32(falcon, queue->tail_reg); queue->position = nvkm_falcon_rd32(queue->qmgr->falcon, queue->tail_reg);
} }
static void static void
msg_queue_close(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue, msg_queue_close(struct nvkm_msgqueue_queue *queue, bool commit)
bool commit)
{ {
struct nvkm_falcon *falcon = priv->falcon; struct nvkm_falcon *falcon = queue->qmgr->falcon;
if (commit) if (commit)
nvkm_falcon_wr32(falcon, queue->tail_reg, queue->position); nvkm_falcon_wr32(falcon, queue->tail_reg, queue->position);
...@@ -43,19 +41,17 @@ msg_queue_close(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue, ...@@ -43,19 +41,17 @@ msg_queue_close(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue,
} }
static bool static bool
msg_queue_empty(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue) msg_queue_empty(struct nvkm_msgqueue_queue *queue)
{ {
struct nvkm_falcon *falcon = priv->falcon; u32 head = nvkm_falcon_rd32(queue->qmgr->falcon, queue->head_reg);
u32 head = nvkm_falcon_rd32(falcon, queue->head_reg); u32 tail = nvkm_falcon_rd32(queue->qmgr->falcon, queue->tail_reg);
u32 tail = nvkm_falcon_rd32(falcon, queue->tail_reg);
return head == tail; return head == tail;
} }
static int static int
msg_queue_pop(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue, msg_queue_pop(struct nvkm_msgqueue_queue *queue, void *data, u32 size)
void *data, u32 size)
{ {
struct nvkm_falcon *falcon = priv->falcon; struct nvkm_falcon *falcon = queue->qmgr->falcon;
u32 head, tail, available; u32 head, tail, available;
head = nvkm_falcon_rd32(falcon, queue->head_reg); head = nvkm_falcon_rd32(falcon, queue->head_reg);
...@@ -72,23 +68,22 @@ msg_queue_pop(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue, ...@@ -72,23 +68,22 @@ msg_queue_pop(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue,
return -EINVAL; return -EINVAL;
} }
nvkm_falcon_read_dmem(priv->falcon, tail, size, 0, data); nvkm_falcon_read_dmem(falcon, tail, size, 0, data);
queue->position += ALIGN(size, QUEUE_ALIGNMENT); queue->position += ALIGN(size, QUEUE_ALIGNMENT);
return 0; return 0;
} }
static int static int
msg_queue_read(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue, msg_queue_read(struct nvkm_msgqueue_queue *queue, struct nv_falcon_msg *hdr)
struct nv_falcon_msg *hdr)
{ {
int ret = 0; int ret = 0;
msg_queue_open(priv, queue); msg_queue_open(queue);
if (msg_queue_empty(priv, queue)) if (msg_queue_empty(queue))
goto close; goto close;
ret = msg_queue_pop(priv, queue, hdr, HDR_SIZE); ret = msg_queue_pop(queue, hdr, HDR_SIZE);
if (ret) { if (ret) {
FLCNQ_ERR(queue, "failed to read message header"); FLCNQ_ERR(queue, "failed to read message header");
goto close; goto close;
...@@ -103,7 +98,7 @@ msg_queue_read(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue, ...@@ -103,7 +98,7 @@ msg_queue_read(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue,
if (hdr->size > HDR_SIZE) { if (hdr->size > HDR_SIZE) {
u32 read_size = hdr->size - HDR_SIZE; u32 read_size = hdr->size - HDR_SIZE;
ret = msg_queue_pop(priv, queue, (hdr + 1), read_size); ret = msg_queue_pop(queue, (hdr + 1), read_size);
if (ret) { if (ret) {
FLCNQ_ERR(queue, "failed to read message data"); FLCNQ_ERR(queue, "failed to read message data");
goto close; goto close;
...@@ -112,14 +107,12 @@ msg_queue_read(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue, ...@@ -112,14 +107,12 @@ msg_queue_read(struct nvkm_msgqueue *priv, struct nvkm_msgqueue_queue *queue,
ret = 1; ret = 1;
close: close:
msg_queue_close(priv, queue, (ret >= 0)); msg_queue_close(queue, (ret >= 0));
return ret; return ret;
} }
static int static int
msgqueue_msg_handle(struct nvkm_msgqueue *priv, msgqueue_msg_handle(struct nvkm_falcon_msgq *msgq, struct nv_falcon_msg *hdr)
struct nvkm_falcon_msgq *msgq,
struct nv_falcon_msg *hdr)
{ {
struct nvkm_falcon_qmgr_seq *seq; struct nvkm_falcon_qmgr_seq *seq;
...@@ -197,8 +190,8 @@ nvkm_msgqueue_process_msgs(struct nvkm_msgqueue *priv, ...@@ -197,8 +190,8 @@ nvkm_msgqueue_process_msgs(struct nvkm_msgqueue *priv,
if (!ret) if (!ret)
priv->init_msg_received = true; priv->init_msg_received = true;
} else { } else {
while (msg_queue_read(priv, queue, hdr) > 0) while (msg_queue_read(queue, hdr) > 0)
msgqueue_msg_handle(priv, queue, hdr); msgqueue_msg_handle(queue, hdr);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment