2019-05-19 21:51:31 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2013-03-22 22:34:03 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2009-2013, NVIDIA Corporation. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_HOST1X_H
|
|
|
|
#define __LINUX_HOST1X_H
|
|
|
|
|
2013-10-14 20:43:22 +08:00
|
|
|
#include <linux/device.h>
|
2021-09-09 21:51:24 +08:00
|
|
|
#include <linux/dma-direction.h>
|
2020-02-07 23:50:52 +08:00
|
|
|
#include <linux/spinlock.h>
|
2013-09-24 22:30:32 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2013-03-22 22:34:03 +08:00
|
|
|
enum host1x_class {
|
2013-09-24 19:59:01 +08:00
|
|
|
HOST1X_CLASS_HOST1X = 0x1,
|
|
|
|
HOST1X_CLASS_GR2D = 0x51,
|
|
|
|
HOST1X_CLASS_GR2D_SB = 0x52,
|
2016-12-14 19:16:13 +08:00
|
|
|
HOST1X_CLASS_VIC = 0x5D,
|
2013-02-28 15:08:01 +08:00
|
|
|
HOST1X_CLASS_GR3D = 0x60,
|
2021-09-16 22:55:17 +08:00
|
|
|
HOST1X_CLASS_NVDEC = 0xF0,
|
|
|
|
HOST1X_CLASS_NVDEC1 = 0xF5,
|
2013-03-22 22:34:03 +08:00
|
|
|
};
|
|
|
|
|
2020-03-26 04:16:03 +08:00
|
|
|
struct host1x;
|
2013-09-24 21:35:40 +08:00
|
|
|
struct host1x_client;
|
2019-02-08 21:35:13 +08:00
|
|
|
struct iommu_group;
|
2013-09-24 21:35:40 +08:00
|
|
|
|
2020-03-26 04:16:03 +08:00
|
|
|
u64 host1x_get_dma_mask(struct host1x *host1x);
|
|
|
|
|
2020-02-07 23:50:52 +08:00
|
|
|
/**
|
|
|
|
* struct host1x_bo_cache - host1x buffer object cache
|
|
|
|
* @mappings: list of mappings
|
|
|
|
* @lock: synchronizes accesses to the list of mappings
|
2022-03-24 18:30:25 +08:00
|
|
|
*
|
|
|
|
* Note that entries are not periodically evicted from this cache and instead need to be
|
|
|
|
* explicitly released. This is used primarily for DRM/KMS where the cache's reference is
|
|
|
|
* released when the last reference to a buffer object represented by a mapping in this
|
|
|
|
* cache is dropped.
|
2020-02-07 23:50:52 +08:00
|
|
|
*/
|
|
|
|
struct host1x_bo_cache {
|
|
|
|
struct list_head mappings;
|
|
|
|
struct mutex lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void host1x_bo_cache_init(struct host1x_bo_cache *cache)
|
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&cache->mappings);
|
|
|
|
mutex_init(&cache->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void host1x_bo_cache_destroy(struct host1x_bo_cache *cache)
|
|
|
|
{
|
|
|
|
/* XXX warn if not empty? */
|
|
|
|
mutex_destroy(&cache->lock);
|
|
|
|
}
|
|
|
|
|
2017-04-10 18:27:01 +08:00
|
|
|
/**
|
|
|
|
* struct host1x_client_ops - host1x client operations
|
2021-03-26 22:51:37 +08:00
|
|
|
* @early_init: host1x client early initialization code
|
2017-04-10 18:27:01 +08:00
|
|
|
* @init: host1x client initialization code
|
|
|
|
* @exit: host1x client tear down code
|
2021-03-26 22:51:37 +08:00
|
|
|
* @late_exit: host1x client late tear down code
|
2019-12-02 22:29:03 +08:00
|
|
|
* @suspend: host1x client suspend code
|
|
|
|
* @resume: host1x client resume code
|
2017-04-10 18:27:01 +08:00
|
|
|
*/
|
2013-09-24 21:35:40 +08:00
|
|
|
struct host1x_client_ops {
|
2021-03-26 22:51:37 +08:00
|
|
|
int (*early_init)(struct host1x_client *client);
|
2013-09-24 21:35:40 +08:00
|
|
|
int (*init)(struct host1x_client *client);
|
|
|
|
int (*exit)(struct host1x_client *client);
|
2021-03-26 22:51:37 +08:00
|
|
|
int (*late_exit)(struct host1x_client *client);
|
2019-12-02 22:29:03 +08:00
|
|
|
int (*suspend)(struct host1x_client *client);
|
|
|
|
int (*resume)(struct host1x_client *client);
|
2013-09-24 21:35:40 +08:00
|
|
|
};
|
|
|
|
|
2017-04-10 18:27:01 +08:00
|
|
|
/**
|
|
|
|
* struct host1x_client - host1x client structure
|
|
|
|
* @list: list node for the host1x client
|
2019-12-02 17:51:58 +08:00
|
|
|
* @host: pointer to struct device representing the host1x controller
|
2017-04-10 18:27:01 +08:00
|
|
|
* @dev: pointer to struct device backing this host1x client
|
2019-02-08 21:35:13 +08:00
|
|
|
* @group: IOMMU group that this client is a member of
|
2017-04-10 18:27:01 +08:00
|
|
|
* @ops: host1x client operations
|
|
|
|
* @class: host1x class represented by this client
|
|
|
|
* @channel: host1x channel associated with this client
|
|
|
|
* @syncpts: array of syncpoints requested for this client
|
|
|
|
* @num_syncpts: number of syncpoints requested for this client
|
2020-06-14 12:08:04 +08:00
|
|
|
* @parent: pointer to parent structure
|
|
|
|
* @usecount: reference count for this structure
|
|
|
|
* @lock: mutex for mutually exclusive concurrency
|
2022-04-04 06:53:54 +08:00
|
|
|
* @cache: host1x buffer object cache
|
2017-04-10 18:27:01 +08:00
|
|
|
*/
|
2013-09-24 21:35:40 +08:00
|
|
|
struct host1x_client {
|
|
|
|
struct list_head list;
|
2019-12-02 17:51:58 +08:00
|
|
|
struct device *host;
|
2013-09-24 21:35:40 +08:00
|
|
|
struct device *dev;
|
2019-02-08 21:35:13 +08:00
|
|
|
struct iommu_group *group;
|
2013-09-24 21:35:40 +08:00
|
|
|
|
|
|
|
const struct host1x_client_ops *ops;
|
|
|
|
|
|
|
|
enum host1x_class class;
|
|
|
|
struct host1x_channel *channel;
|
|
|
|
|
|
|
|
struct host1x_syncpt **syncpts;
|
|
|
|
unsigned int num_syncpts;
|
2019-12-02 22:29:03 +08:00
|
|
|
|
|
|
|
struct host1x_client *parent;
|
|
|
|
unsigned int usecount;
|
|
|
|
struct mutex lock;
|
2020-02-07 23:50:52 +08:00
|
|
|
|
|
|
|
struct host1x_bo_cache cache;
|
2013-09-24 21:35:40 +08:00
|
|
|
};
|
|
|
|
|
2013-09-24 22:30:32 +08:00
|
|
|
/*
|
|
|
|
* host1x buffer objects
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct host1x_bo;
|
|
|
|
struct sg_table;
|
|
|
|
|
2021-09-09 21:51:24 +08:00
|
|
|
struct host1x_bo_mapping {
|
2020-02-07 23:50:52 +08:00
|
|
|
struct kref ref;
|
2021-09-09 21:51:24 +08:00
|
|
|
struct dma_buf_attachment *attach;
|
|
|
|
enum dma_data_direction direction;
|
2020-02-07 23:50:52 +08:00
|
|
|
struct list_head list;
|
2021-09-09 21:51:24 +08:00
|
|
|
struct host1x_bo *bo;
|
|
|
|
struct sg_table *sgt;
|
|
|
|
unsigned int chunks;
|
|
|
|
struct device *dev;
|
|
|
|
dma_addr_t phys;
|
|
|
|
size_t size;
|
2020-02-07 23:50:52 +08:00
|
|
|
|
|
|
|
struct host1x_bo_cache *cache;
|
|
|
|
struct list_head entry;
|
2021-09-09 21:51:24 +08:00
|
|
|
};
|
|
|
|
|
2020-02-07 23:50:52 +08:00
|
|
|
static inline struct host1x_bo_mapping *to_host1x_bo_mapping(struct kref *ref)
|
|
|
|
{
|
|
|
|
return container_of(ref, struct host1x_bo_mapping, ref);
|
|
|
|
}
|
|
|
|
|
2013-09-24 22:30:32 +08:00
|
|
|
struct host1x_bo_ops {
|
|
|
|
struct host1x_bo *(*get)(struct host1x_bo *bo);
|
|
|
|
void (*put)(struct host1x_bo *bo);
|
2021-09-09 21:51:24 +08:00
|
|
|
struct host1x_bo_mapping *(*pin)(struct device *dev, struct host1x_bo *bo,
|
|
|
|
enum dma_data_direction dir);
|
|
|
|
void (*unpin)(struct host1x_bo_mapping *map);
|
2013-09-24 22:30:32 +08:00
|
|
|
void *(*mmap)(struct host1x_bo *bo);
|
|
|
|
void (*munmap)(struct host1x_bo *bo, void *addr);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct host1x_bo {
|
|
|
|
const struct host1x_bo_ops *ops;
|
2020-02-07 23:50:52 +08:00
|
|
|
struct list_head mappings;
|
|
|
|
spinlock_t lock;
|
2013-09-24 22:30:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void host1x_bo_init(struct host1x_bo *bo,
|
|
|
|
const struct host1x_bo_ops *ops)
|
|
|
|
{
|
2020-02-07 23:50:52 +08:00
|
|
|
INIT_LIST_HEAD(&bo->mappings);
|
|
|
|
spin_lock_init(&bo->lock);
|
2013-09-24 22:30:32 +08:00
|
|
|
bo->ops = ops;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct host1x_bo *host1x_bo_get(struct host1x_bo *bo)
|
|
|
|
{
|
|
|
|
return bo->ops->get(bo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void host1x_bo_put(struct host1x_bo *bo)
|
|
|
|
{
|
|
|
|
bo->ops->put(bo);
|
|
|
|
}
|
|
|
|
|
2020-02-07 23:50:52 +08:00
|
|
|
struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo,
|
|
|
|
enum dma_data_direction dir,
|
|
|
|
struct host1x_bo_cache *cache);
|
|
|
|
void host1x_bo_unpin(struct host1x_bo_mapping *map);
|
2013-09-24 22:30:32 +08:00
|
|
|
|
|
|
|
static inline void *host1x_bo_mmap(struct host1x_bo *bo)
|
|
|
|
{
|
|
|
|
return bo->ops->mmap(bo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void host1x_bo_munmap(struct host1x_bo *bo, void *addr)
|
|
|
|
{
|
|
|
|
bo->ops->munmap(bo, addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* host1x syncpoints
|
|
|
|
*/
|
|
|
|
|
2013-10-14 20:21:52 +08:00
|
|
|
#define HOST1X_SYNCPT_CLIENT_MANAGED (1 << 0)
|
2013-10-14 20:21:53 +08:00
|
|
|
#define HOST1X_SYNCPT_HAS_BASE (1 << 1)
|
2013-10-14 20:21:52 +08:00
|
|
|
|
2013-10-14 20:21:53 +08:00
|
|
|
struct host1x_syncpt_base;
|
2013-09-24 22:30:32 +08:00
|
|
|
struct host1x_syncpt;
|
|
|
|
struct host1x;
|
|
|
|
|
2021-03-29 21:38:32 +08:00
|
|
|
struct host1x_syncpt *host1x_syncpt_get_by_id(struct host1x *host, u32 id);
|
|
|
|
struct host1x_syncpt *host1x_syncpt_get_by_id_noref(struct host1x *host, u32 id);
|
|
|
|
struct host1x_syncpt *host1x_syncpt_get(struct host1x_syncpt *sp);
|
2013-09-24 22:30:32 +08:00
|
|
|
u32 host1x_syncpt_id(struct host1x_syncpt *sp);
|
|
|
|
u32 host1x_syncpt_read_min(struct host1x_syncpt *sp);
|
|
|
|
u32 host1x_syncpt_read_max(struct host1x_syncpt *sp);
|
2015-01-28 21:29:02 +08:00
|
|
|
u32 host1x_syncpt_read(struct host1x_syncpt *sp);
|
2013-09-24 22:30:32 +08:00
|
|
|
int host1x_syncpt_incr(struct host1x_syncpt *sp);
|
2014-02-20 06:48:36 +08:00
|
|
|
u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
|
2013-09-24 22:30:32 +08:00
|
|
|
int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
|
|
|
|
u32 *value);
|
2017-08-30 18:48:31 +08:00
|
|
|
struct host1x_syncpt *host1x_syncpt_request(struct host1x_client *client,
|
2013-10-14 20:21:52 +08:00
|
|
|
unsigned long flags);
|
2021-03-29 21:38:32 +08:00
|
|
|
void host1x_syncpt_put(struct host1x_syncpt *sp);
|
2021-03-29 21:38:28 +08:00
|
|
|
struct host1x_syncpt *host1x_syncpt_alloc(struct host1x *host,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *name);
|
2013-09-24 22:30:32 +08:00
|
|
|
|
2013-10-14 20:21:53 +08:00
|
|
|
struct host1x_syncpt_base *host1x_syncpt_get_base(struct host1x_syncpt *sp);
|
|
|
|
u32 host1x_syncpt_base_id(struct host1x_syncpt_base *base);
|
|
|
|
|
2021-03-29 21:38:34 +08:00
|
|
|
void host1x_syncpt_release_vblank_reservation(struct host1x_client *client,
|
|
|
|
u32 syncpt_id);
|
|
|
|
|
2021-06-10 19:04:42 +08:00
|
|
|
struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold);
|
|
|
|
|
2013-09-24 22:30:32 +08:00
|
|
|
/*
|
|
|
|
* host1x channel
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct host1x_channel;
|
|
|
|
struct host1x_job;
|
|
|
|
|
2018-06-18 20:01:51 +08:00
|
|
|
struct host1x_channel *host1x_channel_request(struct host1x_client *client);
|
2013-09-24 22:30:32 +08:00
|
|
|
struct host1x_channel *host1x_channel_get(struct host1x_channel *channel);
|
2021-12-01 07:23:16 +08:00
|
|
|
void host1x_channel_stop(struct host1x_channel *channel);
|
2013-09-24 22:30:32 +08:00
|
|
|
void host1x_channel_put(struct host1x_channel *channel);
|
|
|
|
int host1x_job_submit(struct host1x_job *job);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* host1x job
|
|
|
|
*/
|
|
|
|
|
2019-10-28 20:37:11 +08:00
|
|
|
#define HOST1X_RELOC_READ (1 << 0)
|
|
|
|
#define HOST1X_RELOC_WRITE (1 << 1)
|
|
|
|
|
2013-09-24 22:30:32 +08:00
|
|
|
struct host1x_reloc {
|
2014-06-10 16:25:00 +08:00
|
|
|
struct {
|
|
|
|
struct host1x_bo *bo;
|
|
|
|
unsigned long offset;
|
|
|
|
} cmdbuf;
|
|
|
|
struct {
|
|
|
|
struct host1x_bo *bo;
|
|
|
|
unsigned long offset;
|
|
|
|
} target;
|
|
|
|
unsigned long shift;
|
2019-10-28 20:37:11 +08:00
|
|
|
unsigned long flags;
|
2013-09-24 22:30:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct host1x_job {
|
|
|
|
/* When refcount goes to zero, job can be freed */
|
|
|
|
struct kref ref;
|
|
|
|
|
|
|
|
/* List entry */
|
|
|
|
struct list_head list;
|
|
|
|
|
|
|
|
/* Channel where job is submitted to */
|
|
|
|
struct host1x_channel *channel;
|
|
|
|
|
2018-05-16 20:12:33 +08:00
|
|
|
/* client where the job originated */
|
|
|
|
struct host1x_client *client;
|
2013-09-24 22:30:32 +08:00
|
|
|
|
|
|
|
/* Gathers and their memory */
|
2021-06-10 19:04:45 +08:00
|
|
|
struct host1x_job_cmd *cmds;
|
|
|
|
unsigned int num_cmds;
|
2013-09-24 22:30:32 +08:00
|
|
|
|
|
|
|
/* Array of handles to be pinned & unpinned */
|
2018-05-16 22:58:44 +08:00
|
|
|
struct host1x_reloc *relocs;
|
2013-09-24 22:30:32 +08:00
|
|
|
unsigned int num_relocs;
|
|
|
|
struct host1x_job_unpin_data *unpins;
|
|
|
|
unsigned int num_unpins;
|
|
|
|
|
|
|
|
dma_addr_t *addr_phys;
|
|
|
|
dma_addr_t *gather_addr_phys;
|
|
|
|
dma_addr_t *reloc_addr_phys;
|
|
|
|
|
|
|
|
/* Sync point id, number of increments and end related to the submit */
|
2021-03-29 21:38:32 +08:00
|
|
|
struct host1x_syncpt *syncpt;
|
2013-09-24 22:30:32 +08:00
|
|
|
u32 syncpt_incrs;
|
|
|
|
u32 syncpt_end;
|
|
|
|
|
gpu: host1x: Add no-recovery mode
Add a new property for jobs to enable or disable recovery i.e.
CPU increments of syncpoints to max value on job timeout. This
allows for a more solid model for hanged jobs, where userspace
doesn't need to guess if a syncpoint increment happened because
the job completed, or because job timeout was triggered.
On job timeout, we stop the channel, NOP all future jobs on the
channel using the same syncpoint, mark the syncpoint as locked
and resume the channel from the next job, if any.
The future jobs are NOPed, since because we don't do the CPU
increments, the value of the syncpoint is no longer synchronized,
and any waiters would become confused if a future job incremented
the syncpoint. The syncpoint is marked locked to ensure that any
future jobs cannot increment the syncpoint either, until the
application has recognized the situation and reallocated the
syncpoint.
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2021-06-10 19:04:43 +08:00
|
|
|
/* Completion waiter ref */
|
|
|
|
void *waiter;
|
|
|
|
|
2013-09-24 22:30:32 +08:00
|
|
|
/* Maximum time to wait for this job */
|
|
|
|
unsigned int timeout;
|
|
|
|
|
gpu: host1x: Add no-recovery mode
Add a new property for jobs to enable or disable recovery i.e.
CPU increments of syncpoints to max value on job timeout. This
allows for a more solid model for hanged jobs, where userspace
doesn't need to guess if a syncpoint increment happened because
the job completed, or because job timeout was triggered.
On job timeout, we stop the channel, NOP all future jobs on the
channel using the same syncpoint, mark the syncpoint as locked
and resume the channel from the next job, if any.
The future jobs are NOPed, since because we don't do the CPU
increments, the value of the syncpoint is no longer synchronized,
and any waiters would become confused if a future job incremented
the syncpoint. The syncpoint is marked locked to ensure that any
future jobs cannot increment the syncpoint either, until the
application has recognized the situation and reallocated the
syncpoint.
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2021-06-10 19:04:43 +08:00
|
|
|
/* Job has timed out and should be released */
|
|
|
|
bool cancelled;
|
|
|
|
|
2013-09-24 22:30:32 +08:00
|
|
|
/* Index and number of slots used in the push buffer */
|
|
|
|
unsigned int first_get;
|
|
|
|
unsigned int num_slots;
|
|
|
|
|
|
|
|
/* Copy of gathers */
|
|
|
|
size_t gather_copy_size;
|
|
|
|
dma_addr_t gather_copy;
|
|
|
|
u8 *gather_copy_mapped;
|
|
|
|
|
|
|
|
/* Check if register is marked as an address reg */
|
2017-06-15 07:18:38 +08:00
|
|
|
int (*is_addr_reg)(struct device *dev, u32 class, u32 reg);
|
2013-09-24 22:30:32 +08:00
|
|
|
|
2017-06-15 07:18:37 +08:00
|
|
|
/* Check if class belongs to the unit */
|
|
|
|
int (*is_valid_class)(u32 class);
|
|
|
|
|
2013-09-24 22:30:32 +08:00
|
|
|
/* Request a SETCLASS to this class */
|
|
|
|
u32 class;
|
|
|
|
|
|
|
|
/* Add a channel wait for previous ops to complete */
|
|
|
|
bool serialize;
|
gpu: host1x: Add no-recovery mode
Add a new property for jobs to enable or disable recovery i.e.
CPU increments of syncpoints to max value on job timeout. This
allows for a more solid model for hanged jobs, where userspace
doesn't need to guess if a syncpoint increment happened because
the job completed, or because job timeout was triggered.
On job timeout, we stop the channel, NOP all future jobs on the
channel using the same syncpoint, mark the syncpoint as locked
and resume the channel from the next job, if any.
The future jobs are NOPed, since because we don't do the CPU
increments, the value of the syncpoint is no longer synchronized,
and any waiters would become confused if a future job incremented
the syncpoint. The syncpoint is marked locked to ensure that any
future jobs cannot increment the syncpoint either, until the
application has recognized the situation and reallocated the
syncpoint.
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2021-06-10 19:04:43 +08:00
|
|
|
|
|
|
|
/* Fast-forward syncpoint increments on job timeout */
|
|
|
|
bool syncpt_recovery;
|
2021-06-10 19:04:44 +08:00
|
|
|
|
|
|
|
/* Callback called when job is freed */
|
|
|
|
void (*release)(struct host1x_job *job);
|
|
|
|
void *user_data;
|
2021-06-10 19:04:46 +08:00
|
|
|
|
|
|
|
/* Whether host1x-side firewall should be ran for this job or not */
|
|
|
|
bool enable_firewall;
|
2022-06-27 22:19:49 +08:00
|
|
|
|
|
|
|
/* Options for configuring engine data stream ID */
|
|
|
|
/* Context device to use for job */
|
|
|
|
struct host1x_memory_context *memory_context;
|
|
|
|
/* Stream ID to use if context isolation is disabled (!memory_context) */
|
|
|
|
u32 engine_fallback_streamid;
|
|
|
|
/* Engine offset to program stream ID to */
|
|
|
|
u32 engine_streamid_offset;
|
2013-09-24 22:30:32 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct host1x_job *host1x_job_alloc(struct host1x_channel *ch,
|
2021-06-10 19:04:46 +08:00
|
|
|
u32 num_cmdbufs, u32 num_relocs,
|
|
|
|
bool skip_firewall);
|
2018-05-16 23:01:43 +08:00
|
|
|
void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *bo,
|
|
|
|
unsigned int words, unsigned int offset);
|
2021-06-10 19:04:45 +08:00
|
|
|
void host1x_job_add_wait(struct host1x_job *job, u32 id, u32 thresh,
|
|
|
|
bool relative, u32 next_class);
|
2013-09-24 22:30:32 +08:00
|
|
|
struct host1x_job *host1x_job_get(struct host1x_job *job);
|
|
|
|
void host1x_job_put(struct host1x_job *job);
|
|
|
|
int host1x_job_pin(struct host1x_job *job, struct device *dev);
|
|
|
|
void host1x_job_unpin(struct host1x_job *job);
|
|
|
|
|
2013-10-14 20:43:22 +08:00
|
|
|
/*
|
|
|
|
* subdevice probe infrastructure
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct host1x_device;
|
|
|
|
|
2017-04-10 18:27:01 +08:00
|
|
|
/**
|
|
|
|
* struct host1x_driver - host1x logical device driver
|
|
|
|
* @driver: core driver
|
|
|
|
* @subdevs: table of OF device IDs matching subdevices for this driver
|
|
|
|
* @list: list node for the driver
|
|
|
|
* @probe: called when the host1x logical device is probed
|
|
|
|
* @remove: called when the host1x logical device is removed
|
|
|
|
* @shutdown: called when the host1x logical device is shut down
|
|
|
|
*/
|
2013-10-14 20:43:22 +08:00
|
|
|
struct host1x_driver {
|
2014-12-18 22:29:14 +08:00
|
|
|
struct device_driver driver;
|
|
|
|
|
2013-10-14 20:43:22 +08:00
|
|
|
const struct of_device_id *subdevs;
|
|
|
|
struct list_head list;
|
|
|
|
|
|
|
|
int (*probe)(struct host1x_device *device);
|
|
|
|
int (*remove)(struct host1x_device *device);
|
2014-12-18 22:29:14 +08:00
|
|
|
void (*shutdown)(struct host1x_device *device);
|
2013-10-14 20:43:22 +08:00
|
|
|
};
|
|
|
|
|
2014-12-18 22:29:14 +08:00
|
|
|
static inline struct host1x_driver *
|
|
|
|
to_host1x_driver(struct device_driver *driver)
|
|
|
|
{
|
|
|
|
return container_of(driver, struct host1x_driver, driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
int host1x_driver_register_full(struct host1x_driver *driver,
|
|
|
|
struct module *owner);
|
2013-10-14 20:43:22 +08:00
|
|
|
void host1x_driver_unregister(struct host1x_driver *driver);
|
|
|
|
|
2014-12-18 22:29:14 +08:00
|
|
|
#define host1x_driver_register(driver) \
|
|
|
|
host1x_driver_register_full(driver, THIS_MODULE)
|
|
|
|
|
2013-10-14 20:43:22 +08:00
|
|
|
struct host1x_device {
|
|
|
|
struct host1x_driver *driver;
|
|
|
|
struct list_head list;
|
|
|
|
struct device dev;
|
|
|
|
|
|
|
|
struct mutex subdevs_lock;
|
|
|
|
struct list_head subdevs;
|
|
|
|
struct list_head active;
|
|
|
|
|
|
|
|
struct mutex clients_lock;
|
|
|
|
struct list_head clients;
|
2014-11-05 18:43:26 +08:00
|
|
|
|
2014-12-18 22:29:14 +08:00
|
|
|
bool registered;
|
2019-06-05 16:46:05 +08:00
|
|
|
|
|
|
|
struct device_dma_parameters dma_parms;
|
2013-10-14 20:43:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct host1x_device *to_host1x_device(struct device *dev)
|
|
|
|
{
|
|
|
|
return container_of(dev, struct host1x_device, dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
int host1x_device_init(struct host1x_device *device);
|
|
|
|
int host1x_device_exit(struct host1x_device *device);
|
|
|
|
|
2021-04-01 23:41:04 +08:00
|
|
|
void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key);
|
|
|
|
void host1x_client_exit(struct host1x_client *client);
|
|
|
|
|
|
|
|
#define host1x_client_init(client) \
|
|
|
|
({ \
|
|
|
|
static struct lock_class_key __key; \
|
|
|
|
__host1x_client_init(client, &__key); \
|
|
|
|
})
|
|
|
|
|
|
|
|
int __host1x_client_register(struct host1x_client *client);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that this wrapper calls __host1x_client_init() for compatibility
|
|
|
|
* with existing callers. Callers that want to separately initialize and
|
|
|
|
* register a host1x client must first initialize using either of the
|
|
|
|
* __host1x_client_init() or host1x_client_init() functions and then use
|
|
|
|
* the low-level __host1x_client_register() function to avoid the client
|
|
|
|
* getting reinitialized.
|
|
|
|
*/
|
|
|
|
#define host1x_client_register(client) \
|
|
|
|
({ \
|
|
|
|
static struct lock_class_key __key; \
|
|
|
|
__host1x_client_init(client, &__key); \
|
|
|
|
__host1x_client_register(client); \
|
2021-03-29 21:38:27 +08:00
|
|
|
})
|
|
|
|
|
2013-10-14 20:43:22 +08:00
|
|
|
int host1x_client_unregister(struct host1x_client *client);
|
|
|
|
|
2019-12-02 22:29:03 +08:00
|
|
|
int host1x_client_suspend(struct host1x_client *client);
|
|
|
|
int host1x_client_resume(struct host1x_client *client);
|
|
|
|
|
2013-09-02 15:48:53 +08:00
|
|
|
struct tegra_mipi_device;
|
|
|
|
|
2020-07-15 12:20:51 +08:00
|
|
|
struct tegra_mipi_device *tegra_mipi_request(struct device *device,
|
|
|
|
struct device_node *np);
|
2013-09-02 15:48:53 +08:00
|
|
|
void tegra_mipi_free(struct tegra_mipi_device *device);
|
2016-08-12 22:00:53 +08:00
|
|
|
int tegra_mipi_enable(struct tegra_mipi_device *device);
|
|
|
|
int tegra_mipi_disable(struct tegra_mipi_device *device);
|
2020-08-12 08:27:19 +08:00
|
|
|
int tegra_mipi_start_calibration(struct tegra_mipi_device *device);
|
|
|
|
int tegra_mipi_finish_calibration(struct tegra_mipi_device *device);
|
2013-09-02 15:48:53 +08:00
|
|
|
|
2022-06-27 22:19:48 +08:00
|
|
|
/* host1x memory contexts */
|
|
|
|
|
|
|
|
struct host1x_memory_context {
|
|
|
|
struct host1x *host;
|
|
|
|
|
|
|
|
refcount_t ref;
|
|
|
|
struct pid *owner;
|
|
|
|
|
|
|
|
struct device dev;
|
|
|
|
u64 dma_mask;
|
|
|
|
u32 stream_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_IOMMU_API
|
|
|
|
struct host1x_memory_context *host1x_memory_context_alloc(struct host1x *host1x,
|
|
|
|
struct pid *pid);
|
|
|
|
void host1x_memory_context_get(struct host1x_memory_context *cd);
|
|
|
|
void host1x_memory_context_put(struct host1x_memory_context *cd);
|
|
|
|
#else
|
|
|
|
static inline struct host1x_memory_context *host1x_memory_context_alloc(struct host1x *host1x,
|
|
|
|
struct pid *pid)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void host1x_memory_context_get(struct host1x_memory_context *cd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void host1x_memory_context_put(struct host1x_memory_context *cd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-22 22:34:03 +08:00
|
|
|
#endif
|