| 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 "xe_device.h" |
| 12 | #include "xe_kunit_helpers.h" |
| 13 | #include "xe_pci_test.h" |
| 14 | #include "xe_reg_sr.h" |
| 15 | #include "xe_tuning.h" |
| 16 | #include "xe_wa.h" |
| 17 | |
| 18 | static int xe_wa_test_init(struct kunit *test) |
| 19 | { |
| 20 | const struct xe_pci_fake_data *param = test->param_value; |
| 21 | struct xe_pci_fake_data data = *param; |
| 22 | struct xe_device *xe; |
| 23 | struct device *dev; |
| 24 | int ret; |
| 25 | |
| 26 | dev = drm_kunit_helper_alloc_device(test); |
| 27 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); |
| 28 | |
| 29 | xe = xe_kunit_helper_alloc_xe_device(test, dev); |
| 30 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xe); |
| 31 | |
| 32 | test->priv = &data; |
| 33 | ret = xe_pci_fake_device_init(xe); |
| 34 | KUNIT_ASSERT_EQ(test, ret, 0); |
| 35 | |
| 36 | if (!param->graphics_verx100) |
| 37 | xe->info.step = param->step; |
| 38 | |
| 39 | /* TODO: init hw engines for engine/LRC WAs */ |
| 40 | xe->drm.dev = dev; |
| 41 | test->priv = xe; |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | static void xe_wa_gt(struct kunit *test) |
| 47 | { |
| 48 | struct xe_device *xe = test->priv; |
| 49 | struct xe_gt *gt; |
| 50 | int id; |
| 51 | |
| 52 | for_each_gt(gt, xe, id) { |
| 53 | xe_reg_sr_init(sr: >->reg_sr, name: "GT" , xe); |
| 54 | |
| 55 | xe_wa_process_gt(gt); |
| 56 | xe_tuning_process_gt(gt); |
| 57 | |
| 58 | KUNIT_ASSERT_EQ(test, gt->reg_sr.errors, 0); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | static struct kunit_case xe_wa_tests[] = { |
| 63 | KUNIT_CASE_PARAM(xe_wa_gt, xe_pci_fake_data_gen_params), |
| 64 | {} |
| 65 | }; |
| 66 | |
| 67 | static struct kunit_suite xe_rtp_test_suite = { |
| 68 | .name = "xe_wa" , |
| 69 | .init = xe_wa_test_init, |
| 70 | .test_cases = xe_wa_tests, |
| 71 | }; |
| 72 | |
| 73 | kunit_test_suite(xe_rtp_test_suite); |
| 74 | |