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

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/display/xe_initial_plane.c
Extension
.c
Size
4215 bytes
Lines
169
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 (!(pte & XE_GGTT_PTE_DM)) {
			drm_err(&xe->drm,
				"Initial plane programming missing DM bit\n");
			return NULL;
		}

		phys_base = pte & ~(page_size - 1);
		flags |= XE_BO_FLAG_VRAM0;

		/*
		 * We don't currently expect this to ever be placed in the
		 * stolen portion.
		 */
		if (phys_base >= xe_vram_region_usable_size(tile0->mem.vram)) {
			drm_err(&xe->drm,
				"Initial plane programming using invalid range, phys_base=%pa\n",
				&phys_base);
			return NULL;
		}

		drm_dbg(&xe->drm,
			"Using phys_base=%pa, based on initial plane programming\n",
			&phys_base);
	} else {
		struct ttm_resource_manager *stolen = ttm_manager_type(&xe->ttm, XE_PL_STOLEN);

		if (!stolen)
			return NULL;
		phys_base = base;
		flags |= XE_BO_FLAG_STOLEN;

		if (IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE) &&
		    IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) &&
		    !xe_display_bo_fbdev_prefer_stolen(xe, plane_config->size)) {
			drm_info(&xe->drm, "Initial FB size exceeds half of stolen, discarding\n");
			return NULL;
		}
	}

	size = round_up(plane_config->base + plane_config->size,
			page_size);
	size -= base;

	bo = xe_bo_create_pin_map_at_novm(xe, tile0, size, phys_base,
					  ttm_bo_type_kernel, flags, 0, false);
	if (IS_ERR(bo)) {
		drm_dbg(&xe->drm,
			"Failed to create bo phys_base=%pa size %u with flags %x: %li\n",
			&phys_base, size, flags, PTR_ERR(bo));
		return NULL;
	}

	return bo;
}

static struct drm_gem_object *
xe_alloc_initial_plane_obj(struct drm_device *drm,
			   struct intel_initial_plane_config *plane_config)
{
	struct xe_device *xe = to_xe_device(drm);
	struct drm_mode_fb_cmd2 mode_cmd = { 0 };
	struct drm_framebuffer *fb = plane_config->fb;
	struct xe_bo *bo;

	mode_cmd.pixel_format = fb->format->format;
	mode_cmd.width = fb->width;
	mode_cmd.height = fb->height;
	mode_cmd.pitches[0] = fb->pitches[0];
	mode_cmd.modifier[0] = fb->modifier;
	mode_cmd.flags = DRM_MODE_FB_MODIFIERS;

	bo = initial_plane_bo(xe, plane_config);
	if (!bo)
		return NULL;

	if (intel_framebuffer_init(to_intel_framebuffer(fb),
				   &bo->ttm.base, fb->format, &mode_cmd)) {
		drm_dbg_kms(&xe->drm, "intel fb init failed\n");
		goto err_bo;
	}
	/* Reference handed over to fb */
	xe_bo_put(bo);

	return &bo->ttm.base;

err_bo:
	xe_bo_unpin_map_no_vm(bo);
	return NULL;
}

Annotation

Implementation Notes