2019-09-14 08:58:55 +01:00
|
|
|
/*
|
|
|
|
* © Copyright 2019 Alyssa Rosenzweig
|
|
|
|
* © Copyright 2019 Collabora, Ltd.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PAN_BO_H__
|
|
|
|
#define __PAN_BO_H__
|
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
#include <time.h>
|
2019-09-14 08:58:55 +01:00
|
|
|
#include "util/list.h"
|
2021-04-06 10:36:34 +01:00
|
|
|
#include "panfrost-job.h"
|
2019-09-14 08:58:55 +01:00
|
|
|
|
|
|
|
/* Flags for allocated memory */
|
|
|
|
|
|
|
|
/* This memory region is executable */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_EXECUTE (1 << 0)
|
2019-09-14 08:58:55 +01:00
|
|
|
|
|
|
|
/* This memory region should be lazily allocated and grow-on-page-fault. Must
|
|
|
|
* be used in conjunction with INVISIBLE */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_GROWABLE (1 << 1)
|
2019-09-14 08:58:55 +01:00
|
|
|
|
|
|
|
/* This memory region should not be mapped to the CPU */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_INVISIBLE (1 << 2)
|
2019-09-14 08:58:55 +01:00
|
|
|
|
|
|
|
/* This region may not be used immediately and will not mmap on allocate
|
|
|
|
* (semantically distinct from INVISIBLE, which cannot never be mmaped) */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_DELAY_MMAP (1 << 3)
|
2019-09-14 10:46:44 +01:00
|
|
|
|
2020-05-26 18:10:41 +01:00
|
|
|
/* BO is shared across processes (imported or exported) and therefore cannot be
|
|
|
|
* cached locally */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_SHARED (1 << 4)
|
2019-09-14 16:11:03 +01:00
|
|
|
|
2019-09-15 08:21:13 +01:00
|
|
|
/* GPU access flags */
|
|
|
|
|
|
|
|
/* BO is either shared (can be accessed by more than one GPU batch) or private
|
|
|
|
* (reserved by a specific GPU job). */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_ACCESS_PRIVATE (0 << 0)
|
|
|
|
#define PAN_BO_ACCESS_SHARED (1 << 0)
|
2019-09-15 08:21:13 +01:00
|
|
|
|
|
|
|
/* BO is being read/written by the GPU */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_ACCESS_READ (1 << 1)
|
|
|
|
#define PAN_BO_ACCESS_WRITE (1 << 2)
|
|
|
|
#define PAN_BO_ACCESS_RW (PAN_BO_ACCESS_READ | PAN_BO_ACCESS_WRITE)
|
2019-09-15 08:21:13 +01:00
|
|
|
|
|
|
|
/* BO is accessed by the vertex/tiler job. */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_ACCESS_VERTEX_TILER (1 << 3)
|
2019-09-15 08:21:13 +01:00
|
|
|
|
|
|
|
/* BO is accessed by the fragment job. */
|
2022-12-23 21:58:38 +00:00
|
|
|
#define PAN_BO_ACCESS_FRAGMENT (1 << 4)
|
2019-09-15 08:21:13 +01:00
|
|
|
|
2022-06-10 12:41:48 +01:00
|
|
|
typedef uint8_t pan_bo_access;
|
|
|
|
|
2021-04-06 10:36:34 +01:00
|
|
|
struct panfrost_device;
|
|
|
|
|
2020-10-18 09:13:18 +01:00
|
|
|
struct panfrost_ptr {
|
2022-12-23 21:58:38 +00:00
|
|
|
/* CPU address */
|
|
|
|
void *cpu;
|
2020-10-18 09:13:18 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* GPU address */
|
|
|
|
mali_ptr gpu;
|
2020-10-18 09:13:18 +01:00
|
|
|
};
|
|
|
|
|
2019-09-14 08:58:55 +01:00
|
|
|
struct panfrost_bo {
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Must be first for casting */
|
|
|
|
struct list_head bucket_link;
|
2019-11-07 08:32:31 +00:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Used to link the BO to the BO cache LRU list. */
|
|
|
|
struct list_head lru_link;
|
2019-11-07 08:32:31 +00:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Store the time this BO was use last, so the BO cache logic can evict
|
|
|
|
* stale BOs.
|
|
|
|
*/
|
|
|
|
time_t last_used;
|
2019-09-14 08:58:55 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Atomic reference count */
|
|
|
|
int32_t refcnt;
|
2019-09-14 08:58:55 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
struct panfrost_device *dev;
|
2019-09-14 09:35:47 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Mapping for the entire object (all levels) */
|
|
|
|
struct panfrost_ptr ptr;
|
2019-09-14 08:58:55 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Size of all entire trees */
|
|
|
|
size_t size;
|
2019-09-14 08:58:55 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
int gem_handle;
|
2019-09-14 08:58:55 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
uint32_t flags;
|
2019-08-31 17:51:20 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Combination of PAN_BO_ACCESS_{READ,WRITE} flags encoding pending
|
|
|
|
* GPU accesses to this BO. Useful to avoid calling the WAIT_BO ioctl
|
|
|
|
* when the BO is idle.
|
|
|
|
*/
|
|
|
|
uint32_t gpu_access;
|
2021-05-12 22:46:10 +01:00
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
/* Human readable description of the BO for debugging. */
|
|
|
|
const char *label;
|
2019-09-14 08:58:55 +01:00
|
|
|
};
|
|
|
|
|
2022-12-23 21:58:38 +00:00
|
|
|
bool panfrost_bo_wait(struct panfrost_bo *bo, int64_t timeout_ns,
|
|
|
|
bool wait_readers);
|
|
|
|
void panfrost_bo_reference(struct panfrost_bo *bo);
|
|
|
|
void panfrost_bo_unreference(struct panfrost_bo *bo);
|
|
|
|
struct panfrost_bo *panfrost_bo_create(struct panfrost_device *dev, size_t size,
|
|
|
|
uint32_t flags, const char *label);
|
|
|
|
void panfrost_bo_mmap(struct panfrost_bo *bo);
|
|
|
|
struct panfrost_bo *panfrost_bo_import(struct panfrost_device *dev, int fd);
|
|
|
|
int panfrost_bo_export(struct panfrost_bo *bo);
|
|
|
|
void panfrost_bo_cache_evict_all(struct panfrost_device *dev);
|
2019-09-14 08:58:55 +01:00
|
|
|
|
|
|
|
#endif /* __PAN_BO_H__ */
|