| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2013 Red Hat |
|---|
| 3 | 4 | * 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 | 5 | */ |
|---|
| 17 | 6 | |
|---|
| 18 | 7 | #ifndef __MSM_RINGBUFFER_H__ |
|---|
| .. | .. |
|---|
| 23 | 12 | #define rbmemptr(ring, member) \ |
|---|
| 24 | 13 | ((ring)->memptrs_iova + offsetof(struct msm_rbmemptrs, member)) |
|---|
| 25 | 14 | |
|---|
| 15 | +#define rbmemptr_stats(ring, index, member) \ |
|---|
| 16 | + (rbmemptr((ring), stats) + \ |
|---|
| 17 | + ((index) * sizeof(struct msm_gpu_submit_stats)) + \ |
|---|
| 18 | + offsetof(struct msm_gpu_submit_stats, member)) |
|---|
| 19 | + |
|---|
| 20 | +struct msm_gpu_submit_stats { |
|---|
| 21 | + u64 cpcycles_start; |
|---|
| 22 | + u64 cpcycles_end; |
|---|
| 23 | + u64 alwayson_start; |
|---|
| 24 | + u64 alwayson_end; |
|---|
| 25 | +}; |
|---|
| 26 | + |
|---|
| 27 | +#define MSM_GPU_SUBMIT_STATS_COUNT 64 |
|---|
| 28 | + |
|---|
| 26 | 29 | struct msm_rbmemptrs { |
|---|
| 27 | 30 | volatile uint32_t rptr; |
|---|
| 28 | 31 | volatile uint32_t fence; |
|---|
| 32 | + |
|---|
| 33 | + volatile struct msm_gpu_submit_stats stats[MSM_GPU_SUBMIT_STATS_COUNT]; |
|---|
| 34 | + volatile u64 ttbr0; |
|---|
| 29 | 35 | }; |
|---|
| 30 | 36 | |
|---|
| 31 | 37 | struct msm_ringbuffer { |
|---|
| .. | .. |
|---|
| 40 | 46 | struct msm_rbmemptrs *memptrs; |
|---|
| 41 | 47 | uint64_t memptrs_iova; |
|---|
| 42 | 48 | struct msm_fence_context *fctx; |
|---|
| 43 | | - spinlock_t lock; |
|---|
| 49 | + |
|---|
| 50 | + /* |
|---|
| 51 | + * preempt_lock protects preemption and serializes wptr updates against |
|---|
| 52 | + * preemption. Can be aquired from irq context. |
|---|
| 53 | + */ |
|---|
| 54 | + spinlock_t preempt_lock; |
|---|
| 44 | 55 | }; |
|---|
| 45 | 56 | |
|---|
| 46 | 57 | struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id, |
|---|