head	1.2;
access;
symbols
	netbsd-11-0-RC4:1.1.1.11
	netbsd-11-0-RC3:1.1.1.11
	netbsd-11-0-RC2:1.1.1.11
	netbsd-11-0-RC1:1.1.1.11
	netbsd-11:1.1.1.11.0.4
	netbsd-11-base:1.1.1.11
	libdrm-2-4-124:1.1.1.11
	netbsd-10-1-RELEASE:1.1.1.11
	libdrm-2-4-122:1.1.1.11
	netbsd-8-3-RELEASE:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.6
	netbsd-10-0-RELEASE:1.1.1.11
	netbsd-10-0-RC6:1.1.1.11
	netbsd-10-0-RC5:1.1.1.11
	netbsd-10-0-RC4:1.1.1.11
	netbsd-10-0-RC3:1.1.1.11
	netbsd-10-0-RC2:1.1.1.11
	netbsd-10-0-RC1:1.1.1.11
	netbsd-10:1.1.1.11.0.2
	netbsd-10-base:1.1.1.11
	libdrm-2-4-114:1.1.1.11
	netbsd-9-3-RELEASE:1.1.1.6
	libdrm-2-4-112:1.1.1.10
	libdrm-2-4-109:1.1.1.9
	libdrm-2-4-107:1.1.1.9
	netbsd-9-2-RELEASE:1.1.1.6
	libdrm-2-4-105:1.1.1.8
	libdrm-2-4-102:1.1.1.7
	netbsd-9-1-RELEASE:1.1.1.6
	netbsd-8-2-RELEASE:1.1.1.2
	libdrm-2-4-100:1.1.1.6
	netbsd-9-0-RELEASE:1.1.1.6
	netbsd-9-0-RC2:1.1.1.6
	netbsd-9-0-RC1:1.1.1.6
	netbsd-9:1.1.1.6.0.2
	netbsd-9-base:1.1.1.6
	libdrm-2-4-99:1.1.1.6
	netbsd-8-1-RELEASE:1.1.1.2
	netbsd-8-1-RC1:1.1.1.2
	libdrm-2-4-97:1.1.1.5
	libdrm-2-4-96:1.1.1.5
	netbsd-8-0-RELEASE:1.1.1.2
	netbsd-8-0-RC2:1.1.1.2
	netbsd-8-0-RC1:1.1.1.2
	libdrm-2-4-91:1.1.1.4
	libdrm-2-4-83:1.1.1.3
	netbsd-8:1.1.1.2.0.2
	netbsd-8-base:1.1.1.2
	libdrm-2-4-75:1.1.1.2
	libdrm-2-4-70:1.1.1.1
	xorg:1.1.1;
locks; strict;
comment	@ * @;


1.2
date	2026.06.10.05.27.44;	author mrg;	state dead;
branches;
next	1.1;
commitid	OkSNQummCTEKcdJG;

1.1
date	2016.08.17.02.14.50;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	sjjkW0DDGfxalBiz;

1.1.1.1
date	2016.08.17.02.14.50;	author mrg;	state Exp;
branches;
next	1.1.1.2;
commitid	sjjkW0DDGfxalBiz;

1.1.1.2
date	2017.03.04.23.15.51;	author mrg;	state Exp;
branches;
next	1.1.1.3;
commitid	KFj0R3BffyGbVhIz;

1.1.1.3
date	2017.08.29.06.30.18;	author mrg;	state Exp;
branches;
next	1.1.1.4;
commitid	SwkxfytMMoJtD45A;

1.1.1.4
date	2018.03.14.07.18.37;	author mrg;	state Exp;
branches;
next	1.1.1.5;
commitid	vKK7pL0psl9szouA;

1.1.1.5
date	2019.01.10.08.49.54;	author mrg;	state Exp;
branches;
next	1.1.1.6;
commitid	XNB5UWAmSCOUmd7B;

1.1.1.6
date	2019.07.15.05.42.03;	author mrg;	state Exp;
branches;
next	1.1.1.7;
commitid	fTEuGipA3XuNl6vB;

1.1.1.7
date	2020.11.01.09.51.26;	author mrg;	state Exp;
branches;
next	1.1.1.8;
commitid	af86gKDNccMIsauC;

