drivers/gpu/host1x/channel.c
Source file repositories/reference/linux-study-clean/drivers/gpu/host1x/channel.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/host1x/channel.c- Extension
.c- Size
- 4507 bytes
- Lines
- 186
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/module.hchannel.hdev.hjob.h
Detected Declarations
function Copyrightfunction host1x_channel_list_freefunction host1x_job_submitfunction host1x_channel_get_indexfunction host1x_channel_stopfunction host1x_channel_stop_allfunction release_channelfunction host1x_channel_putfunction host1x_channel_requestexport host1x_job_submitexport host1x_channel_getexport host1x_channel_stopexport host1x_channel_putexport host1x_channel_request
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Tegra host1x Channel
*
* Copyright (c) 2010-2013, NVIDIA Corporation.
*/
#include <linux/slab.h>
#include <linux/module.h>
#include "channel.h"
#include "dev.h"
#include "job.h"
/* Constructor for the host1x device list */
int host1x_channel_list_init(struct host1x_channel_list *chlist,
unsigned int num_channels)
{
chlist->channels = kzalloc_objs(struct host1x_channel, num_channels);
if (!chlist->channels)
return -ENOMEM;
chlist->allocated_channels = bitmap_zalloc(num_channels, GFP_KERNEL);
if (!chlist->allocated_channels) {
kfree(chlist->channels);
return -ENOMEM;
}
mutex_init(&chlist->lock);
return 0;
}
void host1x_channel_list_free(struct host1x_channel_list *chlist)
{
bitmap_free(chlist->allocated_channels);
kfree(chlist->channels);
}
int host1x_job_submit(struct host1x_job *job)
{
struct host1x *host = dev_get_drvdata(job->channel->dev->parent);
return host1x_hw_channel_submit(host, job);
}
EXPORT_SYMBOL(host1x_job_submit);
struct host1x_channel *host1x_channel_get(struct host1x_channel *channel)
{
kref_get(&channel->refcount);
return channel;
}
EXPORT_SYMBOL(host1x_channel_get);
/**
* host1x_channel_get_index() - Attempt to get channel reference by index
* @host: Host1x device object
* @index: Index of channel
*
* If channel number @index is currently allocated, increase its refcount
* and return a pointer to it. Otherwise, return NULL.
*/
struct host1x_channel *host1x_channel_get_index(struct host1x *host,
unsigned int index)
{
struct host1x_channel *ch = &host->channel_list.channels[index];
if (!kref_get_unless_zero(&ch->refcount))
return NULL;
return ch;
}
void host1x_channel_stop(struct host1x_channel *channel)
{
struct host1x *host = dev_get_drvdata(channel->dev->parent);
host1x_hw_cdma_stop(host, &channel->cdma);
}
EXPORT_SYMBOL(host1x_channel_stop);
/**
* host1x_channel_stop_all() - disable CDMA on allocated channels
* @host: host1x instance
*
* Stop CDMA on allocated channels
*/
void host1x_channel_stop_all(struct host1x *host)
{
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `channel.h`, `dev.h`, `job.h`.
- Detected declarations: `function Copyright`, `function host1x_channel_list_free`, `function host1x_job_submit`, `function host1x_channel_get_index`, `function host1x_channel_stop`, `function host1x_channel_stop_all`, `function release_channel`, `function host1x_channel_put`, `function host1x_channel_request`, `export host1x_job_submit`.
- 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.