drivers/gpu/host1x/syncpt.c
Source file repositories/reference/linux-study-clean/drivers/gpu/host1x/syncpt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/host1x/syncpt.c- Extension
.c- Size
- 12526 bytes
- Lines
- 536
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/device.hlinux/dma-fence.hlinux/slab.htrace/events/host1x.hsyncpt.hdev.hintr.hdebug.h
Detected Declarations
function Copyrightfunction host1x_syncpt_base_freefunction host1x_syncpt_allocfunction host1x_syncpt_idfunction host1x_syncpt_incr_maxfunction host1x_syncpt_restorefunction host1x_syncpt_savefunction host1x_syncpt_loadfunction host1x_syncpt_load_wait_basefunction host1x_syncpt_incrfunction host1x_syncpt_waitfunction host1x_syncpt_is_expiredfunction host1x_syncpt_initfunction host1x_syncpt_requestfunction syncpt_releasefunction host1x_syncpt_putfunction host1x_syncpt_deinitfunction host1x_syncpt_read_maxfunction host1x_syncpt_read_minfunction host1x_syncpt_readfunction host1x_syncpt_nb_ptsfunction host1x_syncpt_nb_basesfunction host1x_syncpt_nb_mlocksfunction host1x_syncpt_get_by_idfunction host1x_syncpt_get_by_id_noreffunction host1x_syncpt_getfunction host1x_syncpt_get_basefunction host1x_syncpt_base_idfunction do_nothingexport host1x_syncpt_allocexport host1x_syncpt_idexport host1x_syncpt_incr_maxexport host1x_syncpt_increxport host1x_syncpt_waitexport host1x_syncpt_requestexport host1x_syncpt_putexport host1x_syncpt_read_maxexport host1x_syncpt_read_minexport host1x_syncpt_readexport host1x_syncpt_get_by_idexport host1x_syncpt_get_by_id_norefexport host1x_syncpt_getexport host1x_syncpt_get_baseexport host1x_syncpt_base_idexport host1x_syncpt_release_vblank_reservation
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Tegra host1x Syncpoints
*
* Copyright (c) 2010-2015, NVIDIA Corporation.
*/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/dma-fence.h>
#include <linux/slab.h>
#include <trace/events/host1x.h>
#include "syncpt.h"
#include "dev.h"
#include "intr.h"
#include "debug.h"
#define SYNCPT_CHECK_PERIOD (2 * HZ)
#define MAX_STUCK_CHECK_COUNT 15
static struct host1x_syncpt_base *
host1x_syncpt_base_request(struct host1x *host)
{
struct host1x_syncpt_base *bases = host->bases;
unsigned int i;
for (i = 0; i < host->info->nb_bases; i++)
if (!bases[i].requested)
break;
if (i >= host->info->nb_bases)
return NULL;
bases[i].requested = true;
return &bases[i];
}
static void host1x_syncpt_base_free(struct host1x_syncpt_base *base)
{
if (base)
base->requested = false;
}
/**
* host1x_syncpt_alloc() - allocate a syncpoint
* @host: host1x device data
* @flags: bitfield of HOST1X_SYNCPT_* flags
* @name: name for the syncpoint for use in debug prints
*
* Allocates a hardware syncpoint for the caller's use. The caller then has
* the sole authority to mutate the syncpoint's value until it is freed again.
*
* If no free syncpoints are available, or a NULL name was specified, returns
* NULL.
*/
struct host1x_syncpt *host1x_syncpt_alloc(struct host1x *host,
unsigned long flags,
const char *name)
{
struct host1x_syncpt *sp = host->syncpt;
char *full_name;
unsigned int i;
if (!name)
return NULL;
mutex_lock(&host->syncpt_mutex);
for (i = 0; i < host->info->nb_pts && kref_read(&sp->ref); i++, sp++)
;
if (i >= host->info->nb_pts)
goto unlock;
if (flags & HOST1X_SYNCPT_HAS_BASE) {
sp->base = host1x_syncpt_base_request(host);
if (!sp->base)
goto unlock;
}
full_name = kasprintf(GFP_KERNEL, "%u-%s", sp->id, name);
if (!full_name)
goto free_base;
sp->name = full_name;
if (flags & HOST1X_SYNCPT_CLIENT_MANAGED)
sp->client_managed = true;
Annotation
- Immediate include surface: `linux/module.h`, `linux/device.h`, `linux/dma-fence.h`, `linux/slab.h`, `trace/events/host1x.h`, `syncpt.h`, `dev.h`, `intr.h`.
- Detected declarations: `function Copyright`, `function host1x_syncpt_base_free`, `function host1x_syncpt_alloc`, `function host1x_syncpt_id`, `function host1x_syncpt_incr_max`, `function host1x_syncpt_restore`, `function host1x_syncpt_save`, `function host1x_syncpt_load`, `function host1x_syncpt_load_wait_base`, `function host1x_syncpt_incr`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.