1.1.1.8
date	2021.04.27.03.01.49;	author mrg;	state Exp;
branches;
next	1.1.1.9;
commitid	bnhxFHsntjvsvSQC;

1.1.1.9
date	2021.07.11.00.27.20;	author mrg;	state Exp;
branches;
next	1.1.1.10;
commitid	ssF6uXIaLv20fv0D;

1.1.1.10
date	2022.07.11.19.19.23;	author mrg;	state Exp;
branches;
next	1.1.1.11;
commitid	wjQfX0qND1IWLvLD;

1.1.1.11
date	2022.11.12.02.04.42;	author mrg;	state Exp;
branches;
next	;
commitid	fMjFZZt1HqTR3m1E;


desc
@@


1.2
log
@merge libdrm 2.4.134
@
text
@/*
 * Copyright 2014 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
*/

#ifndef _AMDGPU_TEST_H_
#define _AMDGPU_TEST_H_

#include "amdgpu.h"
#include "amdgpu_drm.h"

/**
 * Define max. number of card in system which we are able to handle
 */
#define MAX_CARDS_SUPPORTED     4

/* Forward reference for array to keep "drm" handles */
extern int drm_amdgpu[MAX_CARDS_SUPPORTED];

/*************************  Basic test suite ********************************/

/*
 * Define basic test suite to serve as the starting point for future testing
*/

/**
 * Initialize basic test suite
 */
int suite_basic_tests_init();

/**
 * Deinitialize basic test suite
 */
int suite_basic_tests_clean();

/**
 * Tests in basic test suite
 */
extern CU_TestInfo basic_tests[];

/**
 * Initialize bo test suite
 */
int suite_bo_tests_init();

/**
 * Deinitialize bo test suite
 */
int suite_bo_tests_clean();

/**
 * Tests in bo test suite
 */
extern CU_TestInfo bo_tests[];

/**
 * Initialize cs test suite
 */
int suite_cs_tests_init();

/**
 * Deinitialize cs test suite
 */
int suite_cs_tests_clean();

/**
 * Tests in cs test suite
 */
extern CU_TestInfo cs_tests[];

/**
 * Initialize vce test suite
 */
int suite_vce_tests_init();

/**
 * Deinitialize vce test suite
 */
int suite_vce_tests_clean();

/**
 * Tests in vce test suite
 */
extern CU_TestInfo vce_tests[];

/**
 * Helper functions
 */
static inline amdgpu_bo_handle gpu_mem_alloc(
					amdgpu_device_handle device_handle,
					uint64_t size,
					uint64_t alignment,
					uint32_t type,
					uint64_t flags,
					uint64_t *vmc_addr,
					amdgpu_va_handle *va_handle)
{
	struct amdgpu_bo_alloc_request req = {0};
	amdgpu_bo_handle buf_handle;
	int r;

	CU_ASSERT_NOT_EQUAL(vmc_addr, NULL);

	req.alloc_size = size;
	req.phys_alignment = alignment;
	req.preferred_heap = type;
	req.flags = flags;

	r = amdgpu_bo_alloc(device_handle, &req, &buf_handle);
	CU_ASSERT_EQUAL(r, 0);

	r = amdgpu_va_range_alloc(device_handle,
				  amdgpu_gpu_va_range_general,
				  size, alignment, 0, vmc_addr,
				  va_handle, 0);
	CU_ASSERT_EQUAL(r, 0);

	r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0, AMDGPU_VA_OP_MAP);
	CU_ASSERT_EQUAL(r, 0);

	return buf_handle;
}

static inline int gpu_mem_free(amdgpu_bo_handle bo,
			       amdgpu_va_handle va_handle,
			       uint64_t vmc_addr,
			       uint64_t size)
{
	int r;

	r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);
	CU_ASSERT_EQUAL(r, 0);

	r = amdgpu_va_range_free(va_handle);
	CU_ASSERT_EQUAL(r, 0);

	r = amdgpu_bo_free(bo);
	CU_ASSERT_EQUAL(r, 0);

	return 0;
}

