1 // SPDX-License-Identifier: MIT 2 /* 3 * Copyright © 2019 Intel Corporation 4 */ 5 6 #include "intel_pm.h" /* intel_gpu_freq() */ 7 #include "selftest_llc.h" 8 #include "intel_rps.h" 9 10 static int gen6_verify_ring_freq(struct intel_llc *llc) 11 { 12 struct drm_i915_private *i915 = llc_to_gt(llc)->i915; 13 struct ia_constants consts; 14 intel_wakeref_t wakeref; 15 unsigned int gpu_freq; 16 int err = 0; 17 18 wakeref = intel_runtime_pm_get(llc_to_gt(llc)->uncore->rpm); 19 20 if (!get_ia_constants(llc, &consts)) 21 goto out_rpm; 22 23 for (gpu_freq = consts.min_gpu_freq; 24 gpu_freq <= consts.max_gpu_freq; 25 gpu_freq++) { 26 struct intel_rps *rps = &llc_to_gt(llc)->rps; 27 28 unsigned int ia_freq, ring_freq, found; 29 u32 val; 30 31 calc_ia_freq(llc, gpu_freq, &consts, &ia_freq, &ring_freq); 32 33 val = gpu_freq; 34 if (sandybridge_pcode_read(i915, 35 GEN6_PCODE_READ_MIN_FREQ_TABLE, 36 &val, NULL)) { 37 pr_err("Failed to read freq table[%d], range [%d, %d]\n", 38 gpu_freq, consts.min_gpu_freq, consts.max_gpu_freq); 39 err = -ENXIO; 40 break; 41 } 42 43 found = (val >> 0) & 0xff; 44 if (found != ia_freq) { 45 pr_err("Min freq table(%d/[%d, %d]):%dMHz did not match expected CPU freq, found %d, expected %d\n", 46 gpu_freq, consts.min_gpu_freq, consts.max_gpu_freq, 47 intel_gpu_freq(rps, gpu_freq * (GRAPHICS_VER(i915) >= 9 ? GEN9_FREQ_SCALER : 1)), 48 found, ia_freq); 49 err = -EINVAL; 50 break; 51 } 52 53 found = (val >> 8) & 0xff; 54 if (found != ring_freq) { 55 pr_err("Min freq table(%d/[%d, %d]):%dMHz did not match expected ring freq, found %d, expected %d\n", 56 gpu_freq, consts.min_gpu_freq, consts.max_gpu_freq, 57 intel_gpu_freq(rps, gpu_freq * (GRAPHICS_VER(i915) >= 9 ? GEN9_FREQ_SCALER : 1)), 58 found, ring_freq); 59 err = -EINVAL; 60 break; 61 } 62 } 63 64 out_rpm: 65 intel_runtime_pm_put(llc_to_gt(llc)->uncore->rpm, wakeref); 66 return err; 67 } 68 69 int st_llc_verify(struct intel_llc *llc) 70 { 71 return gen6_verify_ring_freq(llc); 72 } 73