drivers/gpu/drm/i915/gem/selftests/i915_gem_client_blt.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/i915/gem/selftests/i915_gem_client_blt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/i915/gem/selftests/i915_gem_client_blt.c- Extension
.c- Size
- 17582 bytes
- Lines
- 747
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_print.hi915_selftest.hdisplay/intel_display_device.hgt/intel_context.hgt/intel_engine_regs.hgt/intel_engine_user.hgt/intel_gpu_commands.hgt/intel_gt.hgt/intel_gt_regs.hgem/i915_gem_lmem.hgem/selftests/igt_gem_utils.hselftests/igt_flush_test.hselftests/mock_drm.hselftests/i915_random.hhuge_gem_object.hmock_context.h
Detected Declarations
struct blit_bufferstruct tiled_blitsenum client_tilingfunction linear_x_y_to_ftiled_posfunction fastblit_supports_x_tilingfunction fast_blit_okfunction prepare_blitfunction tiled_blits_destroy_buffersfunction __create_vmafunction tiled_blits_create_buffersfunction fill_scratchfunction swizzle_bitfunction tiled_offsetfunction verify_bufferfunction pin_bufferfunction tiled_blitfunction tiled_blits_createfunction tiled_blits_destroyfunction tiled_blits_preparefunction tiled_blits_bouncefunction __igt_client_tiled_blitsfunction has_bit17_swizzlefunction bad_swizzlingfunction igt_client_tiled_blitsfunction i915_gem_client_blt_live_selftests
Annotated Snippet
struct blit_buffer {
struct i915_vma *vma;
u32 start_val;
enum client_tiling tiling;
};
struct tiled_blits {
struct intel_context *ce;
struct blit_buffer buffers[3];
struct blit_buffer scratch;
struct i915_vma *batch;
u64 hole;
u64 align;
u32 width;
u32 height;
};
static bool fastblit_supports_x_tiling(const struct drm_i915_private *i915)
{
struct intel_display *display = i915->display;
int gen = GRAPHICS_VER(i915);
/* XY_FAST_COPY_BLT does not exist on pre-gen9 platforms */
drm_WARN_ON(&i915->drm, gen < 9);
if (gen < 12)
return true;
if (GRAPHICS_VER_FULL(i915) < IP_VER(12, 55))
return false;
return intel_display_device_present(display);
}
static bool fast_blit_ok(const struct blit_buffer *buf)
{
/* XY_FAST_COPY_BLT does not exist on pre-gen9 platforms */
if (GRAPHICS_VER(buf->vma->vm->i915) < 9)
return false;
/* filter out platforms with unsupported X-tile support in fastblit */
if (buf->tiling == CLIENT_TILING_X && !fastblit_supports_x_tiling(buf->vma->vm->i915))
return false;
return true;
}
static int prepare_blit(const struct tiled_blits *t,
struct blit_buffer *dst,
struct blit_buffer *src,
struct drm_i915_gem_object *batch)
{
const int ver = GRAPHICS_VER(to_i915(batch->base.dev));
bool use_64b_reloc = ver >= 8;
u32 src_pitch, dst_pitch;
u32 cmd, *cs;
cs = i915_gem_object_pin_map_unlocked(batch, I915_MAP_WC);
if (IS_ERR(cs))
return PTR_ERR(cs);
if (fast_blit_ok(dst) && fast_blit_ok(src)) {
struct intel_gt *gt = t->ce->engine->gt;
u32 src_tiles = 0, dst_tiles = 0;
u32 src_4t = 0, dst_4t = 0;
/* Need to program BLIT_CCTL if it is not done previously
* before using XY_FAST_COPY_BLT
*/
*cs++ = MI_LOAD_REGISTER_IMM(1);
*cs++ = i915_mmio_reg_offset(BLIT_CCTL(t->ce->engine->mmio_base));
*cs++ = (BLIT_CCTL_SRC_MOCS(gt->mocs.uc_index) |
BLIT_CCTL_DST_MOCS(gt->mocs.uc_index));
src_pitch = t->width; /* in dwords */
if (src->tiling == CLIENT_TILING_Y) {
src_tiles = XY_FAST_COPY_BLT_D0_SRC_TILE_MODE(YMAJOR);
if (GRAPHICS_VER_FULL(to_i915(batch->base.dev)) >= IP_VER(12, 55))
src_4t = XY_FAST_COPY_BLT_D1_SRC_TILE4;
} else if (src->tiling == CLIENT_TILING_X) {
src_tiles = XY_FAST_COPY_BLT_D0_SRC_TILE_MODE(TILE_X);
} else {
src_pitch *= 4; /* in bytes */
}
dst_pitch = t->width; /* in dwords */
if (dst->tiling == CLIENT_TILING_Y) {
dst_tiles = XY_FAST_COPY_BLT_D0_DST_TILE_MODE(YMAJOR);
if (GRAPHICS_VER_FULL(to_i915(batch->base.dev)) >= IP_VER(12, 55))
dst_4t = XY_FAST_COPY_BLT_D1_DST_TILE4;
Annotation
- Immediate include surface: `drm/drm_print.h`, `i915_selftest.h`, `display/intel_display_device.h`, `gt/intel_context.h`, `gt/intel_engine_regs.h`, `gt/intel_engine_user.h`, `gt/intel_gpu_commands.h`, `gt/intel_gt.h`.
- Detected declarations: `struct blit_buffer`, `struct tiled_blits`, `enum client_tiling`, `function linear_x_y_to_ftiled_pos`, `function fastblit_supports_x_tiling`, `function fast_blit_ok`, `function prepare_blit`, `function tiled_blits_destroy_buffers`, `function __create_vma`, `function tiled_blits_create_buffers`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.