static inline int
amdgpu_bo_alloc_and_map(amdgpu_device_handle dev, unsigned size,
			unsigned alignment, unsigned heap, uint64_t flags,
			amdgpu_bo_handle *bo, void **cpu, uint64_t *mc_address,
			amdgpu_va_handle *va_handle)
{
	struct amdgpu_bo_alloc_request request = {};
	amdgpu_bo_handle buf_handle;
	amdgpu_va_handle handle;
	uint64_t vmc_addr;
	int r;

	request.alloc_size = size;
	request.phys_alignment = alignment;
	request.preferred_heap = heap;
	request.flags = flags;

	r = amdgpu_bo_alloc(dev, &request, &buf_handle);
	if (r)
		return r;

	r = amdgpu_va_range_alloc(dev,
				  amdgpu_gpu_va_range_general,
				  size, alignment, 0, &vmc_addr,
				  &handle, 0);
	if (r)
		goto error_va_alloc;

	r = amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_MAP);
	if (r)
		goto error_va_map;

	r = amdgpu_bo_cpu_map(buf_handle, cpu);
	if (r)
		goto error_cpu_map;

	*bo = buf_handle;
	*mc_address = vmc_addr;
	*va_handle = handle;

	return 0;

error_cpu_map:
	amdgpu_bo_cpu_unmap(buf_handle);

error_va_map:
	amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP);

error_va_alloc:
	amdgpu_bo_free(buf_handle);
	return r;
}

static inline int
amdgpu_bo_unmap_and_free(amdgpu_bo_handle bo, amdgpu_va_handle va_handle,
			 uint64_t mc_addr, uint64_t size)
{
	amdgpu_bo_cpu_unmap(bo);
	amdgpu_bo_va_op(bo, 0, size, mc_addr, 0, AMDGPU_VA_OP_UNMAP);
	amdgpu_va_range_free(va_handle);
	amdgpu_bo_free(bo);

	return 0;

}

static inline int
amdgpu_get_bo_list(amdgpu_device_handle dev, amdgpu_bo_handle bo1,
		   amdgpu_bo_handle bo2, amdgpu_bo_list_handle *list)
{
	amdgpu_bo_handle resources[] = {bo1, bo2};

	return amdgpu_bo_list_create(dev, bo2 ? 2 : 1, resources, NULL, list);
}

#endif  /* #ifdef _AMDGPU_TEST_H_ */
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@initial import of libdrm-2.4.70
@
text
@@


1.1.1.2
log
@initial import of libdrm-2.4.75
@
text
@a37 3
/* Global variables */
extern int open_render_node;

@


1.1.1.3
log
@initial import of libdrm-2.4.83
@
text
@a107 30
+ * Initialize vcn test suite
+ */
int suite_vcn_tests_init();

/**
+ * Deinitialize vcn test suite
+ */
int suite_vcn_tests_clean();

/**
+ * Tests in vcn test suite
+ */
extern CU_TestInfo vcn_tests[];

/**
 * Initialize uvd enc test suite
 */
int suite_uvd_enc_tests_init();

/**
 * Deinitialize uvd enc test suite
 */
int suite_uvd_enc_tests_clean();

/**
 * Tests in uvd enc test suite
 */
extern CU_TestInfo uvd_enc_tests[];

/**
@


1.1.1.4
log
@initial import of libdrm-2.4.91
@
text
@a87 5
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_cs_tests_enable(void);

/**
a102 5
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_vce_tests_enable(void);

/**
a117 5
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_vcn_tests_enable(void);

/**
a132 5
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_uvd_enc_tests_enable(void);

/**
a137 40
 * Initialize deadlock test suite
 */
int suite_deadlock_tests_init();

/**
 * Deinitialize deadlock test suite
 */
int suite_deadlock_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_deadlock_tests_enable(void);

/**
 * Tests in uvd enc test suite
 */
extern CU_TestInfo deadlock_tests[];

/**
 * Initialize vm test suite
 */
int suite_vm_tests_init();

/**
 * Deinitialize deadlock test suite
 */
int suite_vm_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_vm_tests_enable(void);

/**
 * Tests in vm test suite
 */
extern CU_TestInfo vm_tests[];

