| .. | .. |
|---|
| 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 | #include "msm_ringbuffer.h" |
|---|
| .. | .. |
|---|
| 36 | 25 | |
|---|
| 37 | 26 | ring->gpu = gpu; |
|---|
| 38 | 27 | ring->id = id; |
|---|
| 39 | | - /* Pass NULL for the iova pointer - we will map it later */ |
|---|
| 28 | + |
|---|
| 40 | 29 | ring->start = msm_gem_kernel_new(gpu->dev, MSM_GPU_RINGBUFFER_SZ, |
|---|
| 41 | | - MSM_BO_WC, gpu->aspace, &ring->bo, NULL); |
|---|
| 30 | + check_apriv(gpu, MSM_BO_WC | MSM_BO_GPU_READONLY), |
|---|
| 31 | + gpu->aspace, &ring->bo, &ring->iova); |
|---|
| 42 | 32 | |
|---|
| 43 | 33 | if (IS_ERR(ring->start)) { |
|---|
| 44 | 34 | ret = PTR_ERR(ring->start); |
|---|
| 45 | 35 | ring->start = 0; |
|---|
| 46 | 36 | goto fail; |
|---|
| 47 | 37 | } |
|---|
| 38 | + |
|---|
| 39 | + msm_gem_object_set_name(ring->bo, "ring%d", id); |
|---|
| 40 | + |
|---|
| 48 | 41 | ring->end = ring->start + (MSM_GPU_RINGBUFFER_SZ >> 2); |
|---|
| 49 | 42 | ring->next = ring->start; |
|---|
| 50 | 43 | ring->cur = ring->start; |
|---|
| .. | .. |
|---|
| 53 | 46 | ring->memptrs_iova = memptrs_iova; |
|---|
| 54 | 47 | |
|---|
| 55 | 48 | INIT_LIST_HEAD(&ring->submits); |
|---|
| 56 | | - spin_lock_init(&ring->lock); |
|---|
| 49 | + spin_lock_init(&ring->preempt_lock); |
|---|
| 57 | 50 | |
|---|
| 58 | 51 | snprintf(name, sizeof(name), "gpu-ring-%d", ring->id); |
|---|
| 59 | 52 | |
|---|
| .. | .. |
|---|
| 73 | 66 | |
|---|
| 74 | 67 | msm_fence_context_free(ring->fctx); |
|---|
| 75 | 68 | |
|---|
| 76 | | - if (ring->bo) { |
|---|
| 77 | | - msm_gem_put_iova(ring->bo, ring->gpu->aspace); |
|---|
| 78 | | - msm_gem_put_vaddr(ring->bo); |
|---|
| 79 | | - drm_gem_object_put_unlocked(ring->bo); |
|---|
| 80 | | - } |
|---|
| 69 | + msm_gem_kernel_put(ring->bo, ring->gpu->aspace, false); |
|---|
| 70 | + |
|---|
| 81 | 71 | kfree(ring); |
|---|
| 82 | 72 | } |
|---|