blob: 3749764a238e27cc16f8608aef9d243d6287bec1 [file] [log] [blame]
Rob Clark7198e6b2013-07-19 12:59:32 -04001/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __MSM_RINGBUFFER_H__
19#define __MSM_RINGBUFFER_H__
20
21#include "msm_drv.h"
22
Jordan Crousef97deca2017-10-20 11:06:57 -060023#define rbmemptr(ring, member) \
24 ((ring)->memptrs_iova + offsetof(struct msm_rbmemptrs, member))
25
26struct msm_rbmemptrs {
27 volatile uint32_t rptr;
28 volatile uint32_t fence;
Rob Clark7198e6b2013-07-19 12:59:32 -040029};
30
Jordan Crousef97deca2017-10-20 11:06:57 -060031struct msm_ringbuffer {
32 struct msm_gpu *gpu;
33 int id;
34 struct drm_gem_object *bo;
Jordan Crouse4c7085a2017-10-20 11:06:59 -060035 uint32_t *start, *end, *cur, *next;
Jordan Crousef97deca2017-10-20 11:06:57 -060036 struct list_head submits;
37 uint64_t iova;
38 uint32_t seqno;
39 uint32_t hangcheck_fence;
40 struct msm_rbmemptrs *memptrs;
41 uint64_t memptrs_iova;
42 struct msm_fence_context *fctx;
43};
44
45struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id,
46 void *memptrs, uint64_t memptrs_iova);
Rob Clark7198e6b2013-07-19 12:59:32 -040047void msm_ringbuffer_destroy(struct msm_ringbuffer *ring);
48
49/* ringbuffer helpers (the parts that are same for a3xx/a2xx/z180..) */
50
51static inline void
52OUT_RING(struct msm_ringbuffer *ring, uint32_t data)
53{
Jordan Crouse4c7085a2017-10-20 11:06:59 -060054 /*
55 * ring->next points to the current command being written - it won't be
56 * committed as ring->cur until the flush
57 */
58 if (ring->next == ring->end)
59 ring->next = ring->start;
60 *(ring->next++) = data;
Rob Clark7198e6b2013-07-19 12:59:32 -040061}
62
63#endif /* __MSM_RINGBUFFER_H__ */