| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * |
|---|
| 4 | | - * (C) COPYRIGHT 2014-2021 ARM Limited. All rights reserved. |
|---|
| 4 | + * (C) COPYRIGHT 2014-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 |
|---|
| .. | .. |
|---|
| 26 | 26 | #include <mali_kbase.h> |
|---|
| 27 | 27 | #include <device/mali_kbase_device.h> |
|---|
| 28 | 28 | #include <backend/gpu/mali_kbase_pm_internal.h> |
|---|
| 29 | +#include <backend/gpu/mali_kbase_cache_policy_backend.h> |
|---|
| 29 | 30 | #include <mali_kbase_hwaccess_gpuprops.h> |
|---|
| 30 | 31 | |
|---|
| 31 | 32 | int kbase_backend_gpuprops_get(struct kbase_device *kbdev, |
|---|
| 32 | 33 | struct kbase_gpuprops_regdump *regdump) |
|---|
| 33 | 34 | { |
|---|
| 34 | 35 | int i; |
|---|
| 35 | | - struct kbase_gpuprops_regdump registers; |
|---|
| 36 | + struct kbase_gpuprops_regdump registers = { 0 }; |
|---|
| 36 | 37 | |
|---|
| 37 | 38 | /* Fill regdump with the content of the relevant registers */ |
|---|
| 38 | 39 | registers.gpu_id = kbase_reg_read(kbdev, GPU_CONTROL_REG(GPU_ID)); |
|---|
| 39 | 40 | |
|---|
| 40 | 41 | registers.l2_features = kbase_reg_read(kbdev, |
|---|
| 41 | 42 | GPU_CONTROL_REG(L2_FEATURES)); |
|---|
| 42 | | - registers.core_features = 0; |
|---|
| 43 | | -#if !MALI_USE_CSF |
|---|
| 44 | | - /* TGOx */ |
|---|
| 45 | | - registers.core_features = kbase_reg_read(kbdev, |
|---|
| 46 | | - GPU_CONTROL_REG(CORE_FEATURES)); |
|---|
| 47 | | -#else /* !MALI_USE_CSF */ |
|---|
| 48 | | - if (((registers.gpu_id & GPU_ID2_PRODUCT_MODEL) == |
|---|
| 49 | | - GPU_ID2_PRODUCT_TGRX) || |
|---|
| 50 | | - ((registers.gpu_id & GPU_ID2_PRODUCT_MODEL) == |
|---|
| 51 | | - GPU_ID2_PRODUCT_TVAX)) |
|---|
| 52 | | - registers.core_features = |
|---|
| 53 | | - kbase_reg_read(kbdev, GPU_CONTROL_REG(CORE_FEATURES)); |
|---|
| 54 | | -#endif /* MALI_USE_CSF */ |
|---|
| 43 | + |
|---|
| 55 | 44 | registers.tiler_features = kbase_reg_read(kbdev, |
|---|
| 56 | 45 | GPU_CONTROL_REG(TILER_FEATURES)); |
|---|
| 57 | 46 | registers.mem_features = kbase_reg_read(kbdev, |
|---|
| .. | .. |
|---|
| 146 | 135 | curr_config_regdump->l2_present_hi = kbase_reg_read(kbdev, |
|---|
| 147 | 136 | GPU_CONTROL_REG(L2_PRESENT_HI)); |
|---|
| 148 | 137 | |
|---|
| 149 | | - if (WARN_ON(kbase_is_gpu_removed(kbdev))) |
|---|
| 138 | + if (kbase_is_gpu_removed(kbdev)) |
|---|
| 150 | 139 | return -EIO; |
|---|
| 151 | 140 | |
|---|
| 152 | 141 | return 0; |
|---|
| .. | .. |
|---|
| 156 | 145 | int kbase_backend_gpuprops_get_features(struct kbase_device *kbdev, |
|---|
| 157 | 146 | struct kbase_gpuprops_regdump *regdump) |
|---|
| 158 | 147 | { |
|---|
| 159 | | - if (kbase_hw_has_feature(kbdev, BASE_HW_FEATURE_COHERENCY_REG)) { |
|---|
| 160 | | - u32 coherency_features; |
|---|
| 148 | + u32 coherency_features; |
|---|
| 149 | + int error = 0; |
|---|
| 161 | 150 | |
|---|
| 162 | | - /* Ensure we can access the GPU registers */ |
|---|
| 163 | | - kbase_pm_register_access_enable(kbdev); |
|---|
| 151 | + /* Ensure we can access the GPU registers */ |
|---|
| 152 | + kbase_pm_register_access_enable(kbdev); |
|---|
| 164 | 153 | |
|---|
| 165 | | - coherency_features = kbase_reg_read(kbdev, |
|---|
| 166 | | - GPU_CONTROL_REG(COHERENCY_FEATURES)); |
|---|
| 154 | + coherency_features = kbase_cache_get_coherency_features(kbdev); |
|---|
| 167 | 155 | |
|---|
| 168 | | - if (kbase_is_gpu_removed(kbdev)) |
|---|
| 169 | | - return -EIO; |
|---|
| 156 | + if (kbase_is_gpu_removed(kbdev)) |
|---|
| 157 | + error = -EIO; |
|---|
| 170 | 158 | |
|---|
| 171 | | - regdump->coherency_features = coherency_features; |
|---|
| 159 | + regdump->coherency_features = coherency_features; |
|---|
| 172 | 160 | |
|---|
| 173 | | - /* We're done accessing the GPU registers for now. */ |
|---|
| 174 | | - kbase_pm_register_access_disable(kbdev); |
|---|
| 175 | | - } else { |
|---|
| 176 | | - /* Pre COHERENCY_FEATURES we only supported ACE_LITE */ |
|---|
| 177 | | - regdump->coherency_features = |
|---|
| 178 | | - COHERENCY_FEATURE_BIT(COHERENCY_NONE) | |
|---|
| 179 | | - COHERENCY_FEATURE_BIT(COHERENCY_ACE_LITE); |
|---|
| 180 | | - } |
|---|
| 161 | + if (kbase_hw_has_feature(kbdev, BASE_HW_FEATURE_CORE_FEATURES)) |
|---|
| 162 | + regdump->core_features = kbase_reg_read(kbdev, GPU_CONTROL_REG(CORE_FEATURES)); |
|---|
| 163 | + else |
|---|
| 164 | + regdump->core_features = 0; |
|---|
| 181 | 165 | |
|---|
| 182 | | - return 0; |
|---|
| 166 | + kbase_pm_register_access_disable(kbdev); |
|---|
| 167 | + |
|---|
| 168 | + return error; |
|---|
| 183 | 169 | } |
|---|
| 184 | 170 | |
|---|
| 185 | 171 | int kbase_backend_gpuprops_get_l2_features(struct kbase_device *kbdev, |
|---|
| .. | .. |
|---|
| 190 | 176 | GPU_CONTROL_REG(L2_FEATURES)); |
|---|
| 191 | 177 | u32 l2_config = |
|---|
| 192 | 178 | kbase_reg_read(kbdev, GPU_CONTROL_REG(L2_CONFIG)); |
|---|
| 179 | + u32 asn_hash[ASN_HASH_COUNT] = { |
|---|
| 180 | + 0, |
|---|
| 181 | + }; |
|---|
| 182 | + int i; |
|---|
| 193 | 183 | |
|---|
| 184 | + if (kbase_hw_has_feature(kbdev, BASE_HW_FEATURE_ASN_HASH)) { |
|---|
| 185 | + for (i = 0; i < ASN_HASH_COUNT; i++) |
|---|
| 186 | + asn_hash[i] = kbase_reg_read( |
|---|
| 187 | + kbdev, GPU_CONTROL_REG(ASN_HASH(i))); |
|---|
| 188 | + } |
|---|
| 194 | 189 | |
|---|
| 195 | 190 | if (kbase_is_gpu_removed(kbdev)) |
|---|
| 196 | 191 | return -EIO; |
|---|
| 197 | 192 | |
|---|
| 198 | 193 | regdump->l2_features = l2_features; |
|---|
| 199 | 194 | regdump->l2_config = l2_config; |
|---|
| 195 | + for (i = 0; i < ASN_HASH_COUNT; i++) |
|---|
| 196 | + regdump->l2_asn_hash[i] = asn_hash[i]; |
|---|
| 200 | 197 | } |
|---|
| 201 | 198 | |
|---|
| 202 | 199 | return 0; |
|---|