接前一篇文章:KWin、libdrm、DRM从上到下全过程 —— drmModeAddFBxxx(28)
上回书理清了drm_gem_open函数的调用脉络,本回开始对其进行深入解析。
在解析drm_gem_open函数之前,对于调用它的函数drm_file_alloc()是很有必要先进行简单讲解的。再次贴出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 *file;
int ret;
file = kzall