2015-12-03 17:21:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Etnaviv Project
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ETNAVIV_GEM_H__
|
|
|
|
#define __ETNAVIV_GEM_H__
|
|
|
|
|
|
|
|
#include <linux/reservation.h>
|
2017-11-24 15:56:37 +00:00
|
|
|
#include "etnaviv_cmdbuf.h"
|
2015-12-03 17:21:29 +00:00
|
|
|
#include "etnaviv_drv.h"
|
|
|
|
|
2017-03-22 12:00:53 +00:00
|
|
|
struct dma_fence;
|
2015-12-03 17:21:29 +00:00
|
|
|
struct etnaviv_gem_ops;
|
|
|
|
struct etnaviv_gem_object;
|
|
|
|
|
|
|
|
struct etnaviv_gem_userptr {
|
|
|
|
uintptr_t ptr;
|
2017-11-17 13:16:10 +00:00
|
|
|
struct mm_struct *mm;
|
2015-12-03 17:21:29 +00:00
|
|
|
bool ro;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct etnaviv_vram_mapping {
|
|
|
|
struct list_head obj_node;
|
|
|
|
struct list_head scan_node;
|
|
|
|
struct list_head mmu_node;
|
|
|
|
struct etnaviv_gem_object *object;
|
|
|
|
struct etnaviv_iommu *mmu;
|
|
|
|
struct drm_mm_node vram_node;
|
|
|
|
unsigned int use;
|
|
|
|
u32 iova;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct etnaviv_gem_object {
|
|
|
|
struct drm_gem_object base;
|
|
|
|
const struct etnaviv_gem_ops *ops;
|
|
|
|
struct mutex lock;
|
|
|
|
|
|
|
|
u32 flags;
|
|
|
|
|
|
|
|
struct list_head gem_node;
|
|
|
|
struct etnaviv_gpu *gpu; /* non-null if active */
|
|
|
|
atomic_t gpu_active;
|
|
|
|
u32 access;
|
|
|
|
|
|
|
|
struct page **pages;
|
|
|
|
struct sg_table *sgt;
|
|
|
|
void *vaddr;
|
|
|
|
|
|
|
|
/* normally (resv == &_resv) except for imported bo's */
|
|
|
|
struct reservation_object *resv;
|
|
|
|
struct reservation_object _resv;
|
|
|
|
|
|
|
|
struct list_head vram_list;
|
|
|
|
|
|
|
|
/* cache maintenance */
|
|
|
|
u32 last_cpu_prep_op;
|
|
|
|
|
|
|
|
struct etnaviv_gem_userptr userptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline
|
|
|
|
struct etnaviv_gem_object *to_etnaviv_bo(struct drm_gem_object *obj)
|
|
|
|
{
|
|
|
|
return container_of(obj, struct etnaviv_gem_object, base);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct etnaviv_gem_ops {
|
|
|
|
int (*get_pages)(struct etnaviv_gem_object *);
|
|
|
|
void (*release)(struct etnaviv_gem_object *);
|
2016-01-25 14:47:28 +00:00
|
|
|
void *(*vmap)(struct etnaviv_gem_object *);
|
2016-04-27 10:27:02 +00:00
|
|
|
int (*mmap)(struct etnaviv_gem_object *, struct vm_area_struct *);
|
2015-12-03 17:21:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj)
|
|
|
|
{
|
|
|
|
return atomic_read(&etnaviv_obj->gpu_active) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_CMDS 4
|
|
|
|
|
2016-01-21 15:20:55 +00:00
|
|
|
struct etnaviv_gem_submit_bo {
|
|
|
|
u32 flags;
|
|
|
|
struct etnaviv_gem_object *obj;
|
|
|
|
struct etnaviv_vram_mapping *mapping;
|
2017-12-04 18:24:06 +00:00
|
|
|
struct dma_fence *excl;
|
|
|
|
unsigned int nr_shared;
|
|
|
|
struct dma_fence **shared;
|
2016-01-21 15:20:55 +00:00
|
|
|
};
|
|
|
|
|
2015-12-03 17:21:29 +00:00
|
|
|
/* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,
|
|
|
|
* associated with the cmdstream submission for synchronization (and
|
2017-11-24 11:02:38 +00:00
|
|
|
* make it easier to unwind when things go wrong, etc).
|
2015-12-03 17:21:29 +00:00
|
|
|
*/
|
|
|
|
struct etnaviv_gem_submit {
|
2017-12-04 17:41:58 +00:00
|
|
|
struct drm_sched_job sched_job;
|
2017-11-24 10:36:03 +00:00
|
|
|
struct kref refcount;
|
2015-12-03 17:21:29 +00:00
|
|
|
struct etnaviv_gpu *gpu;
|
2017-11-23 17:02:43 +00:00
|
|
|
struct dma_fence *out_fence, *in_fence;
|
2017-11-29 13:49:04 +00:00
|
|
|
int out_fence_id;
|
2017-11-24 15:56:37 +00:00
|
|
|
struct list_head node; /* GPU active submit list */
|
|
|
|
struct etnaviv_cmdbuf cmdbuf;
|
2017-11-24 16:56:29 +00:00
|
|
|
bool runtime_resumed;
|
2017-11-24 14:16:58 +00:00
|
|
|
u32 exec_state;
|
2017-06-27 14:02:51 +00:00
|
|
|
u32 flags;
|
2017-11-24 11:02:38 +00:00
|
|
|
unsigned int nr_pmrs;
|
|
|
|
struct etnaviv_perfmon_request *pmrs;
|
2015-12-03 17:21:29 +00:00
|
|
|
unsigned int nr_bos;
|
2016-01-21 15:20:55 +00:00
|
|
|
struct etnaviv_gem_submit_bo bos[0];
|
2017-06-27 14:02:51 +00:00
|
|
|
/* No new members here, the previous one is variable-length! */
|
2015-12-03 17:21:29 +00:00
|
|
|
};
|
|
|
|
|
2017-11-24 10:36:03 +00:00
|
|
|
void etnaviv_submit_put(struct etnaviv_gem_submit * submit);
|
|
|
|
|
2015-12-03 17:21:29 +00:00
|
|
|
int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
|
|
|
|
struct timespec *timeout);
|
|
|
|
int etnaviv_gem_new_private(struct drm_device *dev, size_t size, u32 flags,
|
|
|
|
struct reservation_object *robj, const struct etnaviv_gem_ops *ops,
|
|
|
|
struct etnaviv_gem_object **res);
|
2017-11-17 11:17:14 +00:00
|
|
|
void etnaviv_gem_obj_add(struct drm_device *dev, struct drm_gem_object *obj);
|
2015-12-03 17:21:29 +00:00
|
|
|
struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *obj);
|
|
|
|
void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj);
|
|
|
|
|
2016-01-21 15:20:50 +00:00
|
|
|
struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
|
|
|
|
struct drm_gem_object *obj, struct etnaviv_gpu *gpu);
|
|
|
|
void etnaviv_gem_mapping_reference(struct etnaviv_vram_mapping *mapping);
|
|
|
|
void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping);
|
|
|
|
|
2015-12-03 17:21:29 +00:00
|
|
|
#endif /* __ETNAVIV_GEM_H__ */
|