drivers/gpu/drm/vmwgfx/ttm_object.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/ttm_object.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vmwgfx/ttm_object.c- Extension
.c- Size
- 17162 bytes
- Lines
- 668
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
ttm_object.hvmwgfx_drv.hlinux/list.hlinux/spinlock.hlinux/slab.hlinux/atomic.hlinux/module.hlinux/hashtable.h
Detected Declarations
struct ttm_object_filestruct ttm_object_devicestruct ttm_ref_objectfunction ttm_object_file_reffunction ttm_tfile_find_ref_rcufunction hash_for_each_possible_rcufunction ttm_tfile_find_reffunction hash_for_each_possiblefunction ttm_object_file_destroyfunction ttm_object_file_unreffunction ttm_base_object_initfunction ttm_release_basefunction ttm_base_object_unreffunction ttm_base_object_lookup_for_reffunction ttm_ref_object_addfunction __releasesfunction ttm_ref_object_base_unreffunction ttm_object_file_releasefunction ttm_object_device_initfunction ttm_object_device_releasefunction get_dma_buf_unless_doomedfunction ttm_prime_refcount_releasefunction ttm_prime_dmabuf_releasefunction ttm_prime_fd_to_handlefunction ttm_prime_handle_to_fdfunction ttm_prime_object_init
Annotated Snippet
struct ttm_object_file {
struct ttm_object_device *tdev;
spinlock_t lock;
struct list_head ref_list;
DECLARE_HASHTABLE(ref_hash, VMW_TTM_OBJECT_REF_HT_ORDER);
struct kref refcount;
};
/*
* struct ttm_object_device
*
* @object_lock: lock that protects idr.
*
* This is the per-device data structure needed for ttm object management.
*/
struct ttm_object_device {
spinlock_t object_lock;
struct dma_buf_ops ops;
void (*dmabuf_release)(struct dma_buf *dma_buf);
struct idr idr;
};
/*
* struct ttm_ref_object
*
* @hash: Hash entry for the per-file object reference hash.
*
* @head: List entry for the per-file list of ref-objects.
*
* @kref: Ref count.
*
* @obj: Base object this ref object is referencing.
*
* @ref_type: Type of ref object.
*
* This is similar to an idr object, but it also has a hash table entry
* that allows lookup with a pointer to the referenced object as a key. In
* that way, one can easily detect whether a base object is referenced by
* a particular ttm_object_file. It also carries a ref count to avoid creating
* multiple ref objects if a ttm_object_file references the same base
* object more than once.
*/
struct ttm_ref_object {
struct rcu_head rcu_head;
struct vmwgfx_hash_item hash;
struct list_head head;
struct kref kref;
struct ttm_base_object *obj;
struct ttm_object_file *tfile;
};
static void ttm_prime_dmabuf_release(struct dma_buf *dma_buf);
static inline struct ttm_object_file *
ttm_object_file_ref(struct ttm_object_file *tfile)
{
kref_get(&tfile->refcount);
return tfile;
}
static int ttm_tfile_find_ref_rcu(struct ttm_object_file *tfile,
uint64_t key,
struct vmwgfx_hash_item **p_hash)
{
struct vmwgfx_hash_item *hash;
hash_for_each_possible_rcu(tfile->ref_hash, hash, head, key) {
if (hash->key == key) {
*p_hash = hash;
return 0;
}
}
return -EINVAL;
}
static int ttm_tfile_find_ref(struct ttm_object_file *tfile,
uint64_t key,
struct vmwgfx_hash_item **p_hash)
{
struct vmwgfx_hash_item *hash;
hash_for_each_possible(tfile->ref_hash, hash, head, key) {
if (hash->key == key) {
*p_hash = hash;
return 0;
}
}
return -EINVAL;
Annotation
- Immediate include surface: `ttm_object.h`, `vmwgfx_drv.h`, `linux/list.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/atomic.h`, `linux/module.h`, `linux/hashtable.h`.
- Detected declarations: `struct ttm_object_file`, `struct ttm_object_device`, `struct ttm_ref_object`, `function ttm_object_file_ref`, `function ttm_tfile_find_ref_rcu`, `function hash_for_each_possible_rcu`, `function ttm_tfile_find_ref`, `function hash_for_each_possible`, `function ttm_object_file_destroy`, `function ttm_object_file_unref`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.