.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note |
---|
2 | 2 | /* |
---|
3 | 3 | * |
---|
4 | | - * (C) COPYRIGHT 2020-2021 ARM Limited. All rights reserved. |
---|
| 4 | + * (C) COPYRIGHT 2020-2022 ARM Limited. All rights reserved. |
---|
5 | 5 | * |
---|
6 | 6 | * This program is free software and is provided to you under the terms of the |
---|
7 | 7 | * GNU General Public License version 2 as published by the Free Software |
---|
.. | .. |
---|
51 | 51 | address); |
---|
52 | 52 | if (multiple) |
---|
53 | 53 | dev_warn(kbdev->dev, "There were multiple GPU faults - some have not been reported\n"); |
---|
| 54 | + |
---|
54 | 55 | } |
---|
55 | 56 | |
---|
56 | 57 | void kbase_gpu_interrupt(struct kbase_device *kbdev, u32 val) |
---|
.. | .. |
---|
62 | 63 | if (val & RESET_COMPLETED) |
---|
63 | 64 | kbase_pm_reset_done(kbdev); |
---|
64 | 65 | |
---|
| 66 | + /* Defer clearing CLEAN_CACHES_COMPLETED to kbase_clean_caches_done. |
---|
| 67 | + * We need to acquire hwaccess_lock to avoid a race condition with |
---|
| 68 | + * kbase_gpu_cache_flush_and_busy_wait |
---|
| 69 | + */ |
---|
| 70 | + KBASE_KTRACE_ADD(kbdev, CORE_GPU_IRQ_CLEAR, NULL, val & ~CLEAN_CACHES_COMPLETED); |
---|
| 71 | + kbase_reg_write(kbdev, GPU_CONTROL_REG(GPU_IRQ_CLEAR), val & ~CLEAN_CACHES_COMPLETED); |
---|
| 72 | + |
---|
| 73 | + /* kbase_instr_hwcnt_sample_done frees the HWCNT pipeline to request another |
---|
| 74 | + * sample. Therefore this must be called after clearing the IRQ to avoid a |
---|
| 75 | + * race between clearing and the next sample raising the IRQ again. |
---|
| 76 | + */ |
---|
65 | 77 | if (val & PRFCNT_SAMPLE_COMPLETED) |
---|
66 | 78 | kbase_instr_hwcnt_sample_done(kbdev); |
---|
67 | | - |
---|
68 | | - KBASE_KTRACE_ADD(kbdev, CORE_GPU_IRQ_CLEAR, NULL, val); |
---|
69 | | - kbase_reg_write(kbdev, GPU_CONTROL_REG(GPU_IRQ_CLEAR), val); |
---|
70 | 79 | |
---|
71 | 80 | /* kbase_pm_check_transitions (called by kbase_pm_power_changed) must |
---|
72 | 81 | * be called after the IRQ has been cleared. This is because it might |
---|
.. | .. |
---|
96 | 105 | |
---|
97 | 106 | KBASE_KTRACE_ADD(kbdev, CORE_GPU_IRQ_DONE, NULL, val); |
---|
98 | 107 | } |
---|
| 108 | + |
---|
| 109 | +#if IS_ENABLED(CONFIG_MALI_REAL_HW) |
---|
| 110 | +void kbase_reg_write(struct kbase_device *kbdev, u32 offset, u32 value) |
---|
| 111 | +{ |
---|
| 112 | + WARN_ON(!kbdev->pm.backend.gpu_powered); |
---|
| 113 | + |
---|
| 114 | + writel(value, kbdev->reg + offset); |
---|
| 115 | + |
---|
| 116 | +#if IS_ENABLED(CONFIG_DEBUG_FS) |
---|
| 117 | + if (unlikely(kbdev->io_history.enabled)) |
---|
| 118 | + kbase_io_history_add(&kbdev->io_history, kbdev->reg + offset, |
---|
| 119 | + value, 1); |
---|
| 120 | +#endif /* CONFIG_DEBUG_FS */ |
---|
| 121 | + dev_dbg(kbdev->dev, "w: reg %08x val %08x", offset, value); |
---|
| 122 | +} |
---|
| 123 | +KBASE_EXPORT_TEST_API(kbase_reg_write); |
---|
| 124 | + |
---|
| 125 | +u32 kbase_reg_read(struct kbase_device *kbdev, u32 offset) |
---|
| 126 | +{ |
---|
| 127 | + u32 val; |
---|
| 128 | + |
---|
| 129 | + WARN_ON(!kbdev->pm.backend.gpu_powered); |
---|
| 130 | + |
---|
| 131 | + val = readl(kbdev->reg + offset); |
---|
| 132 | + |
---|
| 133 | +#if IS_ENABLED(CONFIG_DEBUG_FS) |
---|
| 134 | + if (unlikely(kbdev->io_history.enabled)) |
---|
| 135 | + kbase_io_history_add(&kbdev->io_history, kbdev->reg + offset, |
---|
| 136 | + val, 0); |
---|
| 137 | +#endif /* CONFIG_DEBUG_FS */ |
---|
| 138 | + dev_dbg(kbdev->dev, "r: reg %08x val %08x", offset, val); |
---|
| 139 | + |
---|
| 140 | + return val; |
---|
| 141 | +} |
---|
| 142 | +KBASE_EXPORT_TEST_API(kbase_reg_read); |
---|
| 143 | +#endif /* IS_ENABLED(CONFIG_MALI_REAL_HW) */ |
---|