/**
a194 23
amdgpu_bo_alloc_wrap(amdgpu_device_handle dev, unsigned size,
		     unsigned alignment, unsigned heap, uint64_t flags,
		     amdgpu_bo_handle *bo)
{
	struct amdgpu_bo_alloc_request request = {};
	amdgpu_bo_handle buf_handle;
	int r;

	request.alloc_size = size;
	request.phys_alignment = alignment;
	request.preferred_heap = heap;
	request.flags = flags;

	r = amdgpu_bo_alloc(dev, &request, &buf_handle);
	if (r)
		return r;

	*bo = buf_handle;

	return 0;
}

static inline int
a268 31

static inline CU_ErrorCode amdgpu_set_suite_active(const char *suite_name,
							  CU_BOOL active)
{
	CU_ErrorCode r = CU_set_suite_active(CU_get_suite(suite_name), active);

	if (r != CUE_SUCCESS)
		fprintf(stderr, "Failed to obtain suite %s\n", suite_name);

	return r;
}

static inline CU_ErrorCode amdgpu_set_test_active(const char *suite_name,
				  const char *test_name, CU_BOOL active)
{
	CU_ErrorCode r;
	CU_pSuite pSuite = CU_get_suite(suite_name);

	if (!pSuite) {
		fprintf(stderr, "Failed to obtain suite %s\n",
				suite_name);
		return CUE_NOSUITE;
	}

	r = CU_set_test_active(CU_get_test(pSuite, test_name), active);
	if (r != CUE_SUCCESS)
		fprintf(stderr, "Failed to obtain test %s\n", test_name);

	return r;
}

@


1.1.1.5
log
@initial import of libdrm-2.4.96
@
text
@d33 1
a33 1
#define MAX_CARDS_SUPPORTED     128
d210 1
a210 1
	amdgpu_bo_handle buf_handle = NULL;
d213 2
a221 18
	if (r)
		return NULL;

	if (vmc_addr && va_handle) {
		r = amdgpu_va_range_alloc(device_handle,
					  amdgpu_gpu_va_range_general,
					  size, alignment, 0, vmc_addr,
					  va_handle, 0);
		CU_ASSERT_EQUAL(r, 0);
		if (r)
			goto error_free_bo;

		r = amdgpu_bo_va_op(buf_handle, 0, size, *vmc_addr, 0,
				    AMDGPU_VA_OP_MAP);
		CU_ASSERT_EQUAL(r, 0);
		if (r)
			goto error_free_va;
	}
d223 4
a226 4
	return buf_handle;

error_free_va:
	r = amdgpu_va_range_free(*va_handle);
d229 1
a229 2
error_free_bo:
	r = amdgpu_bo_free(buf_handle);
d232 1
a232 1
	return NULL;
d242 2
a243 2
	if (!bo)
		return 0;
d245 2
a246 12
	if (va_handle) {
		r = amdgpu_bo_va_op(bo, 0, size, vmc_addr, 0,
				    AMDGPU_VA_OP_UNMAP);
		CU_ASSERT_EQUAL(r, 0);
		if (r)
			return r;

		r = amdgpu_va_range_free(va_handle);
		CU_ASSERT_EQUAL(r, 0);
		if (r)
			return r;
	}
d251 1
a251 1
	return r;
a276 6
int amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size,
			unsigned alignment, unsigned heap, uint64_t alloc_flags,
			uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu,
			uint64_t *mc_address,
			amdgpu_va_handle *va_handle);

d279 1
a279 1
			unsigned alignment, unsigned heap, uint64_t alloc_flags,
d283 45
a327 2
	return amdgpu_bo_alloc_and_map_raw(dev, size, alignment, heap,
					alloc_flags, 0, bo, cpu, mc_address, va_handle);
@


1.1.1.6
log
@initial import of libdrm-2.4.99
@
text
@a196 43

/**
 * Initialize ras test suite
 */
int suite_ras_tests_init();

/**
 * Deinitialize deadlock test suite
 */
int suite_ras_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_ras_tests_enable(void);

/**
 * Tests in ras test suite
 */
extern CU_TestInfo ras_tests[];


/**
 * Initialize syncobj timeline test suite
 */
int suite_syncobj_timeline_tests_init();

/**
 * Deinitialize syncobj timeline test suite
 */
int suite_syncobj_timeline_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_syncobj_timeline_tests_enable(void);

/**
 * Tests in syncobj timeline test suite
 */
extern CU_TestInfo syncobj_timeline_tests[];


@


1.1.1.7
log
@initial import of libdrm-2.4.102
@
text
@a238 5
void amdgpu_dispatch_hang_helper(amdgpu_device_handle device_handle, uint32_t ip_type);
void amdgpu_dispatch_hang_slow_helper(amdgpu_device_handle device_handle, uint32_t ip_type);
void amdgpu_memcpy_draw_test(amdgpu_device_handle device_handle, uint32_t ring,
			     int hang);
