drivers/gpu/drm/loongson/lsdc_benchmark.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/loongson/lsdc_benchmark.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/loongson/lsdc_benchmark.c- Extension
.c- Size
- 2959 bytes
- Lines
- 135
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_debugfs.hdrm/drm_print.hlsdc_benchmark.hlsdc_drv.hlsdc_gem.hlsdc_ttm.h
Detected Declarations
function lsdc_copy_gtt_to_vram_cpufunction lsdc_copy_vram_to_gtt_cpufunction lsdc_copy_gtt_to_gtt_cpufunction lsdc_benchmark_copyfunction lsdc_show_benchmark_copy
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2023 Loongson Technology Corporation Limited
*/
#include <drm/drm_debugfs.h>
#include <drm/drm_print.h>
#include "lsdc_benchmark.h"
#include "lsdc_drv.h"
#include "lsdc_gem.h"
#include "lsdc_ttm.h"
typedef void (*lsdc_copy_proc_t)(struct lsdc_bo *src_bo,
struct lsdc_bo *dst_bo,
unsigned int size,
int n);
static void lsdc_copy_gtt_to_vram_cpu(struct lsdc_bo *src_bo,
struct lsdc_bo *dst_bo,
unsigned int size,
int n)
{
lsdc_bo_kmap(src_bo);
lsdc_bo_kmap(dst_bo);
while (n--)
memcpy_toio(dst_bo->kptr, src_bo->kptr, size);
lsdc_bo_kunmap(src_bo);
lsdc_bo_kunmap(dst_bo);
}
static void lsdc_copy_vram_to_gtt_cpu(struct lsdc_bo *src_bo,
struct lsdc_bo *dst_bo,
unsigned int size,
int n)
{
lsdc_bo_kmap(src_bo);
lsdc_bo_kmap(dst_bo);
while (n--)
memcpy_fromio(dst_bo->kptr, src_bo->kptr, size);
lsdc_bo_kunmap(src_bo);
lsdc_bo_kunmap(dst_bo);
}
static void lsdc_copy_gtt_to_gtt_cpu(struct lsdc_bo *src_bo,
struct lsdc_bo *dst_bo,
unsigned int size,
int n)
{
lsdc_bo_kmap(src_bo);
lsdc_bo_kmap(dst_bo);
while (n--)
memcpy(dst_bo->kptr, src_bo->kptr, size);
lsdc_bo_kunmap(src_bo);
lsdc_bo_kunmap(dst_bo);
}
static void lsdc_benchmark_copy(struct lsdc_device *ldev,
unsigned int size,
unsigned int n,
u32 src_domain,
u32 dst_domain,
lsdc_copy_proc_t copy_proc,
struct drm_printer *p)
{
struct drm_device *ddev = &ldev->base;
struct lsdc_bo *src_bo;
struct lsdc_bo *dst_bo;
unsigned long start_jiffies;
unsigned long end_jiffies;
unsigned int throughput;
unsigned int time;
src_bo = lsdc_bo_create_kernel_pinned(ddev, src_domain, size);
dst_bo = lsdc_bo_create_kernel_pinned(ddev, dst_domain, size);
start_jiffies = jiffies;
copy_proc(src_bo, dst_bo, size, n);
end_jiffies = jiffies;
lsdc_bo_free_kernel_pinned(src_bo);
lsdc_bo_free_kernel_pinned(dst_bo);
Annotation
- Immediate include surface: `drm/drm_debugfs.h`, `drm/drm_print.h`, `lsdc_benchmark.h`, `lsdc_drv.h`, `lsdc_gem.h`, `lsdc_ttm.h`.
- Detected declarations: `function lsdc_copy_gtt_to_vram_cpu`, `function lsdc_copy_vram_to_gtt_cpu`, `function lsdc_copy_gtt_to_gtt_cpu`, `function lsdc_benchmark_copy`, `function lsdc_show_benchmark_copy`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.