diff options
Diffstat (limited to 'mali_kbase/tests/mali_kutf_irq_test/mali_kutf_irq_test_main.c')
-rw-r--r-- | mali_kbase/tests/mali_kutf_irq_test/mali_kutf_irq_test_main.c | 91 |
1 files changed, 44 insertions, 47 deletions
diff --git a/mali_kbase/tests/mali_kutf_irq_test/mali_kutf_irq_test_main.c b/mali_kbase/tests/mali_kutf_irq_test/mali_kutf_irq_test_main.c index f2a014d..c0d4671 100644 --- a/mali_kbase/tests/mali_kutf_irq_test/mali_kutf_irq_test_main.c +++ b/mali_kbase/tests/mali_kutf_irq_test/mali_kutf_irq_test_main.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note /* * - * (C) COPYRIGHT 2016-2018, 2020-2022 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2016-2023 ARM Limited. All rights reserved. * * This program is free software and is provided to you under the terms of the * GNU General Public License version 2 as published by the Free Software @@ -51,58 +51,58 @@ struct kutf_irq_fixture_data { struct kbase_device *kbdev; }; -/* ID for the GPU IRQ */ -#define GPU_IRQ_HANDLER 2 +/* Tag for GPU IRQ */ +#define GPU_IRQ_TAG 2 #define NR_TEST_IRQS ((u32)1000000) -/* IRQ for the test to trigger. Currently POWER_CHANGED_SINGLE as it is - * otherwise unused in the DDK - */ -#define TEST_IRQ POWER_CHANGED_SINGLE - #define IRQ_TIMEOUT HZ -/* Kernel API for setting irq throttle hook callback and irq time in us*/ -extern int kbase_set_custom_irq_handler(struct kbase_device *kbdev, - irq_handler_t custom_handler, - int irq_type); -extern irqreturn_t kbase_gpu_irq_test_handler(int irq, void *data, u32 val); +static void *kbase_untag(void *ptr) +{ + return (void *)(((uintptr_t)ptr) & ~(uintptr_t)3); +} static DECLARE_WAIT_QUEUE_HEAD(wait); static bool triggered; static u64 irq_time; -static void *kbase_untag(void *ptr) -{ - return (void *)(((uintptr_t) ptr) & ~3); -} - /** * kbase_gpu_irq_custom_handler - Custom IRQ throttle handler * @irq: IRQ number * @data: Data associated with this IRQ * - * Return: state of the IRQ + * Return: IRQ_HANDLED if any interrupt has been handled. IRQ_NONE otherwise. */ static irqreturn_t kbase_gpu_irq_custom_handler(int irq, void *data) { struct kbase_device *kbdev = kbase_untag(data); - u32 val = kbase_reg_read(kbdev, GPU_CONTROL_REG(GPU_IRQ_STATUS)); + u32 status_reg_enum = GPU_CONTROL_ENUM(GPU_IRQ_STATUS); + u32 clear_reg_enum = GPU_CONTROL_ENUM(GPU_IRQ_CLEAR); + u32 test_irq = POWER_CHANGED_SINGLE; + u32 val = kbase_reg_read32(kbdev, status_reg_enum); irqreturn_t result; u64 tval; - bool has_test_irq = val & TEST_IRQ; + bool has_test_irq = val & test_irq; + if (has_test_irq) { tval = ktime_get_real_ns(); /* Clear the test source only here */ - kbase_reg_write(kbdev, GPU_CONTROL_REG(GPU_IRQ_CLEAR), - TEST_IRQ); + kbase_reg_write32(kbdev, clear_reg_enum, test_irq); /* Remove the test IRQ status bit */ - val = val ^ TEST_IRQ; + val = val ^ test_irq; } - result = kbase_gpu_irq_test_handler(irq, data, val); + if (!val) + result = IRQ_NONE; + else { +#if IS_ENABLED(CONFIG_MALI_REAL_HW) + dev_dbg(kbdev->dev, "%s: irq %d irqstatus 0x%x\n", __func__, irq, val); + kbase_gpu_interrupt(kbdev, val); +#endif + result = IRQ_HANDLED; + } if (has_test_irq) { irq_time = tval; @@ -121,13 +121,11 @@ static irqreturn_t kbase_gpu_irq_custom_handler(int irq, void *data) * * Return: Fixture data created on success or NULL on failure */ -static void *mali_kutf_irq_default_create_fixture( - struct kutf_context *context) +static void *mali_kutf_irq_default_create_fixture(struct kutf_context *context) { struct kutf_irq_fixture_data *data; - data = kutf_mempool_alloc(&context->fixture_pool, - sizeof(struct kutf_irq_fixture_data)); + data = kutf_mempool_alloc(&context->fixture_pool, sizeof(struct kutf_irq_fixture_data)); if (!data) goto fail; @@ -151,8 +149,7 @@ fail: * * @context: KUTF context. */ -static void mali_kutf_irq_default_remove_fixture( - struct kutf_context *context) +static void mali_kutf_irq_default_remove_fixture(struct kutf_context *context) { struct kutf_irq_fixture_data *data = context->fixture; struct kbase_device *kbdev = data->kbdev; @@ -185,17 +182,17 @@ static void mali_kutf_irq_latency(struct kutf_context *context) kbase_pm_context_active(kbdev); kbase_pm_wait_for_desired_state(kbdev); - kbase_set_custom_irq_handler(kbdev, kbase_gpu_irq_custom_handler, - GPU_IRQ_HANDLER); + kbase_set_custom_irq_handler(kbdev, kbase_gpu_irq_custom_handler, GPU_IRQ_TAG); for (i = 1; i <= NR_TEST_IRQS; i++) { u64 start_time = ktime_get_real_ns(); + u32 reg_enum = GPU_CONTROL_ENUM(GPU_IRQ_RAWSTAT); + u32 test_irq = POWER_CHANGED_SINGLE; triggered = false; /* Trigger fake IRQ */ - kbase_reg_write(kbdev, GPU_CONTROL_REG(GPU_IRQ_RAWSTAT), - TEST_IRQ); + kbase_reg_write32(kbdev, reg_enum, test_irq); if (wait_event_timeout(wait, triggered, IRQ_TIMEOUT) == 0) { /* Wait extra time to see if it would come */ @@ -218,20 +215,22 @@ static void mali_kutf_irq_latency(struct kutf_context *context) } /* Go back to default handler */ - kbase_set_custom_irq_handler(kbdev, NULL, GPU_IRQ_HANDLER); + kbase_set_custom_irq_handler(kbdev, NULL, GPU_IRQ_TAG); kbase_pm_context_idle(kbdev); if (i > NR_TEST_IRQS) { do_div(average_time, NR_TEST_IRQS); - results = kutf_dsprintf(&context->fixture_pool, - "Min latency = %lldns, Max latency = %lldns, Average latency = %lldns\n", - min_time, max_time, average_time); + results = kutf_dsprintf( + &context->fixture_pool, + "Min latency = %lldns, Max latency = %lldns, Average latency = %lldns\n", + min_time, max_time, average_time); kutf_test_pass(context, results); } else { - results = kutf_dsprintf(&context->fixture_pool, - "Timed out for the %u-th IRQ (loop_limit: %u), triggered late: %d\n", - i, NR_TEST_IRQS, triggered); + results = kutf_dsprintf( + &context->fixture_pool, + "Timed out for the %u-th IRQ (loop_limit: %u), triggered late: %d\n", i, + NR_TEST_IRQS, triggered); kutf_test_fail(context, results); } } @@ -252,9 +251,8 @@ static int __init mali_kutf_irq_test_main_init(void) return -ENOMEM; } - suite = kutf_create_suite(irq_app, "irq_default", - 1, mali_kutf_irq_default_create_fixture, - mali_kutf_irq_default_remove_fixture); + suite = kutf_create_suite(irq_app, "irq_default", 1, mali_kutf_irq_default_create_fixture, + mali_kutf_irq_default_remove_fixture); if (suite == NULL) { pr_warn("Creation of test suite failed!\n"); @@ -262,8 +260,7 @@ static int __init mali_kutf_irq_test_main_init(void) return -ENOMEM; } - kutf_add_test(suite, 0x0, "irq_latency", - mali_kutf_irq_latency); + kutf_add_test(suite, 0x0, "irq_latency", mali_kutf_irq_latency); return 0; } |