Lines Matching +full:host +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2010-2015, NVIDIA Corporation.
10 #include <linux/dma-fence.h>
24 host1x_syncpt_base_request(struct host1x *host) in host1x_syncpt_base_request() argument
26 struct host1x_syncpt_base *bases = host->bases; in host1x_syncpt_base_request()
29 for (i = 0; i < host->info->nb_bases; i++) in host1x_syncpt_base_request()
33 if (i >= host->info->nb_bases) in host1x_syncpt_base_request()
43 base->requested = false; in host1x_syncpt_base_free()
47 * host1x_syncpt_alloc() - allocate a syncpoint
48 * @host: host1x device data
58 struct host1x_syncpt *host1x_syncpt_alloc(struct host1x *host, in host1x_syncpt_alloc() argument
62 struct host1x_syncpt *sp = host->syncpt; in host1x_syncpt_alloc()
69 mutex_lock(&host->syncpt_mutex); in host1x_syncpt_alloc()
71 for (i = 0; i < host->info->nb_pts && kref_read(&sp->ref); i++, sp++) in host1x_syncpt_alloc()
74 if (i >= host->info->nb_pts) in host1x_syncpt_alloc()
78 sp->base = host1x_syncpt_base_request(host); in host1x_syncpt_alloc()
79 if (!sp->base) in host1x_syncpt_alloc()
83 full_name = kasprintf(GFP_KERNEL, "%u-%s", sp->id, name); in host1x_syncpt_alloc()
87 sp->name = full_name; in host1x_syncpt_alloc()
90 sp->client_managed = true; in host1x_syncpt_alloc()
92 sp->client_managed = false; in host1x_syncpt_alloc()
94 kref_init(&sp->ref); in host1x_syncpt_alloc()
96 mutex_unlock(&host->syncpt_mutex); in host1x_syncpt_alloc()
100 host1x_syncpt_base_free(sp->base); in host1x_syncpt_alloc()
101 sp->base = NULL; in host1x_syncpt_alloc()
103 mutex_unlock(&host->syncpt_mutex); in host1x_syncpt_alloc()
109 * host1x_syncpt_id() - retrieve syncpoint ID
112 * Given a pointer to a struct host1x_syncpt, retrieves its ID. This ID is
118 return sp->id; in host1x_syncpt_id()
123 * host1x_syncpt_incr_max() - update the value sent to hardware
129 return (u32)atomic_add_return(incrs, &sp->max_val); in host1x_syncpt_incr_max()
136 void host1x_syncpt_restore(struct host1x *host) in host1x_syncpt_restore() argument
138 struct host1x_syncpt *sp_base = host->syncpt; in host1x_syncpt_restore()
141 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) { in host1x_syncpt_restore()
147 host1x_hw_syncpt_assign_to_channel(host, sp_base + i, NULL); in host1x_syncpt_restore()
148 host1x_hw_syncpt_restore(host, sp_base + i); in host1x_syncpt_restore()
151 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) in host1x_syncpt_restore()
152 host1x_hw_syncpt_restore_wait_base(host, sp_base + i); in host1x_syncpt_restore()
154 host1x_hw_syncpt_enable_protection(host); in host1x_syncpt_restore()
163 void host1x_syncpt_save(struct host1x *host) in host1x_syncpt_save() argument
165 struct host1x_syncpt *sp_base = host->syncpt; in host1x_syncpt_save()
168 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) { in host1x_syncpt_save()
170 host1x_hw_syncpt_load(host, sp_base + i); in host1x_syncpt_save()
175 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) in host1x_syncpt_save()
176 host1x_hw_syncpt_load_wait_base(host, sp_base + i); in host1x_syncpt_save()
187 val = host1x_hw_syncpt_load(sp->host, sp); in host1x_syncpt_load()
188 trace_host1x_syncpt_load_min(sp->id, val); in host1x_syncpt_load()
198 host1x_hw_syncpt_load_wait_base(sp->host, sp); in host1x_syncpt_load_wait_base()
200 return sp->base_val; in host1x_syncpt_load_wait_base()
204 * host1x_syncpt_incr() - increment syncpoint value from CPU, updating cache
209 return host1x_hw_syncpt_cpu_incr(sp->host, sp); in host1x_syncpt_incr()
214 * host1x_syncpt_wait() - wait for a syncpoint to reach a given value
226 host1x_hw_syncpt_load(sp->host, sp); in host1x_syncpt_wait()
237 return -EAGAIN; in host1x_syncpt_wait()
256 host1x_hw_syncpt_load(sp->host, sp); in host1x_syncpt_wait()
258 return -EAGAIN; in host1x_syncpt_wait()
275 current_val = (u32)atomic_read(&sp->min_val); in host1x_syncpt_is_expired()
277 return ((current_val - thresh) & 0x80000000U) == 0U; in host1x_syncpt_is_expired()
280 int host1x_syncpt_init(struct host1x *host) in host1x_syncpt_init() argument
286 syncpt = devm_kcalloc(host->dev, host->info->nb_pts, sizeof(*syncpt), in host1x_syncpt_init()
289 return -ENOMEM; in host1x_syncpt_init()
291 bases = devm_kcalloc(host->dev, host->info->nb_bases, sizeof(*bases), in host1x_syncpt_init()
294 return -ENOMEM; in host1x_syncpt_init()
296 for (i = 0; i < host->info->nb_pts; i++) { in host1x_syncpt_init()
297 syncpt[i].id = i; in host1x_syncpt_init()
298 syncpt[i].host = host; in host1x_syncpt_init()
301 for (i = 0; i < host->info->nb_bases; i++) in host1x_syncpt_init()
302 bases[i].id = i; in host1x_syncpt_init()
304 mutex_init(&host->syncpt_mutex); in host1x_syncpt_init()
305 host->syncpt = syncpt; in host1x_syncpt_init()
306 host->bases = bases; in host1x_syncpt_init()
309 host->nop_sp = host1x_syncpt_alloc(host, 0, "reserved-nop"); in host1x_syncpt_init()
310 if (!host->nop_sp) in host1x_syncpt_init()
311 return -ENOMEM; in host1x_syncpt_init()
313 if (host->info->reserve_vblank_syncpts) { in host1x_syncpt_init()
314 kref_init(&host->syncpt[26].ref); in host1x_syncpt_init()
315 kref_init(&host->syncpt[27].ref); in host1x_syncpt_init()
322 * host1x_syncpt_request() - request a syncpoint
334 struct host1x *host = dev_get_drvdata(client->host->parent); in host1x_syncpt_request() local
336 return host1x_syncpt_alloc(host, flags, dev_name(client->dev)); in host1x_syncpt_request()
344 atomic_set(&sp->max_val, host1x_syncpt_read(sp)); in syncpt_release()
346 sp->locked = false; in syncpt_release()
348 mutex_lock(&sp->host->syncpt_mutex); in syncpt_release()
350 host1x_syncpt_base_free(sp->base); in syncpt_release()
351 kfree(sp->name); in syncpt_release()
352 sp->base = NULL; in syncpt_release()
353 sp->name = NULL; in syncpt_release()
354 sp->client_managed = false; in syncpt_release()
356 mutex_unlock(&sp->host->syncpt_mutex); in syncpt_release()
360 * host1x_syncpt_put() - free a requested syncpoint
372 kref_put(&sp->ref, syncpt_release); in host1x_syncpt_put()
376 void host1x_syncpt_deinit(struct host1x *host) in host1x_syncpt_deinit() argument
378 struct host1x_syncpt *sp = host->syncpt; in host1x_syncpt_deinit()
381 for (i = 0; i < host->info->nb_pts; i++, sp++) in host1x_syncpt_deinit()
382 kfree(sp->name); in host1x_syncpt_deinit()
386 * host1x_syncpt_read_max() - read maximum syncpoint value
396 return (u32)atomic_read(&sp->max_val); in host1x_syncpt_read_max()
401 * host1x_syncpt_read_min() - read minimum syncpoint value
411 return (u32)atomic_read(&sp->min_val); in host1x_syncpt_read_min()
416 * host1x_syncpt_read() - read the current syncpoint value
425 unsigned int host1x_syncpt_nb_pts(struct host1x *host) in host1x_syncpt_nb_pts() argument
427 return host->info->nb_pts; in host1x_syncpt_nb_pts()
430 unsigned int host1x_syncpt_nb_bases(struct host1x *host) in host1x_syncpt_nb_bases() argument
432 return host->info->nb_bases; in host1x_syncpt_nb_bases()
435 unsigned int host1x_syncpt_nb_mlocks(struct host1x *host) in host1x_syncpt_nb_mlocks() argument
437 return host->info->nb_mlocks; in host1x_syncpt_nb_mlocks()
441 * host1x_syncpt_get_by_id() - obtain a syncpoint by ID
442 * @host: host1x controller
443 * @id: syncpoint ID
445 struct host1x_syncpt *host1x_syncpt_get_by_id(struct host1x *host, in host1x_syncpt_get_by_id() argument
446 unsigned int id) in host1x_syncpt_get_by_id() argument
448 if (id >= host->info->nb_pts) in host1x_syncpt_get_by_id()
451 if (kref_get_unless_zero(&host->syncpt[id].ref)) in host1x_syncpt_get_by_id()
452 return &host->syncpt[id]; in host1x_syncpt_get_by_id()
459 * host1x_syncpt_get_by_id_noref() - obtain a syncpoint by ID but don't
461 * @host: host1x controller
462 * @id: syncpoint ID
464 struct host1x_syncpt *host1x_syncpt_get_by_id_noref(struct host1x *host, in host1x_syncpt_get_by_id_noref() argument
465 unsigned int id) in host1x_syncpt_get_by_id_noref() argument
467 if (id >= host->info->nb_pts) in host1x_syncpt_get_by_id_noref()
470 return &host->syncpt[id]; in host1x_syncpt_get_by_id_noref()
475 * host1x_syncpt_get() - increment syncpoint refcount
480 kref_get(&sp->ref); in host1x_syncpt_get()
487 * host1x_syncpt_get_base() - obtain the wait base associated with a syncpoint
492 return sp ? sp->base : NULL; in host1x_syncpt_get_base()
497 * host1x_syncpt_base_id() - retrieve the ID of a syncpoint wait base
502 return base->id; in host1x_syncpt_base_id()
511 * host1x_syncpt_release_vblank_reservation() - Make VBLANK syncpoint
515 * @syncpt_id: syncpoint ID to make available
525 struct host1x *host = dev_get_drvdata(client->host->parent); in host1x_syncpt_release_vblank_reservation() local
527 if (!host->info->reserve_vblank_syncpts) in host1x_syncpt_release_vblank_reservation()
530 kref_put(&host->syncpt[syncpt_id].ref, do_nothing); in host1x_syncpt_release_vblank_reservation()