drivers/gpu/drm/xe/display/xe_display_bo.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/display/xe_display_bo.c
Extension
.c
Size
6237 bytes
Lines
233
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 (XE_IOCTL_DBG(xe, xe_bo_is_vm_bound(bo))) {
			ttm_bo_unreserve(&bo->ttm);
			ret = -EINVAL;
			goto err;
		}
		bo->flags |= XE_BO_FLAG_FORCE_WC;
	}
	ttm_bo_unreserve(&bo->ttm);
	return 0;

err:
	xe_bo_put(bo);
	return ret;
}

static void xe_display_bo_framebuffer_fini(struct drm_gem_object *obj)
{
	struct xe_bo *bo = gem_to_xe_bo(obj);

	if (bo->flags & XE_BO_FLAG_PINNED) {
		/* Unpin our kernel fb first */
		xe_bo_lock(bo, false);
		xe_bo_unpin(bo);
		xe_bo_unlock(bo);
	}
	xe_bo_put(bo);
}

static struct drm_gem_object *
xe_display_bo_framebuffer_lookup(struct drm_device *drm,
				 struct drm_file *filp,
				 const struct drm_mode_fb_cmd2 *mode_cmd)
{
	struct xe_device *xe = to_xe_device(drm);
	struct xe_bo *bo;
	struct drm_gem_object *gem = drm_gem_object_lookup(filp, mode_cmd->handles[0]);

	if (!gem)
		return ERR_PTR(-ENOENT);

	bo = gem_to_xe_bo(gem);
	/* Require vram placement or dma-buf import */
	if (IS_DGFX(xe) &&
	    !xe_bo_can_migrate(bo, XE_PL_VRAM0) &&
	    bo->ttm.type != ttm_bo_type_sg) {
		drm_gem_object_put(gem);
		return ERR_PTR(-EREMOTE);
	}

	return gem;
}

#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
/*
 * FIXME: There shouldn't be any reason to have XE_PAGE_SIZE stride
 * alignment. The same 64 as i915 uses should be fine, and we shouldn't need to
 * have driver specific values. However, dropping the stride alignment to 64
 * leads to underflowing the bo pin count in the atomic cleanup work.
 */
static u32 xe_display_bo_fbdev_pitch_align(u32 stride)
{
	return ALIGN(stride, XE_PAGE_SIZE);
}

bool xe_display_bo_fbdev_prefer_stolen(struct xe_device *xe, unsigned int size)
{
	struct ttm_resource_manager *stolen;

	stolen = ttm_manager_type(&xe->ttm, XE_PL_STOLEN);
	if (!stolen)
		return false;

	if (IS_DGFX(xe))
		return false;

	if (XE_DEVICE_WA(xe, 22019338487_display))
		return false;

	/*
	 * If the FB is too big, just don't use it since fbdev is not very
	 * important and we should probably use that space with FBC or other
	 * features.
	 */
	return stolen->size >= (size * 2) >> PAGE_SHIFT;
}

static struct drm_gem_object *xe_display_bo_fbdev_create(struct drm_device *drm, int size)
{
	struct xe_device *xe = to_xe_device(drm);
	struct xe_bo *obj;

Annotation

Implementation Notes