// SPDX-License-Identifier: MIT /* * Copyright © 2023 Intel Corporation */ #include "xe_drm_client.h" #include <drm/drm_print.h> #include <drm/xe_drm.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/types.h> #include "xe_bo.h" #include "xe_bo_types.h" #include "xe_device_types.h" #include "xe_exec_queue.h" #include "xe_force_wake.h" #include "xe_gt.h" #include "xe_hw_engine.h" #include "xe_pm.h" #include "xe_trace.h" /** * DOC: DRM Client usage stats * * The drm/xe driver implements the DRM client usage stats specification as * documented in :ref:`drm-client-usage-stats`. * * Example of the output showing the implemented key value pairs and entirety of * the currently possible format options: * * :: * * pos: 0 * flags: 0100002 * mnt_id: 26 * ino: 685 * drm-driver: xe * drm-client-id: 3 * drm-pdev: 0000:03:00.0 * drm-total-system: 0 * drm-shared-system: 0 * drm-active-system: 0 * drm-resident-system: 0 * drm-purgeable-system: 0 * drm-total-gtt: 192 KiB * drm-shared-gtt: 0 * drm-active-gtt: 0 * drm-resident-gtt: 192 KiB * drm-total-vram0: 23992 KiB * drm-shared-vram0: 16 MiB * drm-active-vram0: 0 * drm-resident-vram0: 23992 KiB * drm-total-stolen: 0 * drm-shared-stolen: 0 * drm-active-stolen: 0 * drm-resident-stolen: 0 * drm-cycles-rcs: 28257900 * drm-total-cycles-rcs: 7655183225 * drm-cycles-bcs: 0 * drm-total-cycles-bcs: 7655183225 * drm-cycles-vcs: 0 * drm-total-cycles-vcs: 7655183225 * drm-engine-capacity-vcs: 2 * drm-cycles-vecs: 0 * drm-total-cycles-vecs: 7655183225 * drm-engine-capacity-vecs: 2 * drm-cycles-ccs: 0 * drm-total-cycles-ccs: 7655183225 * drm-engine-capacity-ccs: 4 * * Possible `drm-cycles-` key names are: `rcs`, `ccs`, `bcs`, `vcs`, `vecs` and * "other". */ /** * xe_drm_client_alloc() - Allocate drm client * @void: No arg * * Allocate drm client struct to track client memory against * same till client life. Call this API whenever new client * has opened xe device. * * Return: pointer to client struct or NULL if can't allocate */ struct xe_drm_client *xe_drm_client_alloc(void) { … } /** * __xe_drm_client_free() - Free client struct * @kref: The reference * * This frees client struct. Call this API when xe device is closed * by drm client. * * Return: void */ void __xe_drm_client_free(struct kref *kref) { … } #ifdef CONFIG_PROC_FS /** * xe_drm_client_add_bo() - Add BO for tracking client mem usage * @client: The drm client ptr * @bo: The xe BO ptr * * Add all BO created by individual drm client by calling this function. * This helps in tracking client memory usage. * * Return: void */ void xe_drm_client_add_bo(struct xe_drm_client *client, struct xe_bo *bo) { … } /** * xe_drm_client_remove_bo() - Remove BO for tracking client mem usage * @bo: The xe BO ptr * * Remove all BO removed by individual drm client by calling this function. * This helps in tracking client memory usage. * * Return: void */ void xe_drm_client_remove_bo(struct xe_bo *bo) { … } static void bo_meminfo(struct xe_bo *bo, struct drm_memory_stats stats[TTM_NUM_MEM_TYPES]) { … } static void show_meminfo(struct drm_printer *p, struct drm_file *file) { … } static void show_run_ticks(struct drm_printer *p, struct drm_file *file) { … } /** * xe_drm_client_fdinfo() - Callback for fdinfo interface * @p: The drm_printer ptr * @file: The drm_file ptr * * This is callabck for drm fdinfo interface. Register this callback * in drm driver ops for show_fdinfo. * * Return: void */ void xe_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file) { … } #endif