接前一篇文章:KWin、libdrm、DRM从上到下全过程 —— drmModeAddFBxxx(29)
上一回解析了drm_gem_open函数的上游函数drm_file_alloc函数。本回正式开始对于drm_gem_open函数进行解析。为了便于理解,再次贴出drm_file_alloc函数和drm_gem_open函数源码。
drm_file_alloc函数在drivers/gpu/drm/drm_file.c中,代码如下:
/**
* drm_file_alloc - allocate file context
* @minor: minor to allocate on
*
* This allocates a new DRM file context. It is not linked into any context and
* can be used by the caller freely. Note that the context keeps a pointer to
* @minor, so it must be freed before @minor is.
*
* RETURNS:
* Pointer to newly allocated context, ERR_PTR on failure.
*/
struct drm_file *drm_file_alloc(struct drm_minor *minor)
{
struct drm_device *dev = minor->dev;
struct drm_file *fi