drivers/gpu/drm/ttm/tests/ttm_bo_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/ttm/tests/ttm_bo_test.c- Extension
.c- Size
- 16585 bytes
- Lines
- 638
- 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
linux/dma-resv.hlinux/kthread.hlinux/delay.hlinux/timer.hlinux/jiffies.hlinux/mutex.hlinux/ww_mutex.hdrm/ttm/ttm_resource.hdrm/ttm/ttm_placement.hdrm/ttm/ttm_tt.httm_kunit_helpers.h
Detected Declarations
struct ttm_bo_test_casestruct signal_timerfunction ttm_bo_init_case_descfunction ttm_bo_reserve_optimistic_no_ticketfunction ttm_bo_reserve_locked_no_sleepfunction ttm_bo_reserve_no_wait_ticketfunction ttm_bo_reserve_double_resvfunction ww_test_edeadlk_normalfunction signal_for_ttm_bo_reservefunction threaded_ttm_bo_reservefunction ttm_bo_reserve_interruptedfunction ttm_bo_unreserve_basicfunction ttm_bo_unreserve_pinnedfunction ttm_bo_unreserve_bulkfunction ttm_bo_fini_basicfunction ttm_bo_fini_shared_resvfunction ttm_bo_pin_basicfunction ttm_bo_pin_unpin_resourcefunction ttm_bo_multiple_pin_one_unpin
Annotated Snippet
struct ttm_bo_test_case {
const char *description;
bool interruptible;
bool no_wait;
};
static const struct ttm_bo_test_case ttm_bo_reserved_cases[] = {
{
.description = "Cannot be interrupted and sleeps",
.interruptible = false,
.no_wait = false,
},
{
.description = "Cannot be interrupted, locks straight away",
.interruptible = false,
.no_wait = true,
},
{
.description = "Can be interrupted, sleeps",
.interruptible = true,
.no_wait = false,
},
};
static void ttm_bo_init_case_desc(const struct ttm_bo_test_case *t,
char *desc)
{
strscpy(desc, t->description, KUNIT_PARAM_DESC_SIZE);
}
KUNIT_ARRAY_PARAM(ttm_bo_reserve, ttm_bo_reserved_cases, ttm_bo_init_case_desc);
static void ttm_bo_reserve_optimistic_no_ticket(struct kunit *test)
{
const struct ttm_bo_test_case *params = test->param_value;
struct ttm_buffer_object *bo;
int err;
bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
err = ttm_bo_reserve(bo, params->interruptible, params->no_wait, NULL);
KUNIT_ASSERT_EQ(test, err, 0);
dma_resv_unlock(bo->base.resv);
}
static void ttm_bo_reserve_locked_no_sleep(struct kunit *test)
{
struct ttm_buffer_object *bo;
bool interruptible = false;
bool no_wait = true;
int err;
bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
/* Let's lock it beforehand */
dma_resv_lock(bo->base.resv, NULL);
err = ttm_bo_reserve(bo, interruptible, no_wait, NULL);
dma_resv_unlock(bo->base.resv);
KUNIT_ASSERT_EQ(test, err, -EBUSY);
}
static void ttm_bo_reserve_no_wait_ticket(struct kunit *test)
{
struct ttm_buffer_object *bo;
struct ww_acquire_ctx ctx;
bool interruptible = false;
bool no_wait = true;
int err;
ww_acquire_init(&ctx, &reservation_ww_class);
bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
err = ttm_bo_reserve(bo, interruptible, no_wait, &ctx);
KUNIT_ASSERT_EQ(test, err, -EBUSY);
ww_acquire_fini(&ctx);
}
static void ttm_bo_reserve_double_resv(struct kunit *test)
{
struct ttm_buffer_object *bo;
struct ww_acquire_ctx ctx;
bool interruptible = false;
bool no_wait = false;
int err;
Annotation
- Immediate include surface: `linux/dma-resv.h`, `linux/kthread.h`, `linux/delay.h`, `linux/timer.h`, `linux/jiffies.h`, `linux/mutex.h`, `linux/ww_mutex.h`, `drm/ttm/ttm_resource.h`.
- Detected declarations: `struct ttm_bo_test_case`, `struct signal_timer`, `function ttm_bo_init_case_desc`, `function ttm_bo_reserve_optimistic_no_ticket`, `function ttm_bo_reserve_locked_no_sleep`, `function ttm_bo_reserve_no_wait_ticket`, `function ttm_bo_reserve_double_resv`, `function ww_test_edeadlk_normal`, `function signal_for_ttm_bo_reserve`, `function threaded_ttm_bo_reserve`.
- 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.