4 * Copyright (c) 2011-2013, NVIDIA Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef __HOST1X_JOB_H
20 #define __HOST1X_JOB_H
22 struct host1x_job_gather {
30 struct host1x_cmdbuf {
38 struct host1x_bo *cmdbuf;
40 struct host1x_bo *target;
46 struct host1x_waitchk {
53 struct host1x_job_unpin_data {
59 * Each submit is tracked as a host1x_job.
62 /* When refcount goes to zero, job can be freed */
66 struct list_head list;
68 /* Channel where job is submitted to */
69 struct host1x_channel *channel;
73 /* Gathers and their memory */
74 struct host1x_job_gather *gathers;
75 unsigned int num_gathers;
77 /* Wait checks to be processed at submit time */
78 struct host1x_waitchk *waitchk;
79 unsigned int num_waitchk;
82 /* Array of handles to be pinned & unpinned */
83 struct host1x_reloc *relocarray;
84 unsigned int num_relocs;
85 struct host1x_job_unpin_data *unpins;
86 unsigned int num_unpins;
88 dma_addr_t *addr_phys;
89 dma_addr_t *gather_addr_phys;
90 dma_addr_t *reloc_addr_phys;
92 /* Sync point id, number of increments and end related to the submit */
97 /* Maximum time to wait for this job */
100 /* Index and number of slots used in the push buffer */
101 unsigned int first_get;
102 unsigned int num_slots;
104 /* Copy of gathers */
105 size_t gather_copy_size;
106 dma_addr_t gather_copy;
107 u8 *gather_copy_mapped;
109 /* Check if register is marked as an address reg */
110 int (*is_addr_reg)(struct device *dev, u32 reg, u32 class);
112 /* Request a SETCLASS to this class */
115 /* Add a channel wait for previous ops to complete */
119 * Allocate memory for a job. Just enough memory will be allocated to
120 * accomodate the submit.
122 struct host1x_job *host1x_job_alloc(struct host1x_channel *ch,
123 u32 num_cmdbufs, u32 num_relocs,
127 * Add a gather to a job.
129 void host1x_job_add_gather(struct host1x_job *job, struct host1x_bo *mem_id,
130 u32 words, u32 offset);
133 * Increment reference going to host1x_job.
135 struct host1x_job *host1x_job_get(struct host1x_job *job);
138 * Decrement reference job, free if goes to zero.
140 void host1x_job_put(struct host1x_job *job);
143 * Pin memory related to job. This handles relocation of addresses to the
144 * host1x address space. Handles both the gather memory and any other memory
145 * referred to from the gather buffers.
147 * Handles also patching out host waits that would wait for an expired sync
150 int host1x_job_pin(struct host1x_job *job, struct device *dev);
153 * Unpin memory related to job.
155 void host1x_job_unpin(struct host1x_job *job);
158 * Dump contents of job to debug output.
160 void host1x_job_dump(struct device *dev, struct host1x_job *job);