Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 * Tegra host1x Syncpoints
  3 *
  4 * Copyright (c) 2010-2013, NVIDIA Corporation.
  5 *
  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.
  9 *
 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
 13 * more details.
 14 *
 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/>.
 17 */
 18
 19#ifndef __HOST1X_SYNCPT_H
 20#define __HOST1X_SYNCPT_H
 21
 22#include <linux/atomic.h>
 23#include <linux/host1x.h>
 24#include <linux/kernel.h>
 
 25#include <linux/sched.h>
 26
 27#include "intr.h"
 28
 29struct host1x;
 30
 31/* Reserved for replacing an expired wait with a NOP */
 32#define HOST1X_SYNCPT_RESERVED			0
 33
 34struct host1x_syncpt_base {
 35	unsigned int id;
 36	bool requested;
 37};
 38
 39struct host1x_syncpt {
 40	int id;
 
 
 41	atomic_t min_val;
 42	atomic_t max_val;
 43	u32 base_val;
 44	const char *name;
 45	bool client_managed;
 46	struct host1x *host;
 47	struct device *dev;
 48	struct host1x_syncpt_base *base;
 49
 50	/* interrupt data */
 51	struct host1x_syncpt_intr intr;
 
 
 
 
 
 
 
 52};
 53
 54/* Initialize sync point array  */
 55int host1x_syncpt_init(struct host1x *host);
 56
 57/*  Free sync point array */
 58void host1x_syncpt_deinit(struct host1x *host);
 59
 60/* Return number of sync point supported. */
 61int host1x_syncpt_nb_pts(struct host1x *host);
 62
 63/* Return number of wait bases supported. */
 64int host1x_syncpt_nb_bases(struct host1x *host);
 65
 66/* Return number of mlocks supported. */
 67int host1x_syncpt_nb_mlocks(struct host1x *host);
 68
 69/*
 70 * Check sync point sanity. If max is larger than min, there have too many
 71 * sync point increments.
 72 *
 73 * Client managed sync point are not tracked.
 74 * */
 75static inline bool host1x_syncpt_check_max(struct host1x_syncpt *sp, u32 real)
 76{
 77	u32 max;
 78	if (sp->client_managed)
 79		return true;
 80	max = host1x_syncpt_read_max(sp);
 81	return (s32)(max - real) >= 0;
 82}
 83
 84/* Return true if sync point is client managed. */
 85static inline bool host1x_syncpt_client_managed(struct host1x_syncpt *sp)
 86{
 87	return sp->client_managed;
 88}
 89
 90/*
 91 * Returns true if syncpoint min == max, which means that there are no
 92 * outstanding operations.
 93 */
 94static inline bool host1x_syncpt_idle(struct host1x_syncpt *sp)
 95{
 96	int min, max;
 97	smp_rmb();
 98	min = atomic_read(&sp->min_val);
 99	max = atomic_read(&sp->max_val);
100	return (min == max);
101}
102
103/* Load current value from hardware to the shadow register. */
104u32 host1x_syncpt_load(struct host1x_syncpt *sp);
105
106/* Check if the given syncpoint value has already passed */
107bool host1x_syncpt_is_expired(struct host1x_syncpt *sp, u32 thresh);
108
109/* Save host1x sync point state into shadow registers. */
110void host1x_syncpt_save(struct host1x *host);
111
112/* Reset host1x sync point state from shadow registers. */
113void host1x_syncpt_restore(struct host1x *host);
114
115/* Read current wait base value into shadow register and return it. */
116u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp);
117
118/* Indicate future operations by incrementing the sync point max. */
119u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
120
121/* Check if sync point id is valid. */
122static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
123{
124	return sp->id < host1x_syncpt_nb_pts(sp->host);
125}
126
127/* Patch a wait by replacing it with a wait for syncpt 0 value 0 */
128int host1x_syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr);
 
 
129
130#endif
v6.2
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Tegra host1x Syncpoints
  4 *
  5 * Copyright (c) 2010-2013, NVIDIA Corporation.
 
 
 
 
 
 
 
 
 
 
 
 
  6 */
  7
  8#ifndef __HOST1X_SYNCPT_H
  9#define __HOST1X_SYNCPT_H
 10
 11#include <linux/atomic.h>
 12#include <linux/host1x.h>
 13#include <linux/kernel.h>
 14#include <linux/kref.h>
 15#include <linux/sched.h>
 16
 17#include "intr.h"
 18
 19struct host1x;
 20
 21/* Reserved for replacing an expired wait with a NOP */
 22#define HOST1X_SYNCPT_RESERVED			0
 23
 24struct host1x_syncpt_base {
 25	unsigned int id;
 26	bool requested;
 27};
 28
 29struct host1x_syncpt {
 30	struct kref ref;
 31
 32	unsigned int id;
 33	atomic_t min_val;
 34	atomic_t max_val;
 35	u32 base_val;
 36	const char *name;
 37	bool client_managed;
 38	struct host1x *host;
 
 39	struct host1x_syncpt_base *base;
 40
 41	/* interrupt data */
 42	struct host1x_syncpt_intr intr;
 43
 44	/*
 45	 * If a submission incrementing this syncpoint fails, lock it so that
 46	 * further submission cannot be made until application has handled the
 47	 * failure.
 48	 */
 49	bool locked;
 50};
 51
 52/* Initialize sync point array  */
 53int host1x_syncpt_init(struct host1x *host);
 54
 55/*  Free sync point array */
 56void host1x_syncpt_deinit(struct host1x *host);
 57
 58/* Return number of sync point supported. */
 59unsigned int host1x_syncpt_nb_pts(struct host1x *host);
 60
 61/* Return number of wait bases supported. */
 62unsigned int host1x_syncpt_nb_bases(struct host1x *host);
 63
 64/* Return number of mlocks supported. */
 65unsigned int host1x_syncpt_nb_mlocks(struct host1x *host);
 66
 67/*
 68 * Check sync point sanity. If max is larger than min, there have too many
 69 * sync point increments.
 70 *
 71 * Client managed sync point are not tracked.
 72 * */
 73static inline bool host1x_syncpt_check_max(struct host1x_syncpt *sp, u32 real)
 74{
 75	u32 max;
 76	if (sp->client_managed)
 77		return true;
 78	max = host1x_syncpt_read_max(sp);
 79	return (s32)(max - real) >= 0;
 80}
 81
 82/* Return true if sync point is client managed. */
 83static inline bool host1x_syncpt_client_managed(struct host1x_syncpt *sp)
 84{
 85	return sp->client_managed;
 86}
 87
 88/*
 89 * Returns true if syncpoint min == max, which means that there are no
 90 * outstanding operations.
 91 */
 92static inline bool host1x_syncpt_idle(struct host1x_syncpt *sp)
 93{
 94	int min, max;
 95	smp_rmb();
 96	min = atomic_read(&sp->min_val);
 97	max = atomic_read(&sp->max_val);
 98	return (min == max);
 99}
100
101/* Load current value from hardware to the shadow register. */
102u32 host1x_syncpt_load(struct host1x_syncpt *sp);
103
104/* Check if the given syncpoint value has already passed */
105bool host1x_syncpt_is_expired(struct host1x_syncpt *sp, u32 thresh);
106
107/* Save host1x sync point state into shadow registers. */
108void host1x_syncpt_save(struct host1x *host);
109
110/* Reset host1x sync point state from shadow registers. */
111void host1x_syncpt_restore(struct host1x *host);
112
113/* Read current wait base value into shadow register and return it. */
114u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp);
115
116/* Indicate future operations by incrementing the sync point max. */
117u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
118
119/* Check if sync point id is valid. */
120static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
121{
122	return sp->id < host1x_syncpt_nb_pts(sp->host);
123}
124
125static inline void host1x_syncpt_set_locked(struct host1x_syncpt *sp)
126{
127	sp->locked = true;
128}
129
130#endif