drivers/gpu/drm/i915/i915_drm_client.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/i915_drm_client.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/i915_drm_client.c- Extension
.c- Size
- 5631 bytes
- Lines
- 221
- 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
linux/kernel.hlinux/slab.hlinux/types.huapi/drm/i915_drm.hdrm/drm_print.hgem/i915_gem_context.hi915_drm_client.hi915_file_private.hi915_gem.hi915_utils.h
Detected Declarations
function __i915_drm_client_freefunction obj_meminfofunction show_meminfofunction busy_addfunction for_each_gem_enginefunction show_client_classfunction i915_drm_client_fdinfofunction i915_drm_client_add_objectfunction i915_drm_client_remove_objectfunction i915_drm_client_add_context_objects
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright © 2020 Intel Corporation
*/
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <uapi/drm/i915_drm.h>
#include <drm/drm_print.h>
#include "gem/i915_gem_context.h"
#include "i915_drm_client.h"
#include "i915_file_private.h"
#include "i915_gem.h"
#include "i915_utils.h"
struct i915_drm_client *i915_drm_client_alloc(void)
{
struct i915_drm_client *client;
client = kzalloc_obj(*client);
if (!client)
return NULL;
kref_init(&client->kref);
spin_lock_init(&client->ctx_lock);
INIT_LIST_HEAD(&client->ctx_list);
#ifdef CONFIG_PROC_FS
spin_lock_init(&client->objects_lock);
INIT_LIST_HEAD(&client->objects_list);
#endif
return client;
}
void __i915_drm_client_free(struct kref *kref)
{
struct i915_drm_client *client =
container_of(kref, typeof(*client), kref);
kfree(client);
}
#ifdef CONFIG_PROC_FS
static void
obj_meminfo(struct drm_i915_gem_object *obj,
struct drm_memory_stats stats[INTEL_REGION_UNKNOWN])
{
const enum intel_region_id id = obj->mm.region ?
obj->mm.region->id : INTEL_REGION_SMEM;
const u64 sz = obj->base.size;
if (drm_gem_object_is_shared_for_memory_stats(&obj->base))
stats[id].shared += sz;
else
stats[id].private += sz;
if (i915_gem_object_has_pages(obj)) {
stats[id].resident += sz;
if (!dma_resv_test_signaled(obj->base.resv,
DMA_RESV_USAGE_BOOKKEEP))
stats[id].active += sz;
else if (i915_gem_object_is_shrinkable(obj) &&
obj->mm.madv == I915_MADV_DONTNEED)
stats[id].purgeable += sz;
}
}
static void show_meminfo(struct drm_printer *p, struct drm_file *file)
{
struct drm_memory_stats stats[INTEL_REGION_UNKNOWN] = {};
struct drm_i915_file_private *fpriv = file->driver_priv;
struct i915_drm_client *client = fpriv->client;
struct drm_i915_private *i915 = fpriv->i915;
struct drm_i915_gem_object *obj;
struct intel_memory_region *mr;
struct list_head __rcu *pos;
unsigned int id;
/* Public objects. */
spin_lock(&file->table_lock);
idr_for_each_entry(&file->object_idr, obj, id)
obj_meminfo(obj, stats);
spin_unlock(&file->table_lock);
/* Internal objects. */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/types.h`, `uapi/drm/i915_drm.h`, `drm/drm_print.h`, `gem/i915_gem_context.h`, `i915_drm_client.h`, `i915_file_private.h`.
- Detected declarations: `function __i915_drm_client_free`, `function obj_meminfo`, `function show_meminfo`, `function busy_add`, `function for_each_gem_engine`, `function show_client_class`, `function i915_drm_client_fdinfo`, `function i915_drm_client_add_object`, `function i915_drm_client_remove_object`, `function i915_drm_client_add_context_objects`.
- 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.