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()
45 static struct host1x_syncpt *host1x_syncpt_alloc(struct host1x *host, in host1x_syncpt_alloc() argument
49 struct host1x_syncpt *sp = host->syncpt; in host1x_syncpt_alloc()
53 mutex_lock(&host->syncpt_mutex); in host1x_syncpt_alloc()
55 for (i = 0; i < host->info->nb_pts && sp->name; i++, sp++) in host1x_syncpt_alloc()
58 if (i >= host->info->nb_pts) in host1x_syncpt_alloc()
62 sp->base = host1x_syncpt_base_request(host); in host1x_syncpt_alloc()
63 if (!sp->base) in host1x_syncpt_alloc()
67 name = kasprintf(GFP_KERNEL, "%02u-%s", sp->id, in host1x_syncpt_alloc()
68 client ? dev_name(client->dev) : NULL); in host1x_syncpt_alloc()
72 sp->client = client; in host1x_syncpt_alloc()
73 sp->name = name; in host1x_syncpt_alloc()
76 sp->client_managed = true; in host1x_syncpt_alloc()
78 sp->client_managed = false; in host1x_syncpt_alloc()
80 mutex_unlock(&host->syncpt_mutex); in host1x_syncpt_alloc()
84 host1x_syncpt_base_free(sp->base); in host1x_syncpt_alloc()
85 sp->base = NULL; in host1x_syncpt_alloc()
87 mutex_unlock(&host->syncpt_mutex); in host1x_syncpt_alloc()
92 * host1x_syncpt_id() - retrieve syncpoint ID
95 * Given a pointer to a struct host1x_syncpt, retrieves its ID. This ID is
101 return sp->id; in host1x_syncpt_id()
106 * host1x_syncpt_incr_max() - update the value sent to hardware
112 return (u32)atomic_add_return(incrs, &sp->max_val); in host1x_syncpt_incr_max()
119 void host1x_syncpt_restore(struct host1x *host) in host1x_syncpt_restore() argument
121 struct host1x_syncpt *sp_base = host->syncpt; in host1x_syncpt_restore()
124 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) in host1x_syncpt_restore()
125 host1x_hw_syncpt_restore(host, sp_base + i); in host1x_syncpt_restore()
127 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) in host1x_syncpt_restore()
128 host1x_hw_syncpt_restore_wait_base(host, sp_base + i); in host1x_syncpt_restore()
137 void host1x_syncpt_save(struct host1x *host) in host1x_syncpt_save() argument
139 struct host1x_syncpt *sp_base = host->syncpt; in host1x_syncpt_save()
142 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) { in host1x_syncpt_save()
144 host1x_hw_syncpt_load(host, sp_base + i); in host1x_syncpt_save()
149 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) in host1x_syncpt_save()
150 host1x_hw_syncpt_load_wait_base(host, sp_base + i); in host1x_syncpt_save()
161 val = host1x_hw_syncpt_load(sp->host, sp); in host1x_syncpt_load()
162 trace_host1x_syncpt_load_min(sp->id, val); in host1x_syncpt_load()
172 host1x_hw_syncpt_load_wait_base(sp->host, sp); in host1x_syncpt_load_wait_base()
174 return sp->base_val; in host1x_syncpt_load_wait_base()
178 * host1x_syncpt_incr() - increment syncpoint value from CPU, updating cache
183 return host1x_hw_syncpt_cpu_incr(sp->host, sp); in host1x_syncpt_incr()
193 host1x_hw_syncpt_load(sp->host, sp); in syncpt_load_min_is_expired()
199 * host1x_syncpt_wait() - wait for a syncpoint to reach a given value
226 val = host1x_hw_syncpt_load(sp->host, sp); in host1x_syncpt_wait()
235 err = -EAGAIN; in host1x_syncpt_wait()
242 err = -ENOMEM; in host1x_syncpt_wait()
247 err = host1x_intr_add_action(sp->host, sp, thresh, in host1x_syncpt_wait()
253 err = -EAGAIN; in host1x_syncpt_wait()
254 /* Caller-specified timeout may be impractically low */ in host1x_syncpt_wait()
280 timeout -= check; in host1x_syncpt_wait()
283 dev_warn(sp->host->dev, in host1x_syncpt_wait()
284 "%s: syncpoint id %u (%s) stuck waiting %d, timeout=%ld\n", in host1x_syncpt_wait()
285 current->comm, sp->id, sp->name, in host1x_syncpt_wait()
288 host1x_debug_dump_syncpts(sp->host); in host1x_syncpt_wait()
291 host1x_debug_dump(sp->host); in host1x_syncpt_wait()
297 host1x_intr_put_ref(sp->host, sp->id, ref); in host1x_syncpt_wait()
314 current_val = (u32)atomic_read(&sp->min_val); in host1x_syncpt_is_expired()
315 future_val = (u32)atomic_read(&sp->max_val); in host1x_syncpt_is_expired()
326 * Dtf = (f - t) in host1x_syncpt_is_expired()
327 * Dtc = (c - t) in host1x_syncpt_is_expired()
353 * Note: do NOT get clever and remove the -thresh from both sides. It in host1x_syncpt_is_expired()
360 return future_val - thresh >= current_val - thresh; in host1x_syncpt_is_expired()
362 return (s32)(current_val - thresh) >= 0; in host1x_syncpt_is_expired()
365 int host1x_syncpt_init(struct host1x *host) in host1x_syncpt_init() argument
371 syncpt = devm_kcalloc(host->dev, host->info->nb_pts, sizeof(*syncpt), in host1x_syncpt_init()
374 return -ENOMEM; in host1x_syncpt_init()
376 bases = devm_kcalloc(host->dev, host->info->nb_bases, sizeof(*bases), in host1x_syncpt_init()
379 return -ENOMEM; in host1x_syncpt_init()
381 for (i = 0; i < host->info->nb_pts; i++) { in host1x_syncpt_init()
382 syncpt[i].id = i; in host1x_syncpt_init()
383 syncpt[i].host = host; in host1x_syncpt_init()
390 host1x_hw_syncpt_assign_to_channel(host, &syncpt[i], NULL); in host1x_syncpt_init()
393 for (i = 0; i < host->info->nb_bases; i++) in host1x_syncpt_init()
394 bases[i].id = i; in host1x_syncpt_init()
396 mutex_init(&host->syncpt_mutex); in host1x_syncpt_init()
397 host->syncpt = syncpt; in host1x_syncpt_init()
398 host->bases = bases; in host1x_syncpt_init()
400 host1x_syncpt_restore(host); in host1x_syncpt_init()
401 host1x_hw_syncpt_enable_protection(host); in host1x_syncpt_init()
404 host->nop_sp = host1x_syncpt_alloc(host, NULL, 0); in host1x_syncpt_init()
405 if (!host->nop_sp) in host1x_syncpt_init()
406 return -ENOMEM; in host1x_syncpt_init()
412 * host1x_syncpt_request() - request a syncpoint
424 struct host1x *host = dev_get_drvdata(client->host->parent); in host1x_syncpt_request() local
426 return host1x_syncpt_alloc(host, client, flags); in host1x_syncpt_request()
431 * host1x_syncpt_free() - free a requested syncpoint
445 mutex_lock(&sp->host->syncpt_mutex); in host1x_syncpt_free()
447 host1x_syncpt_base_free(sp->base); in host1x_syncpt_free()
448 kfree(sp->name); in host1x_syncpt_free()
449 sp->base = NULL; in host1x_syncpt_free()
450 sp->client = NULL; in host1x_syncpt_free()
451 sp->name = NULL; in host1x_syncpt_free()
452 sp->client_managed = false; in host1x_syncpt_free()
454 mutex_unlock(&sp->host->syncpt_mutex); in host1x_syncpt_free()
458 void host1x_syncpt_deinit(struct host1x *host) in host1x_syncpt_deinit() argument
460 struct host1x_syncpt *sp = host->syncpt; in host1x_syncpt_deinit()
463 for (i = 0; i < host->info->nb_pts; i++, sp++) in host1x_syncpt_deinit()
464 kfree(sp->name); in host1x_syncpt_deinit()
468 * host1x_syncpt_read_max() - read maximum syncpoint value
478 return (u32)atomic_read(&sp->max_val); in host1x_syncpt_read_max()
483 * host1x_syncpt_read_min() - read minimum syncpoint value
493 return (u32)atomic_read(&sp->min_val); in host1x_syncpt_read_min()
498 * host1x_syncpt_read() - read the current syncpoint value
507 unsigned int host1x_syncpt_nb_pts(struct host1x *host) in host1x_syncpt_nb_pts() argument
509 return host->info->nb_pts; in host1x_syncpt_nb_pts()
512 unsigned int host1x_syncpt_nb_bases(struct host1x *host) in host1x_syncpt_nb_bases() argument
514 return host->info->nb_bases; in host1x_syncpt_nb_bases()
517 unsigned int host1x_syncpt_nb_mlocks(struct host1x *host) in host1x_syncpt_nb_mlocks() argument
519 return host->info->nb_mlocks; in host1x_syncpt_nb_mlocks()
523 * host1x_syncpt_get() - obtain a syncpoint by ID
524 * @host: host1x controller
525 * @id: syncpoint ID
527 struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, unsigned int id) in host1x_syncpt_get() argument
529 if (id >= host->info->nb_pts) in host1x_syncpt_get()
532 return host->syncpt + id; in host1x_syncpt_get()
537 * host1x_syncpt_get_base() - obtain the wait base associated with a syncpoint
542 return sp ? sp->base : NULL; in host1x_syncpt_get_base()
547 * host1x_syncpt_base_id() - retrieve the ID of a syncpoint wait base
552 return base->id; in host1x_syncpt_base_id()