1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright © 2023 Intel Corporation 4 */ 5 6 #include <drm/drm_drv.h> 7 #include <drm/drm_kunit_helpers.h> 8 9 #include <kunit/test.h> 10 11 #include "tests/xe_test.h" 12 13 #include "xe_device.h" 14 #include "xe_pci_test.h" 15 #include "xe_pci_types.h" 16 17 static void check_graphics_ip(struct kunit *test) 18 { 19 const struct xe_ip *param = test->param_value; 20 const struct xe_graphics_desc *graphics = param->desc; 21 u64 mask = graphics->hw_engine_mask; 22 23 /* RCS, CCS, and BCS engines are allowed on the graphics IP */ 24 mask &= ~(XE_HW_ENGINE_RCS_MASK | 25 XE_HW_ENGINE_CCS_MASK | 26 XE_HW_ENGINE_BCS_MASK); 27 28 /* Any remaining engines are an error */ 29 KUNIT_ASSERT_EQ(test, mask, 0); 30 } 31 32 static void check_media_ip(struct kunit *test) 33 { 34 const struct xe_ip *param = test->param_value; 35 const struct xe_media_desc *media = param->desc; 36 u64 mask = media->hw_engine_mask; 37 38 /* VCS, VECS and GSCCS engines are allowed on the media IP */ 39 mask &= ~(XE_HW_ENGINE_VCS_MASK | 40 XE_HW_ENGINE_VECS_MASK | 41 XE_HW_ENGINE_GSCCS_MASK); 42 43 /* Any remaining engines are an error */ 44 KUNIT_ASSERT_EQ(test, mask, 0); 45 } 46 47 static struct kunit_case xe_pci_tests[] = { 48 KUNIT_CASE_PARAM(check_graphics_ip, xe_pci_graphics_ip_gen_param), 49 KUNIT_CASE_PARAM(check_media_ip, xe_pci_media_ip_gen_param), 50 {} 51 }; 52 53 static struct kunit_suite xe_pci_test_suite = { 54 .name = "xe_pci", 55 .test_cases = xe_pci_tests, 56 }; 57 58 kunit_test_suite(xe_pci_test_suite); 59