void amdgpu_memcpy_draw_hang_slow_test(amdgpu_device_handle device_handle, uint32_t ring);
@


1.1.1.8
log
@initial import of libdrm-2.4.105
@
text
@a57 5
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_basic_tests_enable(void);

/**
a245 26
 * Initialize security test suite
 */
int suite_security_tests_init();

/**
 * Deinitialize security test suite
 */
int suite_security_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_security_tests_enable(void);

/**
 * Tests in security test suite
 */
extern CU_TestInfo security_tests[];

extern void
amdgpu_command_submission_write_linear_helper_with_secure(amdgpu_device_handle
							  device,
							  unsigned ip_type,
							  bool secure);

/**
a420 22
static inline bool asic_is_arcturus(uint32_t asic_id)
{
	switch(asic_id) {
	/* Arcturus asic DID */
	case 0x738C:
	case 0x7388:
	case 0x738E:
		return true;
	default:
		return false;
	}
}

void amdgpu_test_exec_cs_helper_raw(amdgpu_device_handle device_handle,
				    amdgpu_context_handle context_handle,
				    unsigned ip_type, int instance, int pm4_dw,
				    uint32_t *pm4_src, int res_cnt,
				    amdgpu_bo_handle *resources,
				    struct amdgpu_cs_ib_info *ib_info,
				    struct amdgpu_cs_request *ibs_request,
				    bool secure);

@


1.1.1.9
log
@initial import of libdrm-2.4.107
@
text
@a275 23


/**
 * Initialize hotunplug test suite
 */
int suite_hotunplug_tests_init();

/**
 * Deinitialize hotunplug test suite
 */
int suite_hotunplug_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_hotunplug_tests_enable(void);

/**
 * Tests in uvd enc test suite
 */
extern CU_TestInfo hotunplug_tests[];


d452 1
a452 2

static inline bool asic_is_gfx_pipe_removed(uint32_t family_id, uint32_t chip_id, uint32_t chip_rev)
d454 5
a458 9

	if (family_id != AMDGPU_FAMILY_AI)
	return false;

	switch (chip_id - chip_rev) {
	/* Arcturus */
	case 0x32:
	/* Aldebaran */
	case 0x3c:
a473 4
void amdgpu_close_devices();
int amdgpu_open_device_on_test_index(int render_node);
char *amdgpu_get_device_from_fd(int fd);

@


1.1.1.10
log
@initial import of libdrm-2.4.112
@
text
@a142 20
+ * Initialize jpeg test suite
+ */
int suite_jpeg_tests_init();

/**
+ * Deinitialize jpeg test suite
+ */
int suite_jpeg_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_jpeg_tests_enable(void);

/**
+ * Tests in vcn test suite
+ */
extern CU_TestInfo jpeg_tests[];

/**
a243 21

/**
 * Initialize cp dma test suite
 */
int suite_cp_dma_tests_init();

/**
 * Deinitialize cp dma test suite
 */
int suite_cp_dma_tests_clean();

/**
 * Decide if the suite is enabled by default or not.
 */
CU_BOOL suite_cp_dma_tests_enable(void);

/**
 * Tests in cp dma test suite
 */
extern CU_TestInfo cp_dma_tests[];

d247 2
a248 2
			     int version, int hang);
void amdgpu_memcpy_draw_hang_slow_test(amdgpu_device_handle device_handle, uint32_t ring, int version);
@


1.1.1.11
log
@initial import of libdrm-2.4.114
@
text
@d285 6
d317 1
a317 6
extern void amdgpu_test_dispatch_helper(amdgpu_device_handle device_handle, unsigned ip);
extern void amdgpu_test_dispatch_hang_helper(amdgpu_device_handle device_handle, uint32_t ip);
extern void amdgpu_test_dispatch_hang_slow_helper(amdgpu_device_handle device_handle, uint32_t ip);
extern void amdgpu_test_draw_helper(amdgpu_device_handle device_handle);
extern void amdgpu_test_draw_hang_helper(amdgpu_device_handle device_handle);
extern void amdgpu_test_draw_hang_slow_helper(amdgpu_device_handle device_handle);
@


