1/* SPDX-License-Identifier: MIT */ 2/* 3 * Copyright �� 2023 Intel Corporation 4 */ 5 6#ifndef _XE_DRM_CLIENT_H_ 7#define _XE_DRM_CLIENT_H_ 8 9#include <linux/kref.h> 10#include <linux/list.h> 11#include <linux/pid.h> 12#include <linux/rcupdate.h> 13#include <linux/sched.h> 14#include <linux/spinlock.h> 15 16struct drm_file; 17struct drm_printer; 18struct xe_bo; 19 20struct xe_drm_client { 21 struct kref kref; 22 unsigned int id; 23#ifdef CONFIG_PROC_FS 24 /** 25 * @bos_lock: lock protecting @bos_list 26 */ 27 spinlock_t bos_lock; 28 /** 29 * @bos_list: list of bos created by this client 30 * 31 * Protected by @bos_lock. 32 */ 33 struct list_head bos_list; 34#endif 35}; 36 37 static inline struct xe_drm_client * 38xe_drm_client_get(struct xe_drm_client *client) 39{ 40 kref_get(&client->kref); 41 return client; 42} 43 44void __xe_drm_client_free(struct kref *kref); 45 46static inline void xe_drm_client_put(struct xe_drm_client *client) 47{ 48 kref_put(&client->kref, __xe_drm_client_free); 49} 50 51struct xe_drm_client *xe_drm_client_alloc(void); 52static inline struct xe_drm_client * 53xe_drm_client_get(struct xe_drm_client *client); 54static inline void xe_drm_client_put(struct xe_drm_client *client); 55#ifdef CONFIG_PROC_FS 56void xe_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file); 57void xe_drm_client_add_bo(struct xe_drm_client *client, 58 struct xe_bo *bo); 59void xe_drm_client_remove_bo(struct xe_bo *bo); 60#else 61static inline void xe_drm_client_add_bo(struct xe_drm_client *client, 62 struct xe_bo *bo) 63{ 64} 65 66static inline void xe_drm_client_remove_bo(struct xe_bo *bo) 67{ 68} 69#endif 70#endif 71