2015-04-20 10:15:23 -06:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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[];
|
|
|
|
|
2015-05-19 10:51:15 -06:00
|
|
|
/**
|
|
|
|
* 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[];
|
|
|
|
|
2015-04-20 10:15:23 -06:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
struct amdgpu_bo_alloc_request req = {0};
|
|
|
|
struct amdgpu_bo_alloc_result res = {0};
|
|
|
|
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, &res);
|
|
|
|
CU_ASSERT_EQUAL(r, 0);
|
|
|
|
|
|
|
|
CU_ASSERT_NOT_EQUAL(res.virtual_mc_base_address, 0);
|
|
|
|
CU_ASSERT_NOT_EQUAL(res.buf_handle, NULL);
|
|
|
|
*vmc_addr = res.virtual_mc_base_address;
|
|
|
|
return res.buf_handle;
|
|
|
|
}
|
|
|
|
|
2015-06-01 06:12:10 -06:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
struct amdgpu_bo_alloc_request request = {};
|
|
|
|
struct amdgpu_bo_alloc_result out;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
request.alloc_size = size;
|
|
|
|
request.phys_alignment = alignment;
|
|
|
|
request.preferred_heap = heap;
|
|
|
|
request.flags = flags;
|
|
|
|
|
|
|
|
r = amdgpu_bo_alloc(dev, &request, &out);
|
|
|
|
if (r)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = amdgpu_bo_cpu_map(out.buf_handle, cpu);
|
|
|
|
if (r) {
|
|
|
|
amdgpu_bo_free(out.buf_handle);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
*bo = out.buf_handle;
|
|
|
|
*mc_address = out.virtual_mc_base_address;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-02 05:05:41 -06:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-04-20 10:15:23 -06:00
|
|
|
#endif /* #ifdef _AMDGPU_TEST_H_ */
|