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

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2010-2015, NVIDIA Corporation.
23 host1x_syncpt_base_request(struct host1x *host) in host1x_syncpt_base_request() argument
25 struct host1x_syncpt_base *bases = host->bases; in host1x_syncpt_base_request()
28 for (i = 0; i < host->info->nb_bases; i++) in host1x_syncpt_base_request()
32 if (i >= host->info->nb_bases) in host1x_syncpt_base_request()
42 base->requested = false; in host1x_syncpt_base_free()
46 * host1x_syncpt_alloc() - allocate a syncpoint
47 * @host: host1x device data
57 struct host1x_syncpt *host1x_syncpt_alloc(struct host1x *host, in host1x_syncpt_alloc() argument
61 struct host1x_syncpt *sp = host->syncpt; in host1x_syncpt_alloc()
68 mutex_lock(&host->syncpt_mutex); in host1x_syncpt_alloc()
70 for (i = 0; i < host->info->nb_pts && kref_read(&sp->ref); i++, sp++) in host1x_syncpt_alloc()
73 if (i >= host->info->nb_pts) in host1x_syncpt_alloc()
77 sp->base = host1x_syncpt_base_request(host); in host1x_syncpt_alloc()
78 if (!sp->base) in host1x_syncpt_alloc()
82 full_name = kasprintf(GFP_KERNEL, "%u-%s", sp->id, name); in host1x_syncpt_alloc()
86 sp->name = full_name; in host1x_syncpt_alloc()
89 sp->client_managed = true; in host1x_syncpt_alloc()
91 sp->client_managed = false; in host1x_syncpt_alloc()
93 kref_init(&sp->ref); in host1x_syncpt_alloc()
95 mutex_unlock(&host->syncpt_mutex); in host1x_syncpt_alloc()
99 host1x_syncpt_base_free(sp->base); in host1x_syncpt_alloc()
100 sp->base = NULL; in host1x_syncpt_alloc()
102 mutex_unlock(&host->syncpt_mutex); in host1x_syncpt_alloc()
108 * host1x_syncpt_id() - retrieve syncpoint ID
111 * Given a pointer to a struct host1x_syncpt, retrieves its ID. This ID is
117 return sp->id; in host1x_syncpt_id()
122 * host1x_syncpt_incr_max() - update the value sent to hardware
128 return (u32)atomic_add_return(incrs, &sp->max_val); in host1x_syncpt_incr_max()
135 void host1x_syncpt_restore(struct host1x *host) in host1x_syncpt_restore() argument
137 struct host1x_syncpt *sp_base = host->syncpt; in host1x_syncpt_restore()
140 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) in host1x_syncpt_restore()
141 host1x_hw_syncpt_restore(host, sp_base + i); in host1x_syncpt_restore()
143 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) in host1x_syncpt_restore()
144 host1x_hw_syncpt_restore_wait_base(host, sp_base + i); in host1x_syncpt_restore()
153 void host1x_syncpt_save(struct host1x *host) in host1x_syncpt_save() argument
155 struct host1x_syncpt *sp_base = host->syncpt; in host1x_syncpt_save()
158 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) { in host1x_syncpt_save()
160 host1x_hw_syncpt_load(host, sp_base + i); in host1x_syncpt_save()
165 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) in host1x_syncpt_save()
166 host1x_hw_syncpt_load_wait_base(host, sp_base + i); in host1x_syncpt_save()
177 val = host1x_hw_syncpt_load(sp->host, sp); in host1x_syncpt_load()
178 trace_host1x_syncpt_load_min(sp->id, val); in host1x_syncpt_load()
188 host1x_hw_syncpt_load_wait_base(sp->host, sp); in host1x_syncpt_load_wait_base()
190 return sp->base_val; in host1x_syncpt_load_wait_base()
194 * host1x_syncpt_incr() - increment syncpoint value from CPU, updating cache
199 return host1x_hw_syncpt_cpu_incr(sp->host, sp); in host1x_syncpt_incr()
209 host1x_hw_syncpt_load(sp->host, sp); in syncpt_load_min_is_expired()
215 * host1x_syncpt_wait() - wait for a syncpoint to reach a given value
242 val = host1x_hw_syncpt_load(sp->host, sp); in host1x_syncpt_wait()
251 err = -EAGAIN; in host1x_syncpt_wait()
258 err = -ENOMEM; in host1x_syncpt_wait()
263 err = host1x_intr_add_action(sp->host, sp, thresh, in host1x_syncpt_wait()
269 err = -EAGAIN; in host1x_syncpt_wait()
270 /* Caller-specified timeout may be impractically low */ in host1x_syncpt_wait()
296 timeout -= check; in host1x_syncpt_wait()
299 dev_warn(sp->host->dev, in host1x_syncpt_wait()
300 "%s: syncpoint id %u (%s) stuck waiting %d, timeout=%ld\n", in host1x_syncpt_wait()
301 current->comm, sp->id, sp->name, in host1x_syncpt_wait()
304 host1x_debug_dump_syncpts(sp->host); in host1x_syncpt_wait()
307 host1x_debug_dump(sp->host); in host1x_syncpt_wait()
313 host1x_intr_put_ref(sp->host, sp->id, ref, true); in host1x_syncpt_wait()
329 current_val = (u32)atomic_read(&sp->min_val); in host1x_syncpt_is_expired()
331 return ((current_val - thresh) & 0x80000000U) == 0U; in host1x_syncpt_is_expired()
334 int host1x_syncpt_init(struct host1x *host) in host1x_syncpt_init() argument
340 syncpt = devm_kcalloc(host->dev, host->info->nb_pts, sizeof(*syncpt), in host1x_syncpt_init()
343 return -ENOMEM; in host1x_syncpt_init()
345 bases = devm_kcalloc(host->dev, host->info->nb_bases, sizeof(*bases), in host1x_syncpt_init()
348 return -ENOMEM; in host1x_syncpt_init()
350 for (i = 0; i < host->info->nb_pts; i++) { in host1x_syncpt_init()
351 syncpt[i].id = i; in host1x_syncpt_init()
352 syncpt[i].host = host; in host1x_syncpt_init()
359 host1x_hw_syncpt_assign_to_channel(host, &syncpt[i], NULL); in host1x_syncpt_init()
362 for (i = 0; i < host->info->nb_bases; i++) in host1x_syncpt_init()
363 bases[i].id = i; in host1x_syncpt_init()
365 mutex_init(&host->syncpt_mutex); in host1x_syncpt_init()
366 host->syncpt = syncpt; in host1x_syncpt_init()
367 host->bases = bases; in host1x_syncpt_init()
369 host1x_syncpt_restore(host); in host1x_syncpt_init()
370 host1x_hw_syncpt_enable_protection(host); in host1x_syncpt_init()
373 host->nop_sp = host1x_syncpt_alloc(host, 0, "reserved-nop"); in host1x_syncpt_init()
374 if (!host->nop_sp) in host1x_syncpt_init()
375 return -ENOMEM; in host1x_syncpt_init()
377 if (host->info->reserve_vblank_syncpts) { in host1x_syncpt_init()
378 kref_init(&host->syncpt[26].ref); in host1x_syncpt_init()
379 kref_init(&host->syncpt[27].ref); in host1x_syncpt_init()
386 * host1x_syncpt_request() - request a syncpoint
398 struct host1x *host = dev_get_drvdata(client->host->parent); in host1x_syncpt_request() local
400 return host1x_syncpt_alloc(host, flags, dev_name(client->dev)); in host1x_syncpt_request()
408 atomic_set(&sp->max_val, host1x_syncpt_read(sp)); in syncpt_release()
410 sp->locked = false; in syncpt_release()
412 mutex_lock(&sp->host->syncpt_mutex); in syncpt_release()
414 host1x_syncpt_base_free(sp->base); in syncpt_release()
415 kfree(sp->name); in syncpt_release()
416 sp->base = NULL; in syncpt_release()
417 sp->name = NULL; in syncpt_release()
418 sp->client_managed = false; in syncpt_release()
420 mutex_unlock(&sp->host->syncpt_mutex); in syncpt_release()
424 * host1x_syncpt_put() - free a requested syncpoint
436 kref_put(&sp->ref, syncpt_release); in host1x_syncpt_put()
440 void host1x_syncpt_deinit(struct host1x *host) in host1x_syncpt_deinit() argument
442 struct host1x_syncpt *sp = host->syncpt; in host1x_syncpt_deinit()
445 for (i = 0; i < host->info->nb_pts; i++, sp++) in host1x_syncpt_deinit()
446 kfree(sp->name); in host1x_syncpt_deinit()
450 * host1x_syncpt_read_max() - read maximum syncpoint value
460 return (u32)atomic_read(&sp->max_val); in host1x_syncpt_read_max()
465 * host1x_syncpt_read_min() - read minimum syncpoint value
475 return (u32)atomic_read(&sp->min_val); in host1x_syncpt_read_min()
480 * host1x_syncpt_read() - read the current syncpoint value
489 unsigned int host1x_syncpt_nb_pts(struct host1x *host) in host1x_syncpt_nb_pts() argument
491 return host->info->nb_pts; in host1x_syncpt_nb_pts()
494 unsigned int host1x_syncpt_nb_bases(struct host1x *host) in host1x_syncpt_nb_bases() argument
496 return host->info->nb_bases; in host1x_syncpt_nb_bases()
499 unsigned int host1x_syncpt_nb_mlocks(struct host1x *host) in host1x_syncpt_nb_mlocks() argument
501 return host->info->nb_mlocks; in host1x_syncpt_nb_mlocks()
505 * host1x_syncpt_get_by_id() - obtain a syncpoint by ID
506 * @host: host1x controller
507 * @id: syncpoint ID
509 struct host1x_syncpt *host1x_syncpt_get_by_id(struct host1x *host, in host1x_syncpt_get_by_id() argument
510 unsigned int id) in host1x_syncpt_get_by_id() argument
512 if (id >= host->info->nb_pts) in host1x_syncpt_get_by_id()
515 if (kref_get_unless_zero(&host->syncpt[id].ref)) in host1x_syncpt_get_by_id()
516 return &host->syncpt[id]; in host1x_syncpt_get_by_id()
523 * host1x_syncpt_get_by_id_noref() - obtain a syncpoint by ID but don't
525 * @host: host1x controller
526 * @id: syncpoint ID
528 struct host1x_syncpt *host1x_syncpt_get_by_id_noref(struct host1x *host, in host1x_syncpt_get_by_id_noref() argument
529 unsigned int id) in host1x_syncpt_get_by_id_noref() argument
531 if (id >= host->info->nb_pts) in host1x_syncpt_get_by_id_noref()
534 return &host->syncpt[id]; in host1x_syncpt_get_by_id_noref()
539 * host1x_syncpt_get() - increment syncpoint refcount
544 kref_get(&sp->ref); in host1x_syncpt_get()
551 * host1x_syncpt_get_base() - obtain the wait base associated with a syncpoint
556 return sp ? sp->base : NULL; in host1x_syncpt_get_base()
561 * host1x_syncpt_base_id() - retrieve the ID of a syncpoint wait base
566 return base->id; in host1x_syncpt_base_id()
575 * host1x_syncpt_release_vblank_reservation() - Make VBLANK syncpoint
579 * @syncpt_id: syncpoint ID to make available
589 struct host1x *host = dev_get_drvdata(client->host->parent); in host1x_syncpt_release_vblank_reservation() local
591 if (!host->info->reserve_vblank_syncpts) in host1x_syncpt_release_vblank_reservation()
594 kref_put(&host->syncpt[syncpt_id].ref, do_nothing); in host1x_syncpt_release_vblank_reservation()