Lines Matching +full:spin +full:- +full:up

1 // SPDX-License-Identifier: MIT
25 #define CPU_LATENCY 0 /* -1 to disable pm_qos, 0 to disable cstates */
36 return -1; in cmp_u64()
48 return -1; in cmp_u32()
67 #define CS_GPR(x) GEN8_RING_CS_GPR(engine->mmio_base, x) in create_spin_counter()
75 obj = i915_gem_object_create_internal(vm->i915, 64 << 10); in create_spin_counter()
79 end = obj->base.size / sizeof(u32) - 1; in create_spin_counter()
112 loop = cs - base; in create_spin_counter()
125 *cs++ = lower_32_bits(vma->node.start + end * sizeof(*cs)); in create_spin_counter()
126 *cs++ = upper_32_bits(vma->node.start + end * sizeof(*cs)); in create_spin_counter()
131 *cs++ = lower_32_bits(vma->node.start + loop * sizeof(*cs)); in create_spin_counter()
132 *cs++ = upper_32_bits(vma->node.start + loop * sizeof(*cs)); in create_spin_counter()
133 GEM_BUG_ON(cs - base > end); in create_spin_counter()
189 mutex_lock(&rps->lock); in rps_set_check()
192 mutex_unlock(&rps->lock); in rps_set_check()
195 GEM_BUG_ON(rps->last_freq != freq); in rps_set_check()
196 mutex_unlock(&rps->lock); in rps_set_check()
221 struct intel_rps *rps = &gt->rps; in live_rps_clock_interval()
225 struct igt_spinner spin; in live_rps_clock_interval() local
228 if (!intel_rps_is_enabled(rps) || GRAPHICS_VER(gt->i915) < 6) in live_rps_clock_interval()
231 if (igt_spinner_init(&spin, gt)) in live_rps_clock_interval()
232 return -ENOMEM; in live_rps_clock_interval()
235 saved_work = rps->work.func; in live_rps_clock_interval()
236 rps->work.func = dummy_rps_work; in live_rps_clock_interval()
239 intel_rps_disable(&gt->rps); in live_rps_clock_interval()
253 rq = igt_spinner_create_request(&spin, in live_rps_clock_interval()
254 engine->kernel_context, in live_rps_clock_interval()
264 if (!igt_wait_for_spinner(&spin, rq)) { in live_rps_clock_interval()
266 engine->name); in live_rps_clock_interval()
267 igt_spinner_end(&spin); in live_rps_clock_interval()
269 intel_gt_set_wedged(engine->gt); in live_rps_clock_interval()
270 err = -EIO; in live_rps_clock_interval()
274 intel_uncore_forcewake_get(gt->uncore, FORCEWAKE_ALL); in live_rps_clock_interval()
276 intel_uncore_write_fw(gt->uncore, GEN6_RP_CUR_UP_EI, 0); in live_rps_clock_interval()
279 intel_uncore_write_fw(gt->uncore, in live_rps_clock_interval()
281 intel_uncore_write_fw(gt->uncore, in live_rps_clock_interval()
284 intel_uncore_write_fw(gt->uncore, GEN6_RP_CONTROL, in live_rps_clock_interval()
287 if (wait_for(intel_uncore_read_fw(gt->uncore, in live_rps_clock_interval()
292 engine->name); in live_rps_clock_interval()
293 err = -ENODEV; in live_rps_clock_interval()
303 cycles_[i] = -intel_uncore_read_fw(gt->uncore, GEN6_RP_CUR_UP_EI); in live_rps_clock_interval()
308 cycles_[i] += intel_uncore_read_fw(gt->uncore, GEN6_RP_CUR_UP_EI); in live_rps_clock_interval()
320 intel_uncore_write_fw(gt->uncore, GEN6_RP_CONTROL, 0); in live_rps_clock_interval()
321 intel_uncore_forcewake_put(gt->uncore, FORCEWAKE_ALL); in live_rps_clock_interval()
323 igt_spinner_end(&spin); in live_rps_clock_interval()
332 engine->name, cycles, time, dt, expected, in live_rps_clock_interval()
333 gt->clock_frequency / 1000); in live_rps_clock_interval()
338 engine->name); in live_rps_clock_interval()
339 err = -EINVAL; in live_rps_clock_interval()
345 engine->name); in live_rps_clock_interval()
346 err = -EINVAL; in live_rps_clock_interval()
350 if (igt_flush_test(gt->i915)) in live_rps_clock_interval()
351 err = -EIO; in live_rps_clock_interval()
356 intel_rps_enable(&gt->rps); in live_rps_clock_interval()
359 igt_spinner_fini(&spin); in live_rps_clock_interval()
362 rps->work.func = saved_work; in live_rps_clock_interval()
364 if (err == -ENODEV) /* skipped, don't report a fail */ in live_rps_clock_interval()
373 struct intel_rps *rps = &gt->rps; in live_rps_control()
377 struct igt_spinner spin; in live_rps_control() local
390 if (IS_CHERRYVIEW(gt->i915)) /* XXX fragile PCU */ in live_rps_control()
393 if (igt_spinner_init(&spin, gt)) in live_rps_control()
394 return -ENOMEM; in live_rps_control()
397 saved_work = rps->work.func; in live_rps_control()
398 rps->work.func = dummy_rps_work; in live_rps_control()
412 rq = igt_spinner_create_request(&spin, in live_rps_control()
413 engine->kernel_context, in live_rps_control()
422 if (!igt_wait_for_spinner(&spin, rq)) { in live_rps_control()
424 engine->name); in live_rps_control()
425 igt_spinner_end(&spin); in live_rps_control()
427 intel_gt_set_wedged(engine->gt); in live_rps_control()
428 err = -EIO; in live_rps_control()
432 if (rps_set_check(rps, rps->min_freq) != rps->min_freq) { in live_rps_control()
434 engine->name, rps->min_freq, read_cagf(rps)); in live_rps_control()
435 igt_spinner_end(&spin); in live_rps_control()
438 err = -EINVAL; in live_rps_control()
442 for (f = rps->min_freq + 1; f < rps->max_freq; f++) { in live_rps_control()
449 if (rps_set_check(rps, rps->min_freq) != rps->min_freq) { in live_rps_control()
451 engine->name, rps->min_freq, read_cagf(rps)); in live_rps_control()
452 igt_spinner_end(&spin); in live_rps_control()
455 err = -EINVAL; in live_rps_control()
464 min = rps_set_check(rps, rps->min_freq); in live_rps_control()
467 igt_spinner_end(&spin); in live_rps_control()
471 engine->name, in live_rps_control()
472 rps->min_freq, intel_gpu_freq(rps, rps->min_freq), in live_rps_control()
473 rps->max_freq, intel_gpu_freq(rps, rps->max_freq), in live_rps_control()
477 if (limit == rps->min_freq) { in live_rps_control()
479 engine->name); in live_rps_control()
481 err = -ENODEV; in live_rps_control()
485 if (igt_flush_test(gt->i915)) { in live_rps_control()
486 err = -EIO; in live_rps_control()
492 igt_spinner_fini(&spin); in live_rps_control()
495 rps->work.func = saved_work; in live_rps_control()
510 min_gpu_freq = rps->min_freq; in show_pcu_config()
511 max_gpu_freq = rps->max_freq; in show_pcu_config()
518 wakeref = intel_runtime_pm_get(rps_to_uncore(rps)->rpm); in show_pcu_config()
524 snb_pcode_read(rps_to_gt(rps)->uncore, GEN6_PCODE_READ_MIN_FREQ_TABLE, in show_pcu_config()
533 intel_runtime_pm_put(rps_to_uncore(rps)->rpm, wakeref); in show_pcu_config()
543 dc = READ_ONCE(*cntr) - dc; in __measure_frequency()
544 dt = ktime_get() - dt; in __measure_frequency()
570 dc = intel_uncore_read_fw(engine->uncore, CS_GPR(0)); in __measure_cs_frequency()
572 dc = intel_uncore_read_fw(engine->uncore, CS_GPR(0)) - dc; in __measure_cs_frequency()
573 dt = ktime_get() - dt; in __measure_cs_frequency()
604 struct intel_rps *rps = &gt->rps; in live_rps_frequency_cs()
619 if (GRAPHICS_VER(gt->i915) < 8) /* for CS simplicity */ in live_rps_frequency_cs()
626 saved_work = rps->work.func; in live_rps_frequency_cs()
627 rps->work.func = dummy_rps_work; in live_rps_frequency_cs()
641 engine->kernel_context->vm, false, in live_rps_frequency_cs()
655 err = i915_request_await_object(rq, vma->obj, false); in live_rps_frequency_cs()
659 err = rq->engine->emit_bb_start(rq, in live_rps_frequency_cs()
660 vma->node.start, in live_rps_frequency_cs()
666 if (wait_for(intel_uncore_read(engine->uncore, CS_GPR(0)), in live_rps_frequency_cs()
669 engine->name); in live_rps_frequency_cs()
673 min.freq = rps->min_freq; in live_rps_frequency_cs()
676 max.freq = rps->max_freq; in live_rps_frequency_cs()
680 engine->name, in live_rps_frequency_cs()
692 engine->name, in live_rps_frequency_cs()
697 for (f = min.freq + 1; f <= rps->max_freq; f++) { in live_rps_frequency_cs()
706 engine->name, in live_rps_frequency_cs()
714 err = -EINTR; /* ignore error, continue on with test */ in live_rps_frequency_cs()
719 i915_gem_object_flush_map(vma->obj); in live_rps_frequency_cs()
720 i915_gem_object_unpin_map(vma->obj); in live_rps_frequency_cs()
726 if (igt_flush_test(gt->i915)) in live_rps_frequency_cs()
727 err = -EIO; in live_rps_frequency_cs()
733 rps->work.func = saved_work; in live_rps_frequency_cs()
745 struct intel_rps *rps = &gt->rps; in live_rps_frequency_srm()
760 if (GRAPHICS_VER(gt->i915) < 8) /* for CS simplicity */ in live_rps_frequency_srm()
767 saved_work = rps->work.func; in live_rps_frequency_srm()
768 rps->work.func = dummy_rps_work; in live_rps_frequency_srm()
782 engine->kernel_context->vm, true, in live_rps_frequency_srm()
796 err = i915_request_await_object(rq, vma->obj, false); in live_rps_frequency_srm()
800 err = rq->engine->emit_bb_start(rq, in live_rps_frequency_srm()
801 vma->node.start, in live_rps_frequency_srm()
809 engine->name); in live_rps_frequency_srm()
813 min.freq = rps->min_freq; in live_rps_frequency_srm()
816 max.freq = rps->max_freq; in live_rps_frequency_srm()
820 engine->name, in live_rps_frequency_srm()
832 engine->name, in live_rps_frequency_srm()
837 for (f = min.freq + 1; f <= rps->max_freq; f++) { in live_rps_frequency_srm()
846 engine->name, in live_rps_frequency_srm()
854 err = -EINTR; /* ignore error, continue on with test */ in live_rps_frequency_srm()
859 i915_gem_object_flush_map(vma->obj); in live_rps_frequency_srm()
860 i915_gem_object_unpin_map(vma->obj); in live_rps_frequency_srm()
866 if (igt_flush_test(gt->i915)) in live_rps_frequency_srm()
867 err = -EIO; in live_rps_frequency_srm()
873 rps->work.func = saved_work; in live_rps_frequency_srm()
888 GEM_BUG_ON(rps->pm_iir); in sleep_for_ei()
897 struct igt_spinner *spin) in __rps_up_interrupt() argument
899 struct intel_uncore *uncore = engine->uncore; in __rps_up_interrupt()
906 rps_set_check(rps, rps->min_freq); in __rps_up_interrupt()
908 rq = igt_spinner_create_request(spin, engine->kernel_context, MI_NOOP); in __rps_up_interrupt()
915 if (!igt_wait_for_spinner(spin, rq)) { in __rps_up_interrupt()
917 engine->name); in __rps_up_interrupt()
919 intel_gt_set_wedged(engine->gt); in __rps_up_interrupt()
920 return -EIO; in __rps_up_interrupt()
925 engine->name); in __rps_up_interrupt()
926 igt_spinner_end(spin); in __rps_up_interrupt()
928 return -EINVAL; in __rps_up_interrupt()
931 if (!(rps->pm_events & GEN6_PM_RP_UP_THRESHOLD)) { in __rps_up_interrupt()
932 pr_err("%s: RPS did not register UP interrupt\n", in __rps_up_interrupt()
933 engine->name); in __rps_up_interrupt()
935 return -EINVAL; in __rps_up_interrupt()
938 if (rps->last_freq != rps->min_freq) { in __rps_up_interrupt()
940 engine->name); in __rps_up_interrupt()
942 return -EINVAL; in __rps_up_interrupt()
946 timeout = intel_gt_pm_interval_to_ns(engine->gt, timeout); in __rps_up_interrupt()
952 igt_spinner_end(spin); in __rps_up_interrupt()
955 if (rps->cur_freq != rps->min_freq) { in __rps_up_interrupt()
956 pr_err("%s: Frequency unexpectedly changed [up], now %d!\n", in __rps_up_interrupt()
957 engine->name, intel_rps_read_actual_frequency(rps)); in __rps_up_interrupt()
958 return -EINVAL; in __rps_up_interrupt()
961 if (!(rps->pm_iir & GEN6_PM_RP_UP_THRESHOLD)) { in __rps_up_interrupt()
962 …pr_err("%s: UP interrupt not recorded for spinner, pm_iir:%x, prev_up:%x, up_threshold:%x, up_ei:%… in __rps_up_interrupt()
963 engine->name, rps->pm_iir, in __rps_up_interrupt()
967 return -EINVAL; in __rps_up_interrupt()
976 struct intel_uncore *uncore = engine->uncore; in __rps_down_interrupt()
979 rps_set_check(rps, rps->max_freq); in __rps_down_interrupt()
981 if (!(rps->pm_events & GEN6_PM_RP_DOWN_THRESHOLD)) { in __rps_down_interrupt()
983 engine->name); in __rps_down_interrupt()
984 return -EINVAL; in __rps_down_interrupt()
987 if (rps->last_freq != rps->max_freq) { in __rps_down_interrupt()
989 engine->name); in __rps_down_interrupt()
990 return -EINVAL; in __rps_down_interrupt()
994 timeout = intel_gt_pm_interval_to_ns(engine->gt, timeout); in __rps_down_interrupt()
999 if (rps->cur_freq != rps->max_freq) { in __rps_down_interrupt()
1001 engine->name, in __rps_down_interrupt()
1003 return -EINVAL; in __rps_down_interrupt()
1006 if (!(rps->pm_iir & (GEN6_PM_RP_DOWN_THRESHOLD | GEN6_PM_RP_DOWN_TIMEOUT))) { in __rps_down_interrupt()
1008 engine->name, rps->pm_iir, in __rps_down_interrupt()
1015 return -EINVAL; in __rps_down_interrupt()
1024 struct intel_rps *rps = &gt->rps; in live_rps_interrupt()
1028 struct igt_spinner spin; in live_rps_interrupt() local
1036 if (!intel_rps_has_interrupts(rps) || GRAPHICS_VER(gt->i915) < 6) in live_rps_interrupt()
1040 pm_events = rps->pm_events; in live_rps_interrupt()
1044 return -ENODEV; in live_rps_interrupt()
1047 if (igt_spinner_init(&spin, gt)) in live_rps_interrupt()
1048 return -ENOMEM; in live_rps_interrupt()
1051 saved_work = rps->work.func; in live_rps_interrupt()
1052 rps->work.func = dummy_rps_work; in live_rps_interrupt()
1055 /* Keep the engine busy with a spinner; expect an UP! */ in live_rps_interrupt()
1057 intel_gt_pm_wait_for_idle(engine->gt); in live_rps_interrupt()
1062 err = __rps_up_interrupt(rps, engine, &spin); in live_rps_interrupt()
1068 intel_gt_pm_wait_for_idle(engine->gt); in live_rps_interrupt()
1074 intel_rc6_disable(&gt->rc6); in live_rps_interrupt()
1078 intel_rc6_enable(&gt->rc6); in live_rps_interrupt()
1086 if (igt_flush_test(gt->i915)) in live_rps_interrupt()
1087 err = -EIO; in live_rps_interrupt()
1089 igt_spinner_fini(&spin); in live_rps_interrupt()
1092 rps->work.func = saved_work; in live_rps_interrupt()
1104 dE = librapl_energy_uJ() - dE; in __measure_power()
1105 dt = ktime_get() - dt; in __measure_power()
1128 struct intel_rps *rps = &gt->rps; in live_rps_power()
1132 struct igt_spinner spin; in live_rps_power() local
1141 if (!intel_rps_is_enabled(rps) || GRAPHICS_VER(gt->i915) < 6) in live_rps_power()
1144 if (!librapl_supported(gt->i915)) in live_rps_power()
1147 if (igt_spinner_init(&spin, gt)) in live_rps_power()
1148 return -ENOMEM; in live_rps_power()
1151 saved_work = rps->work.func; in live_rps_power()
1152 rps->work.func = dummy_rps_work; in live_rps_power()
1166 rq = igt_spinner_create_request(&spin, in live_rps_power()
1167 engine->kernel_context, in live_rps_power()
1177 if (!igt_wait_for_spinner(&spin, rq)) { in live_rps_power()
1179 engine->name); in live_rps_power()
1180 igt_spinner_end(&spin); in live_rps_power()
1182 intel_gt_set_wedged(engine->gt); in live_rps_power()
1183 err = -EIO; in live_rps_power()
1187 max.freq = rps->max_freq; in live_rps_power()
1190 min.freq = rps->min_freq; in live_rps_power()
1193 igt_spinner_end(&spin); in live_rps_power()
1197 engine->name, in live_rps_power()
1210 engine->name); in live_rps_power()
1211 err = -EINVAL; in live_rps_power()
1215 if (igt_flush_test(gt->i915)) { in live_rps_power()
1216 err = -EIO; in live_rps_power()
1221 igt_spinner_fini(&spin); in live_rps_power()
1224 rps->work.func = saved_work; in live_rps_power()
1232 struct intel_rps *rps = &gt->rps; in live_rps_dynamic()
1235 struct igt_spinner spin; in live_rps_dynamic() local
1245 if (!intel_rps_is_enabled(rps) || GRAPHICS_VER(gt->i915) < 6) in live_rps_dynamic()
1248 if (igt_spinner_init(&spin, gt)) in live_rps_dynamic()
1249 return -ENOMEM; in live_rps_dynamic()
1268 rps->cur_freq = rps->min_freq; in live_rps_dynamic()
1271 intel_rc6_disable(&gt->rc6); in live_rps_dynamic()
1272 GEM_BUG_ON(rps->last_freq != rps->min_freq); in live_rps_dynamic()
1274 rq = igt_spinner_create_request(&spin, in live_rps_dynamic()
1275 engine->kernel_context, in live_rps_dynamic()
1285 max.freq = wait_for_freq(rps, rps->max_freq, 500); in live_rps_dynamic()
1288 igt_spinner_end(&spin); in live_rps_dynamic()
1291 min.freq = wait_for_freq(rps, rps->min_freq, 2000); in live_rps_dynamic()
1295 engine->name, in live_rps_dynamic()
1302 engine->name); in live_rps_dynamic()
1303 err = -EINVAL; in live_rps_dynamic()
1307 intel_rc6_enable(&gt->rc6); in live_rps_dynamic()
1310 if (igt_flush_test(gt->i915)) in live_rps_dynamic()
1311 err = -EIO; in live_rps_dynamic()
1316 igt_spinner_fini(&spin); in live_rps_dynamic()