drivers/gpu/drm/xe/xe_drm_client.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_drm_client.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_drm_client.c
Extension
.c
Size
10004 bytes
Lines
402
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (dma_resv_trylock(bo->ttm.base.resv)) {
			bo_meminfo(bo, stats);
			xe_bo_unlock(bo);
		} else {
			xe_bo_get(bo);
			spin_unlock(&file->table_lock);

			xe_bo_lock(bo, false);
			bo_meminfo(bo, stats);
			xe_bo_unlock(bo);

			xe_bo_put(bo);
			spin_lock(&file->table_lock);
		}
	}
	spin_unlock(&file->table_lock);

	/* Internal objects. */
	spin_lock(&client->bos_lock);
	list_for_each_entry(bo, &client->bos_list, client_link) {
		if (!kref_get_unless_zero(&bo->ttm.base.refcount))
			continue;

		if (dma_resv_trylock(bo->ttm.base.resv)) {
			bo_meminfo(bo, stats);
			xe_bo_unlock(bo);
		} else {
			spin_unlock(&client->bos_lock);

			xe_bo_lock(bo, false);
			bo_meminfo(bo, stats);
			xe_bo_unlock(bo);

			spin_lock(&client->bos_lock);
			/* The bo ref will prevent this bo from being removed from the list */
			xe_assert(xef->xe, !list_empty(&bo->client_link));
		}

		xe_bo_put_deferred(bo, &deferred);
	}
	spin_unlock(&client->bos_lock);

	xe_bo_put_commit(&deferred);

	for (mem_type = XE_PL_SYSTEM; mem_type < TTM_NUM_MEM_TYPES; ++mem_type) {
		if (!xe_mem_type_to_name[mem_type])
			continue;

		man = ttm_manager_type(bdev, mem_type);

		if (man) {
			drm_print_memory_stats(p,
					       &stats[mem_type],
					       DRM_GEM_OBJECT_ACTIVE |
					       DRM_GEM_OBJECT_RESIDENT |
					       (mem_type != XE_PL_SYSTEM ? 0 :
					       DRM_GEM_OBJECT_PURGEABLE),
					       xe_mem_type_to_name[mem_type]);
		}
	}
}

static struct xe_hw_engine *any_engine(struct xe_device *xe)
{
	struct xe_gt *gt;
	unsigned long gt_id;

	for_each_gt(gt, xe, gt_id) {
		struct xe_hw_engine *hwe = xe_gt_any_hw_engine(gt);

		if (hwe)
			return hwe;
	}

	return NULL;
}

/*
 * Pick any engine and grab its forcewake.  On error phwe will be NULL and
 * the returned forcewake reference will be invalid.  Callers should check
 * phwe against NULL.
 */
static struct xe_force_wake_ref force_wake_get_any_engine(struct xe_device *xe,
							  struct xe_hw_engine **phwe)
{
	enum xe_force_wake_domains domain;
	struct xe_force_wake_ref fw_ref = {};
	struct xe_hw_engine *hwe;

	*phwe = NULL;

Annotation

Implementation Notes